63 lines
1.5 KiB
C#
63 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows;
|
|
using Life.Annotations;
|
|
using Life.Automaton;
|
|
|
|
namespace Life
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window, INotifyPropertyChanged
|
|
{
|
|
private IField _field;
|
|
private int _size;
|
|
private Rule _rule = GameOfLife.Rule("3", "23");
|
|
|
|
public IField Field
|
|
{
|
|
get => _field;
|
|
set
|
|
{
|
|
_field = value;
|
|
OnPropertyChanged(nameof(Field));
|
|
}
|
|
}
|
|
|
|
public int Size
|
|
{
|
|
get => _size;
|
|
set
|
|
{
|
|
_size = value;
|
|
OnPropertyChanged(nameof(Size));
|
|
}
|
|
}
|
|
|
|
public MainWindow()
|
|
{
|
|
Size = 20;
|
|
Field = new MooreField(20, 20);
|
|
Field[5, 5].IsAlive = true;
|
|
DataContext = this;
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Step_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
Field.Transform(_rule);
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
[NotifyPropertyChangedInvocator]
|
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
} |