-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml
157 lines (133 loc) · 8.9 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<Window x:Class="Mazeinator.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="Mazeinator" Height="720" Width="1280" MinHeight="480" MinWidth="960" Background="Ivory"
UseLayoutRounding="True" WindowStartupLocation="CenterScreen"
SizeChanged="Window_SizeChanged"
Closing="Window_Closing" Loaded="Window_Loaded" ResizeMode="CanResizeWithGrip">
<Window.InputBindings>
<KeyBinding Command="{Binding NewFileCMD}" Modifiers="Ctrl" Key="N" />
<KeyBinding Command="{Binding SaveFileCMD}" Modifiers="Ctrl" Key="S" />
<KeyBinding Command="{Binding LoadFileCMD}" Modifiers="Ctrl" Key="W" />
<KeyBinding Command="{Binding GenerateCMD}" Modifiers="Ctrl" Key="D" />
<KeyBinding Command="{Binding GenerateBlankCMD}" Modifiers="Ctrl+Shift" Key="D" />
<KeyBinding Command="{Binding ExportCMD}" Modifiers="Ctrl" Key="E" />
<KeyBinding Command="{Binding QuitCMD}" Modifiers="Ctrl" Key="Q" />
<KeyBinding Command="{Binding AboutCMD}" Key="F1" />
</Window.InputBindings>
<Window.Resources>
<Style x:Key="StatusBarTextStyle" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Padding" Value="3,0" />
<Setter Property="Margin" Value="1,0" />
</Style>
<Style x:Key="MenuItemStyle" TargetType="MenuItem">
<Setter Property="Padding" Value="3,0,1,0" />
<Setter Property="Margin" Value="1,0,0,0" />
</Style>
</Window.Resources>
<DockPanel>
<!--Top menu panel-->
<Menu DockPanel.Dock="Top" Padding="3,3">
<MenuItem Header="_File">
<MenuItem Header="_New" Click="NewMaze" InputGestureText="Ctrl+N" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Generate" Click="MazeGeneration" InputGestureText="Ctrl+D" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="Generate _Blank" Click="MazeBlankGeneration" InputGestureText="Ctrl+Shift+D" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Save" Click="SaveMaze" InputGestureText="Ctrl+S" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Load" Click="LoadMaze" InputGestureText="Ctrl+W" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Export" Click="ExportMaze" InputGestureText="Ctrl+E" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Close" Click="CloseApp" InputGestureText="Ctrl+Q" Style="{StaticResource MenuItemStyle}" />
</MenuItem>
<MenuItem Header="_Options">
<MenuItem Header="Visual _Settings" Click="SettingOpen" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Greedy" Click="Greedy_click" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Dijkstra" Click="Dijkstra_click" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_A☆" Click="AStar_click" Style="{StaticResource MenuItemStyle}" />
<ComboBox SelectedIndex="0" Padding="5,2,2,2" Margin="1,1,1,1" Width="100"
Name="HeurSelect" SelectionChanged="HeuristicSelector">
<ComboBoxItem>Euclidean</ComboBoxItem>
<ComboBoxItem>Euclidean Squared</ComboBoxItem>
<ComboBoxItem>Manhattan</ComboBoxItem>
<ComboBoxItem>Diagonal</ComboBoxItem>
</ComboBox>
</MenuItem>
<MenuItem Header="About" Click="AboutClick" Style="{StaticResource MenuItemStyle}" />
</Menu>
<Grid x:Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0"
Orientation="Horizontal" VerticalAlignment="Center"
Height="auto" Margin="0,3">
<TextBlock Text="Width:" Style="{StaticResource StatusBarTextStyle}" />
<xctk:IntegerUpDown Name="WidthBox" Value="{Binding Path=NodeCountX, Mode=TwoWay}" Minimum="1" Maximum="1024"
TextAlignment="Center" VerticalContentAlignment="Center"
Width="55" Padding="3,0" />
<TextBlock Text="Height:" Style="{StaticResource StatusBarTextStyle}" />
<xctk:IntegerUpDown Name="HeightBox" Value="{Binding Path=NodeCountY, Mode=TwoWay}" Minimum="1" Maximum="1024"
TextAlignment="Center" VerticalContentAlignment="Center"
Width="55" Padding="3,0" />
<Button Click="MazeGeneration" Height="auto" Padding="3,0" Margin="3,0,0,0">Generate</Button>
<TextBlock Text="Node count: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=NodeCount, Mode=OneWay}" />
</TextBlock>
</StackPanel>
<!--Canvas for maze drawing-->
<Canvas Grid.Row="1" x:Name="MainCanvas" Grid.Column="0" Background="Transparent">
<Canvas.ContextMenu>
<ContextMenu>
<MenuItem Header="Visual _Settings" Click="SettingOpen" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Greedy" Click="Greedy_click" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_Dijkstra" Click="Dijkstra_click" Style="{StaticResource MenuItemStyle}" />
<MenuItem Header="_A☆" Click="AStar_click" Style="{StaticResource MenuItemStyle}" />
</ContextMenu>
</Canvas.ContextMenu>
<Image x:Name="pictureBox" Source="{Binding Path=MazeBindedBitmap, Mode=OneWay}" MouseLeftButtonDown="SelectNode"
Width="{Binding Path=ActualWidth, ElementName=MainCanvas}" Height="{Binding Path=ActualHeight, ElementName=MainCanvas}"
Stretch="Uniform" RenderOptions.BitmapScalingMode="Fant" />
</Canvas>
<StatusBar Grid.Row="2">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Node count: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=NodeCount, Mode=OneWay}" />
</TextBlock>
<TextBlock Text="Processing time: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=LastGenTime, Mode=OneWay}" />
</TextBlock>
<TextBlock Text="Render time: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=LastRenderTime, Mode=OneWay}" />
</TextBlock>
<TextBlock Text="Render size: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=RenderSizeX, Mode=OneWay}" />
<TextBlock Text="×" />
<TextBlock Text="{Binding Path=RenderSizeY, Mode=OneWay}" />
</TextBlock>
<TextBlock Text="Canvas size: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=CanvasSizeX, Mode=OneWay}" />
<TextBlock Text="×" />
<TextBlock Text="{Binding Path=CanvasSizeY, Mode=OneWay}" />
</TextBlock>
<Separator Margin="1,2,1,0" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<TextBlock Text="Path length: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=PathLength, Mode=OneWay}" />
</TextBlock>
<TextBlock Text="Explored nodes: " Style="{StaticResource StatusBarTextStyle}">
<TextBlock Text="{Binding Path=ExploredNodes, Mode=OneWay}" />
</TextBlock>
<Separator Margin="1,2,1,0" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<TextBlock Text="{Binding Path=Status, Mode=OneWay}" Style="{StaticResource StatusBarTextStyle}" />
</StackPanel>
</StatusBar>
</Grid>
</DockPanel>
</Window>