-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml
More file actions
300 lines (294 loc) · 13.1 KB
/
MainWindow.xaml
File metadata and controls
300 lines (294 loc) · 13.1 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<Window x:Class="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:tk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ruler="clr-namespace:RulerControl;assembly=RulerControl"
xmlns:local="clr-namespace:WpfApp5"
mc:Ignorable="d"
Title="MainWindow"
Height="600"
Width="1024"
Left="0"
Top="0"
WindowStartupLocation="Manual">
<Window.Resources>
<SolidColorBrush x:Key="LightGreyBrush"
Color="LightGray"/>
<SolidColorBrush x:Key="MidGreyBrush"
Color="MediumBlue"/>
<SolidColorBrush x:Key="DarkGreyBrush"
Color="Gray"/>
<Style TargetType="{x:Type Button}"
x:Key="3DButtonStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Border x:Name="TopLeftBorder"
BorderBrush="{StaticResource LightGreyBrush}"
BorderThickness="2,2,0,0"/>
<Border x:Name="BottomRightBorder"
BorderBrush="{StaticResource DarkGreyBrush}"
BorderThickness="0,0,2,2"/>
<Grid Margin="3">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="AliceBlue"
Offset="0"/>
<GradientStop Color="LightBlue"
Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<ContentPresenter Margin="{TemplateBinding Padding}"/>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed"
Value="True">
<Setter TargetName="TopLeftBorder"
Property="BorderBrush"
Value="{StaticResource DarkGreyBrush}"/>
<Setter TargetName="BottomRightBorder"
Property="BorderBrush"
Value="{StaticResource LightGreyBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid x:Name="MainGrid"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Menu IsMainMenu="True"
Grid.Row="0"
Grid.ColumnSpan="2">
<MenuItem Header="_File">
<MenuItem x:Name="miLoadXml" Header="Load From Xml" Click="miLoadXml_Click">
<MenuItem.Icon>
<Frame Source="Resources/Folder_16x.xaml"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="miSaveAsXml" Header="Save to Xml" Click="miSaveAsXml_Click">
<MenuItem.Icon>
<Frame Source="Resources/SaveAs_16x.xaml"/>
</MenuItem.Icon>
</MenuItem>
<Separator/>
<MenuItem x:Name="miExit" Header="Exit" Click="miExit_Click">
<MenuItem.Icon>
<Frame Source="Resources/Close_16x.xaml"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="View">
<MenuItem x:Name="miShowBox"
Header="Show Bounding Box"
IsCheckable="True"
IsChecked="True"
Click="miShowBox_Click"/>
<MenuItem x:Name="miShowCenter"
Header="Show Center Marker"
IsCheckable="True"
IsChecked="True"
Click="miShowCenter_Click"/>
<MenuItem x:Name="miShowLines"
Header="Show Interior Lines"
IsCheckable="True"
IsChecked="True"
Click="miShowLines_Click"/>
<MenuItem x:Name="miShowValueOnRulers"
Header="Show Moving Point Values on Rulers"
IsCheckable="true"
IsChecked="True"
Click="miShowValueOnRulers_Click"/>
</MenuItem>
<MenuItem Header="_Help">
<MenuItem x:Name="miAbout"
Header="_About"
Click="miAbout_Click"/>
</MenuItem>
</Menu>
<WrapPanel Grid.Row="1"
Grid.ColumnSpan="2"
Orientation="Horizontal">
<local:ToolBarEx Loaded="ToolBarEx_Loaded">
<Separator/>
<Button x:Name="btnNewPolygon"
Content="New Polygon"
Style="{StaticResource 3DButtonStyle}"
Click="btnNewPolygon_Click"/>
<Separator/>
<Button x:Name="btnSaveCanvas"
Content="Save Canvas Image"
Style="{StaticResource 3DButtonStyle}"
Click="btnSaveCanvas_Click"/>
<Separator/>
</local:ToolBarEx>
<local:ToolBarEx Loaded="ToolBarEx_Loaded"
VerticalContentAlignment="Center"
Height="30">
<Label Content="Rotation Angle"
VerticalContentAlignment="Center"/>
<local:ComboBoxEx x:Name="cbRotationAngle"
MinWidth="100"
IsEditable="True"
IsReadOnly="False"
SelectedIndex="6"
Loaded="cbRotationAngle_Loaded"
SelectionChanged="cbRotationAngle_SelectionChanged"/>
</local:ToolBarEx>
</WrapPanel>
<Grid x:Name="CanvasGrid"
Grid.Row="2"
Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="300"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ruler:RulerControl x:Name="rlrVertical" Width="25"
Grid.Column="0"
Grid.Row="1"
Orientation="Vertical"
Background="Silver"
Foreground="Black"/>
<Canvas x:Name="cnv"
Grid.Row="1"
Grid.Column="1"
Background="AliceBlue"
MouseLeftButtonDown="cnv_MouseLeftButtonDown"
MouseLeftButtonUp="cnv_MouseLeftButtonUp"
MouseRightButtonDown="cnv_MouseRightButtonDown"
MouseRightButtonUp="cnv_MouseRightButtonUp"
MouseMove="cnv_MouseMove"
MouseWheel="cnv_MouseWheel"
SizeChanged="cnv_SizeChanged"
Loaded="cnv_Loaded">
<Polygon Name="PBox" x:Uid="PBox" Tag="PBox"
Stroke="Black"
Fill="Transparent"
StrokeThickness="1"
StrokeDashArray="0.5 0.5"/>
<Polygon Name="PGon" x:Uid="PGon" Tag="PGon"
Stroke="Blue"
StrokeThickness="1"
StrokeLineJoin="Round"
Fill="LightBlue"/>
<Polyline Name="PLines" x:Uid="PLines" Tag="PLines"
Fill="Transparent"
Stroke="Green"
StrokeThickness="1"
StrokeLineJoin="Round"
StrokeDashArray="0.5 0.5"/>
<Ellipse Name="PVertex" x:Uid="PVertex" Tag="PVertex"
Visibility="Hidden"
Stroke="Black"
StrokeThickness="1"
Fill="Transparent"
Width="11"
Height="11"/>
<Polygon Name="PCentroid" x:Uid="PCentroid" Tag="PCentroid"
Stroke="Black"
StrokeThickness="1"
Fill="Red"/>
</Canvas>
<ruler:RulerControl x:Name="rlrHorizontal" Height="25"
Grid.Column="1"
Grid.Row="0"
Orientation="Horizontal"
Background="Silver"
Foreground="Black"/>
<Grid Grid.Row="1" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<GroupBox Header="Colors" Margin="4">
<GroupItem Margin="4">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Outline"
Width="60"
VerticalAlignment="Center"
FontSize="10"/>
<local:ColorComboBox x:Name="cbOutline" Width="200"
SelectionChanged="cbOutline_SelectionChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Interior"
Width="60"
VerticalAlignment="Center"
FontSize="10"/>
<local:ColorComboBox x:Name="cbInterior" Width="200"
SelectionChanged="cbInterior_SelectionChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Box"
Width="60"
VerticalAlignment="Center"
FontSize="10"/>
<local:ColorComboBox x:Name="cbBox" Width="200"
SelectionChanged="cbBox_SelectionChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Lines"
Width="60"
VerticalAlignment="Center"
FontSize="10"/>
<local:ColorComboBox x:Name="cbLines" Width="200"
SelectionChanged="cbLines_SelectionChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Centroid"
Width="60"
VerticalAlignment="Center"
FontSize="10"/>
<local:ColorComboBox x:Name="cbCentroid" Width="200"
SelectionChanged="cbCentroid_SelectionChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Canvas"
Width="60"
VerticalAlignment="Center"
FontSize="10"/>
<local:ColorComboBox x:Name="cbCanvas" Width="200"
SelectionChanged="cbCanvas_SelectionChanged"/>
</StackPanel>
<Separator/>
<Button x:Name="btnResetColors" Width="70" HorizontalAlignment="Left" Content="Reset Colors" Click="btnResetColors_Click">
</Button>
</StackPanel>
</GroupItem>
</GroupBox>
</StackPanel>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="TB" Grid.Row="1"
Background="AntiqueWhite"
Padding="10"/>
</ScrollViewer>
</Grid>
</Grid>
<StatusBar Grid.Row="3"
Grid.ColumnSpan="2">
<StatusBarItem>
<TextBlock/>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>