Skip to content

Commit dab4925

Browse files
committed
Final Touches
1 parent 1f44d11 commit dab4925

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

MattEland.FSharpGeneticAlgorithm.WindowsClient/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
xmlns:local="clr-namespace:MattEland.FSharpGeneticAlgorithm.WindowsClient"
55
StartupUri="MainWindow.xaml">
66
<Application.Resources>
7+
<BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>
78
</Application.Resources>
89
</Application>

MattEland.FSharpGeneticAlgorithm.WindowsClient/MainWindow.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:windowsClient="clr-namespace:MattEland.FSharpGeneticAlgorithm.WindowsClient"
77
mc:Ignorable="d"
8-
Title="WPF Core C# talking to F# Tutorial by Matt Eland"
9-
Width="755" Height="650"
8+
Title="Genetic Algorithms in F# and WPF Core by Matt Eland"
9+
Width="725" Height="650"
1010
Background="Black" Foreground="White">
1111
<DockPanel>
1212
<!-- Status Bar -->
@@ -25,6 +25,7 @@
2525
<Button Margin="0,5" Command="{Binding Advance10Command}">Next 10 Generations</Button>
2626
<Button Margin="0,5" Command="{Binding RandomizeCommand}">Randomize Worlds</Button>
2727
<Button Margin="0,5" Command="{Binding ResetCommand}">Reset</Button>
28+
<CheckBox IsChecked="{Binding ShowHeatMap}" x:Name="checkShowHeatMap" Foreground="White">Show Tile Attractiveness</CheckBox>
2829
</StackPanel>
2930
<TextBlock DockPanel.Dock="Top" FontWeight="Bold" Margin="0,10">Population</TextBlock>
3031
<windowsClient:BrainInfoControl DockPanel.Dock="Bottom"
@@ -65,7 +66,7 @@
6566
</Style>
6667
</ItemsControl.ItemContainerStyle>
6768
</ItemsControl>
68-
<ItemsControl ItemsSource="{Binding HeatMap}" Width="150" Height="150">
69+
<ItemsControl ItemsSource="{Binding HeatMap}" Visibility="{Binding ElementName=checkShowHeatMap, Path=IsChecked, Converter={StaticResource VisibilityConverter}}" Width="150" Height="150">
6970
<ItemsControl.ItemTemplate>
7071
<ItemContainerTemplate>
7172
<Border Background="{Binding Fill}" ToolTip="{Binding Text}" Opacity="0.5" Width="10" Height="10">

MattEland.FSharpGeneticAlgorithm.WindowsClient/ViewModels/MainViewModel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ public SimulationResultViewModel SelectedBrain
4949
}
5050
}
5151

52+
public bool ShowHeatMap
53+
{
54+
get => _showHeatMap;
55+
set
56+
{
57+
if (value == _showHeatMap) return;
58+
_showHeatMap = value;
59+
OnPropertyChanged();
60+
}
61+
}
62+
5263
public ActionCommand ResetCommand { get; }
5364
public ActionCommand RandomizeCommand { get; }
5465
public ActionCommand AdvanceCommand { get; }
@@ -102,5 +113,6 @@ private void AdvanceToNextGeneration()
102113

103114
private SimulationResultViewModel _brain;
104115
private World.World[] _worlds;
116+
private bool _showHeatMap;
105117
}
106118
}

0 commit comments

Comments
 (0)