Mozliwosc wykonywania kilku krokow na raz
This commit is contained in:
parent
db989e9801
commit
af2568a913
@ -30,12 +30,11 @@
|
|||||||
<GridSplitter Grid.Column="1" Width="3" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"/>
|
<GridSplitter Grid.Column="1" Width="3" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"/>
|
||||||
|
|
||||||
<StackPanel Orientation="Vertical" Margin="8" Grid.Column="2" HorizontalAlignment="Stretch">
|
<StackPanel Orientation="Vertical" Margin="8" Grid.Column="2" HorizontalAlignment="Stretch">
|
||||||
<DockPanel HorizontalAlignment="Stretch" Margin="0 0 0 8">
|
<DockPanel Margin="0 0 0 8">
|
||||||
<TextBlock Style="{StaticResource Header}" VerticalAlignment="Center">Iteration</TextBlock>
|
<TextBlock Style="{StaticResource Header}" VerticalAlignment="Center">Iteration</TextBlock>
|
||||||
<TextBlock Style="{StaticResource Value}" Text="{Binding Iteration}" VerticalAlignment="Stretch"/>
|
<TextBlock Style="{StaticResource Value}" Text="{Binding Iteration}" HorizontalAlignment="Stretch"/>
|
||||||
<Button VerticalAlignment="Center" Command="{Binding StepCommand}" HorizontalAlignment="Right">
|
<Button VerticalAlignment="Stretch" Command="{Binding StepCommand}" CommandParameter="{Binding Steps}" DockPanel.Dock="Right" HorizontalAlignment="Right" Padding="8">step</Button>
|
||||||
<TextBlock Margin="4">step</TextBlock>
|
<TextBox Text="{Binding Steps}" VerticalAlignment="Stretch" HorizontalAlignment="Right" DockPanel.Dock="Right" Padding="8" BorderThickness="1 1 0 1"/>
|
||||||
</Button>
|
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<DockPanel HorizontalAlignment="Stretch" Margin="0 0 0 8">
|
<DockPanel HorizontalAlignment="Stretch" Margin="0 0 0 8">
|
||||||
<TextBlock Style="{StaticResource Header}" VerticalAlignment="Center" DockPanel.Dock="Left">Size</TextBlock>
|
<TextBlock Style="{StaticResource Header}" VerticalAlignment="Center" DockPanel.Dock="Left">Size</TextBlock>
|
||||||
|
@ -18,16 +18,13 @@ namespace Life
|
|||||||
{
|
{
|
||||||
Automaton = new GameOfLife(20, 20),
|
Automaton = new GameOfLife(20, 20),
|
||||||
Size = 16,
|
Size = 16,
|
||||||
Separation = 2
|
Separation = 2,
|
||||||
|
Steps = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
DataContext = ViewModel;
|
DataContext = ViewModel;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CommandBinding_OnExecuted(object sender, ExecutedRoutedEventArgs e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ namespace Life.ViewModel
|
|||||||
private int _separation;
|
private int _separation;
|
||||||
private int _width;
|
private int _width;
|
||||||
private int _height;
|
private int _height;
|
||||||
|
private int _steps;
|
||||||
private IAutomaton _automaton;
|
private IAutomaton _automaton;
|
||||||
private IFormatter _formatter = new BinaryFormatter();
|
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 IField Field => Automaton.Field;
|
||||||
public int Iteration => Automaton.Iteration;
|
public int Iteration => Automaton.Iteration;
|
||||||
|
|
||||||
@ -104,14 +115,15 @@ namespace Life.ViewModel
|
|||||||
Action = HandleSaveCommand
|
Action = HandleSaveCommand
|
||||||
};
|
};
|
||||||
|
|
||||||
public ICommand StepCommand => new DelegateCommand<object>
|
public ICommand StepCommand => new DelegateCommand<int>
|
||||||
{
|
{
|
||||||
Action = Step
|
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));
|
OnPropertyChanged(nameof(Iteration));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user