From af2568a9134e4af8862a4d35bb9cab38a40107f9 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Mon, 28 Oct 2019 18:37:39 +0100 Subject: [PATCH] Mozliwosc wykonywania kilku krokow na raz --- Life/MainWindow.xaml | 9 ++++----- Life/MainWindow.xaml.cs | 7 ++----- Life/ViewModel/AutomatonViewModel.cs | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Life/MainWindow.xaml b/Life/MainWindow.xaml index 0352c0b..c306aba 100644 --- a/Life/MainWindow.xaml +++ b/Life/MainWindow.xaml @@ -30,12 +30,11 @@ - + Iteration - - + + + Size diff --git a/Life/MainWindow.xaml.cs b/Life/MainWindow.xaml.cs index b3ad5a3..0abbfe5 100644 --- a/Life/MainWindow.xaml.cs +++ b/Life/MainWindow.xaml.cs @@ -18,16 +18,13 @@ namespace Life { Automaton = new GameOfLife(20, 20), Size = 16, - Separation = 2 + Separation = 2, + Steps = 1, }; DataContext = ViewModel; InitializeComponent(); } - - private void CommandBinding_OnExecuted(object sender, ExecutedRoutedEventArgs e) - { - } } } \ No newline at end of file diff --git a/Life/ViewModel/AutomatonViewModel.cs b/Life/ViewModel/AutomatonViewModel.cs index cdfec2e..1657ef1 100644 --- a/Life/ViewModel/AutomatonViewModel.cs +++ b/Life/ViewModel/AutomatonViewModel.cs @@ -15,6 +15,7 @@ namespace Life.ViewModel private int _separation; private int _width; private int _height; + private int _steps; private IAutomaton _automaton; private IFormatter _formatter = new BinaryFormatter(); @@ -81,6 +82,16 @@ namespace Life.ViewModel } } + public int Steps + { + get => _steps; + set + { + _steps = value; + OnPropertyChanged(nameof(Steps)); + } + } + public IField Field => Automaton.Field; public int Iteration => Automaton.Iteration; @@ -104,14 +115,15 @@ namespace Life.ViewModel Action = HandleSaveCommand }; - public ICommand StepCommand => new DelegateCommand + public ICommand StepCommand => new DelegateCommand { Action = Step }; - private void Step(object param) + private void Step(int param) { - Automaton.Advance(); + for (int i = 0; i < param; i++) + Automaton.Advance(); OnPropertyChanged(nameof(Iteration)); }