-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMainWindow.xaml
94 lines (91 loc) · 5.58 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<Window x:Class="MattEland.FSharpGeneticAlgorithm.WindowsClient.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowsClient="clr-namespace:MattEland.FSharpGeneticAlgorithm.WindowsClient"
mc:Ignorable="d"
Title="Genetic Algorithms in F# and WPF Core by Matt Eland"
Width="725" Height="650"
Background="Black" Foreground="White">
<DockPanel>
<!-- Status Bar -->
<StatusBar DockPanel.Dock="Bottom" DataContext="{Binding SelectedBrain.SelectedState}" Background="{Binding GameStatusBrush}" FontWeight="Bold">
<StatusBarItem>
<TextBlock Text="{Binding TurnsLeftText}"></TextBlock>
</StatusBarItem>
<StatusBarItem HorizontalAlignment="Right">
<TextBlock Text="{Binding GameStatusText}"></TextBlock>
</StatusBarItem>
</StatusBar>
<!-- Commands Area -->
<DockPanel DockPanel.Dock="Right" Width="150" Margin="0,0,8,8">
<StackPanel Margin="0,8,0,0" DockPanel.Dock="Top">
<Button Margin="0,5" Command="{Binding AdvanceCommand}">Next Generation</Button>
<Button Margin="0,5" Command="{Binding Advance10Command}">Next 10 Generations</Button>
<Button Margin="0,5" Command="{Binding Advance100Command}">Next 100 Generations</Button>
<Button Margin="0,5" Command="{Binding RandomizeCommand}">Randomize Worlds</Button>
<Button Margin="0,5" Command="{Binding ResetCommand}">Reset</Button>
<CheckBox IsChecked="{Binding ShowHeatMap}" x:Name="checkShowHeatMap" Foreground="White">Show Tile Attractiveness</CheckBox>
</StackPanel>
<TextBlock DockPanel.Dock="Top" FontWeight="Bold" Margin="0,10">Population</TextBlock>
<windowsClient:BrainInfoControl DockPanel.Dock="Bottom"
DataContext="{Binding SelectedBrain.Brain}"></windowsClient:BrainInfoControl>
<ListBox ItemsSource="{Binding Population}" SelectedItem="{Binding SelectedBrain}" DisplayMemberPath="DisplayText"></ListBox>
</DockPanel>
<!-- Main UI -->
<DockPanel DataContext="{Binding SelectedBrain}">
<!-- Time Control -->
<DockPanel DockPanel.Dock="Bottom" Margin="10">
<TextBlock DockPanel.Dock="Left" Margin="0,0,10,0">Time Index</TextBlock>
<Slider Minimum="0" Maximum="{Binding MaxStateIndex}" Value="{Binding CurrentIndex}"></Slider>
</DockPanel>
<Grid Margin="10" Background="Green" DataContext="{Binding SelectedState}">
<Image Source="Images/Grass.png" Stretch="Fill" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Image>
<Viewbox Stretch="Uniform">
<Grid>
<ItemsControl ItemsSource="{Binding Actors}" Width="150" Height="150" Panel.ZIndex="1">
<ItemsControl.ItemTemplate>
<ItemContainerTemplate>
<Border BorderBrush="Black" BorderThickness="1">
<Image Source="{Binding ImagePath}" Width="10" Height="10" Stretch="Fill"></Image>
</Border>
</ItemContainerTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas></Canvas>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding PosX}" />
<Setter Property="Canvas.Top" Value="{Binding PosY}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
<ItemsControl ItemsSource="{Binding HeatMap}" Visibility="{Binding ElementName=checkShowHeatMap, Path=IsChecked, Converter={StaticResource VisibilityConverter}}" Width="150" Height="150">
<ItemsControl.ItemTemplate>
<ItemContainerTemplate>
<Border Background="{Binding Fill}" ToolTip="{Binding Text}" Opacity="0.5" Width="10" Height="10">
</Border>
</ItemContainerTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas></Canvas>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding PosX}" />
<Setter Property="Canvas.Top" Value="{Binding PosY}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Grid>
</Viewbox>
</Grid>
</DockPanel>
</DockPanel>
</Window>