-
Notifications
You must be signed in to change notification settings - Fork 92
/
MainWindow.xaml
268 lines (259 loc) · 18.1 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
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
<mah:MetroWindow x:Class="AUCapture_WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
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:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:dialogs="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:converters="clr-namespace:AUCapture_WPF.Converters"
xmlns:controls="clr-namespace:AUCapture_WPF.Controls"
mc:Ignorable="d"
Style="{DynamicResource MahApps.Styles.MetroWindow.Clean}"
ResizeMode="CanResize"
Title="AUCapture" TitleAlignment="Center" Height="544" Width="544"
ShowInTaskbar="True"
TitleCharacterCasing="Normal"
ShowSystemMenu="False"
ShowSystemMenuOnRightClick="False"
Name="window"
SaveWindowPosition="false"
dialogs:DialogParticipation.Register="{Binding }"
ContentRendered="MainWindow_OnContentRendered" Loaded="MetroWindow_Loaded" TryToBeFlickerFree="True"
MinWidth="300" MinHeight="200">
<mah:MetroWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/clean/Controls.xaml" />
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Theme setting -->
</ResourceDictionary.MergedDictionaries>
<converters:PlayerToImage x:Key="PlayerToImage" />
<converters:BoolToString x:Key="BoolToString" />
<converters:EnumToStringConverter x:Key="EnumToStringConverter"/>
<converters:VisabilityInverterConverter x:Key="VisabilityInverterConverter"/>
<converters:BoolToVisibilityConverterInverted x:Key="BoolToVisibilityConverterInverted"/>
</ResourceDictionary>
</mah:MetroWindow.Resources>
<mah:MetroWindow.LeftWindowCommands>
<mah:WindowCommands>
<Button Click="Settings" ToolTip="Open the settings window">
<Button.ContentTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconModern Width="22" Height="22" VerticalAlignment="Center" Kind="Settings" />
<TextBlock Margin="4 0 0 0" VerticalAlignment="Center" Text="{Binding}" />
</StackPanel>
</DataTemplate>
</Button.ContentTemplate>
</Button>
</mah:WindowCommands>
</mah:MetroWindow.LeftWindowCommands>
<mah:MetroWindow.Flyouts>
<mah:FlyoutsControl>
<mah:Flyout x:Name="SettingsFlyout" Header="Settings"
Position="Left"
Width="{Binding ActualWidth, ElementName=window, Converter={dialogs:MathMultiplyConverter}, ConverterParameter=0.75}"
Theme="Adapt"
IsAutoCloseEnabled="False" AnimateOpacity="True" Opacity="0.90">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<Grid>
<mah:MetroAnimatedTabControl TabStripMargin="0 0 10 0" TabStripPlacement="Left"
mah:TabControlHelper.UnderlinePlacement="Right"
mah:TabControlHelper.Transition="LeftReplace"
mah:TabControlHelper.Underlined="TabPanel">
<mah:MetroTabItem Header="General">
<StackPanel Orientation="Vertical">
<mah:ToggleSwitch Header="Always copy game code"
IsOn="{Binding Settings.AlwaysCopyGameCode, Mode=TwoWay}" />
<mah:ToggleSwitch Header="Focus window on connect"
IsOn="{Binding Settings.FocusOnToken, Mode=TwoWay}" />
<mah:ToggleSwitch Header="API Server"
IsOn="{Binding Settings.ApiServer, Mode=TwoWay}"
Toggled="APIServerToggleSwitch_Toggled" />
</StackPanel>
</mah:MetroTabItem>
<mah:MetroTabItem Header="Theme">
<StackPanel Orientation="Vertical">
<mah:ToggleSwitch x:Name="DarkMode_Toggleswitch" Header="Dark mode"
IsOn="{Binding Settings.DarkMode, Mode=TwoWay}"
Toggled="Darkmode_Toggled" />
<mah:MetroHeader Header="Color Picker">
<mah:ColorPicker x:Name="AccentColorPicker"
SelectedColorChanged="AccentColorPicker_OnSelectedColorChanged"
mah:TextBoxHelper.AutoWatermark="True"
mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="Select a color" />
</mah:MetroHeader>
</StackPanel>
</mah:MetroTabItem>
<mah:MetroTabItem Header="Debug" x:Name="DebugTab">
<Grid Margin="0 10 0 0">
<StackPanel Orientation="Vertical">
<mah:ToggleSwitch Header="Debug mode"
IsOn="{Binding Settings.debug, Mode=TwoWay}" />
<Button x:Name="ReloadOffsetsButton" Content="Reload offsets"
Click="ReloadOffsetsButton_OnClick"
Style="{StaticResource MahApps.Styles.Button.Square.Accent}" />
</StackPanel>
</Grid>
</mah:MetroTabItem>
<mah:MetroTabItem Header="Discord" x:Name="DiscordTokenTab">
<Grid Margin="0 10 0 0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="20" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<PasswordBox x:Name="discordTokenBox"
VerticalContentAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Grid.Row="1"
Margin="0 5 5 0"
mah:ControlsHelper.FocusBorderBrush="{DynamicResource MahApps.Brushes.Accent}"
mah:TextBoxHelper.SelectAllOnFocus="True"
mah:TextBoxHelper.Watermark="Paste token here"
mah:TextBoxHelper.ButtonContent="{iconPacks:Unicons Kind=Question}"
Style="{DynamicResource MahApps.Styles.PasswordBox.Button}"
mah:TextBoxHelper.ButtonCommand="{Binding TextBoxButtonHelpCmd, Mode=OneWay}"
mah:TextBoxHelper.ButtonsAlignment="Right" />
<StackPanel Grid.Row="3"
MinHeight="85"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button Grid.Column="1" Content="Submit"
x:Name="SubmitDiscordButton" Margin="5 0 5 0"
IsDefault="True"
HorizontalAlignment="Center"
Click="SubmitDiscordButton_OnClick"
Style="{DynamicResource MahApps.Styles.Button.Dialogs.Accent}" />
</StackPanel>
</Grid>
</mah:MetroTabItem>
<mah:MetroTabItem Header="About">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<mah:MetroHeader Header="App version:">
<TextBox VerticalAlignment="Center" MinWidth="150" IsReadOnly="True"
Text="{Binding Version, Mode=OneWay}" />
</mah:MetroHeader>
<mah:MetroHeader Header="Latest version:">
<TextBox VerticalAlignment="Center" MinWidth="150" IsReadOnly="True"
Text="{Binding LatestVersion, Mode=OneWay}" />
</mah:MetroHeader>
</StackPanel>
</ScrollViewer>
</mah:MetroTabItem>
</mah:MetroAnimatedTabControl>
</Grid>
</StackPanel>
</ScrollViewer>
</mah:Flyout>
</mah:FlyoutsControl>
</mah:MetroWindow.Flyouts>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<GroupBox Name="ItemBox" Visibility="{Binding Connected, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.ColumnSpan="3" Grid.RowSpan="4" Header="Players">
<ItemsControl Grid.ColumnSpan="3" Grid.RowSpan="4" Name="PlayersList" ItemsSource="{Binding Players}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:PlayerControl PlayerName="{Binding Name}" Color="{Binding Color}"
AliveStatus="{Binding Alive}" PlayerPantsID="{Binding PantsID}" PlayerHatID="{Binding HatID}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="4" Columns="3" IsItemsHost="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</GroupBox>
<StackPanel VerticalAlignment="Center" Grid.RowSpan="4" Grid.ColumnSpan="3" Orientation="Vertical" Visibility="{Binding Connected, Converter={StaticResource BoolToVisibilityConverterInverted}}">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">
<Run FontSize="32" FontFamily="{StaticResource AUFont}">Waiting for among us</Run><LineBreak/>
</TextBlock>
<mah:ProgressRing IsActive="True" />
</StackPanel>
<Expander Grid.Column="2" Grid.Row="3" Header="Status" Visibility="{Binding ElementName=ItemBox, Path=Visibility}" ExpandDirection="Up" Margin="0" Panel.ZIndex="1" >
<DataGrid ItemsSource="{Binding ConnectionStatuses}" HeadersVisibility="None" AutoGenerateColumns="False" CanUserSortColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="IsHitTestVisible" Value="False"/>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTemplateColumn IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<iconPacks:PackIconUnicons VerticalAlignment="Center" VerticalContentAlignment="Center">
<iconPacks:PackIconUnicons.Style>
<Style TargetType="iconPacks:PackIconUnicons">
<Setter Property="Kind" Value="Multiply" />
<Setter Property="Foreground" Value="Red" />
<Style.Triggers>
<DataTrigger
Binding="{Binding Path=Connected, Converter={StaticResource BoolToString}}"
Value="True">
<Setter Property="Kind" Value="Check" />
<Setter Property="Foreground" Value="LimeGreen" />
</DataTrigger>
</Style.Triggers>
</Style>
</iconPacks:PackIconUnicons.Style>
</iconPacks:PackIconUnicons>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn >
<DataGridTextColumn Binding="{Binding ConnectionName}" Width="*" IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Expander>
<Expander ExpandDirection="Up" VerticalAlignment="Bottom" Visibility="{Binding ElementName=ItemBox, Path=Visibility}" Grid.Column="0" Grid.Row="3" Grid.RowSpan="1" Header="Info" Margin="0">
<StackPanel Orientation="Vertical">
<TextBox x:Name="StatusBox" mah:TextBoxHelper.Watermark="State" Text="{Binding GameState, Converter={StaticResource EnumToStringConverter}}"
VerticalAlignment="Center" IsManipulationEnabled="False" Focusable="False"
IsHitTestVisible="True" AllowDrop="False" IsReadOnly="True" ToolTip="Current status"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
<TextBox x:Name="GameCodeBox" Text="{Binding GameCode}"
mah:TextBoxHelper.Watermark="Game code"
VerticalAlignment="Center"
IsHitTestVisible="True"
Focusable="False"
IsManipulationEnabled="False"
AllowDrop="False"
ToolTip="Game code"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
mah:TextBoxHelper.ButtonContent="{iconPacks:Unicons Kind=Copy}"
Style="{DynamicResource MahApps.Styles.TextBox.Button}"
mah:TextBoxHelper.ButtonCommand="{Binding TextBoxButtonCopyCmd, Mode=OneWay}"
dialogs:TextBoxHelper.WatermarkAlignment="Right" VerticalContentAlignment="Stretch"
dialogs:TextBoxHelper.AutoWatermark="True" />
<TextBox x:Name="MapBox" mah:TextBoxHelper.Watermark="Map" Text="{Binding GameMap, Converter={StaticResource EnumToStringConverter}}"
VerticalAlignment="Center" IsManipulationEnabled="False" Focusable="False"
IsHitTestVisible="True" AllowDrop="False" IsReadOnly="True" ToolTip="Current map"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
</StackPanel>
</Expander>
</Grid>
</mah:MetroWindow>