-
Notifications
You must be signed in to change notification settings - Fork 91
/
MainWindow.xaml
337 lines (320 loc) · 22.7 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
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<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:li="http://github.com/zeluisping/loadingIndicators/xaml/controls"
xmlns:converters="clr-namespace:AUCapture_WPF.Converters"
xmlns:controls="clr-namespace:AUCapture_WPF.Controls"
xmlns:wpf="clr-namespace:LoadingIndicators.WPF;assembly=LoadingIndicators.WPF"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
Style="{DynamicResource MahApps.Styles.MetroWindow.Clean}"
ResizeMode="CanResize"
Title="AUCapture" TitleAlignment="Center" Height="544" Width="366"
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:,,,/LoadingIndicators.WPF;component/styles/LoadingThreeDots.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" />
<converters:BoolInverter x:Key="BoolInverter" />
<converters:GameStateToVisability x:Key="GameStateToVisability"/>
<BitmapImage UriSource="Resources/Misc/status-connected.png" x:Key="status-connected"/>
<BitmapImage UriSource="Resources/Misc/status-disconnected.png" x:Key="status-disconnected"/>
</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>
<Button Click="ManualConnect_Click" x:Name="ManualConnectButton"
ToolTip="Open the manual connection window">
<Button.ContentTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconModern Width="22" Height="22" VerticalAlignment="Center" Kind="Connect" />
</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" />
<mah:ToggleSwitch x:Name="AlwaysOnTopSwitch" Header="Always on top" IsOn="{Binding Settings.alwaysOnTop, Mode=TwoWay}" Toggled="AlwaysOnTopSwitch_OnToggled"></mah:ToggleSwitch>
</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}" />
<Button Margin="0,10,0,0" Content="Reset Config"
Style="{StaticResource MahApps.Styles.Button.Square.Accent}"
Background="#FFDC3545" Click="ResetConfigButton_OnClick" />
</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:Flyout x:Name="ManualConnectionFlyout" Header="Manual Connection" Position="Left"
Width="{Binding ActualWidth,ElementName=window, Converter={dialogs:MathDivideConverter}, ConverterParameter=2}"
Theme="Adapt"
IsAutoCloseEnabled="False" AnimateOpacity="True" ExternalCloseButton="Left">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Host: " VerticalAlignment="Center" Margin="4 0 3 0" />
<TextBox x:Name="Host" VerticalAlignment="Center" MinWidth="150"
Text="{Binding Settings.host, Mode=TwoWay}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Code: " VerticalAlignment="Center" Margin="4 0 0 0" />
<TextBox x:Name="Code" VerticalAlignment="Center" MinWidth="150"
Text="{Binding Settings.connectCode, Mode=TwoWay}" />
</StackPanel>
<Button Content="Submit" x:Name="SubmitConnectButton" Margin="20"
Click="SubmitConnectButton_OnClick" />
</StackPanel>
</ScrollViewer>
</Grid>
</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" />
</Grid.RowDefinitions>
<StackPanel VerticalAlignment="Center" Grid.RowSpan="4" Grid.ColumnSpan="3" Orientation="Vertical" IsEnabled="{Binding Connected, Converter={StaticResource BoolInverter}}">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
Visibility="{Binding Connected, Converter={StaticResource BoolToVisibilityConverterInverted}}">
<Run FontSize="32" FontFamily="{StaticResource AUFont}">Waiting for among us</Run><LineBreak />
</TextBlock>
<mah:ProgressRing IsActive="{Binding Connected, Converter={StaticResource BoolInverter}}" IsEnabled="{Binding Connected, Converter={StaticResource BoolInverter}}" Visibility="{Binding Connected, Converter={StaticResource BoolToVisibilityConverterInverted}}" />
<Button Padding="10" Margin="0 10 0 0" HorizontalAlignment="Center"
Visibility="{Binding Connected, Converter={StaticResource BoolToVisibilityConverterInverted}}"
Command="{Binding OpenAmongUsCMD, Mode=OneWay}">
<Button.Content>
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconUnicons Kind="Rocket" />
<TextBlock Margin="5 0 0 0"> Launch Among Us</TextBlock>
</StackPanel>
</Button.Content>
</Button>
</StackPanel>
<GroupBox Name="ItemBox"
Visibility="{Binding Connected, Converter={StaticResource BooleanToVisibilityConverter}}"
Grid.ColumnSpan="3" Grid.RowSpan="3" Header="Players"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ItemsControl Visibility="{Binding GameState, Converter={StaticResource GameStateToVisability}}" 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}" PlayerPetID="{Binding PetID}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid IsItemsHost="True" Rows="3" hc:PanelElement.FluidMoveBehavior="{StaticResource BehaviorXY400}" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</GroupBox>
<StackPanel Orientation="Vertical" Grid.Row="3" Grid.ColumnSpan="3"
Visibility="{Binding ElementName=ItemBox, Path=Visibility}">
<ItemsControl Grid.Row="3" Grid.ColumnSpan="3" ItemsSource="{Binding ConnectionStatuses}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{DynamicResource MahApps.Brushes.Accent}" BorderThickness="1">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Image VerticalAlignment="Center" Stretch="None" HorizontalAlignment="Center">
<Image.Style>
<Style TargetType="Image">
<Setter Property="Source" Value="{StaticResource status-disconnected}" />
<Style.Triggers>
<DataTrigger
Binding="{Binding Path=Connected, Converter={StaticResource BoolToString}}"
Value="True">
<Setter Property="Source" Value="{StaticResource status-connected}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<Label Content="{Binding ConnectionName}" HorizontalContentAlignment="Right" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid IsItemsHost="True" Rows="1" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Grid Visibility="{Binding ElementName=ItemBox, Path=Visibility}" Grid.Row="4" Grid.ColumnSpan="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" 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" BorderBrush="{DynamicResource MahApps.Brushes.Accent}"/>
<TextBox Grid.Column="1" 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" BorderBrush="{DynamicResource MahApps.Brushes.Accent}"/>
<TextBox Grid.Column="2" 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" BorderBrush="{DynamicResource MahApps.Brushes.Accent}"/>
</Grid>
</StackPanel>
</Grid>
</mah:MetroWindow>