Skip to content

Commit 3261036

Browse files
authored
Merge pull request #10 from Float3/dev
forgot to add CommandBindings
2 parents b9e9d46 + b412558 commit 3261036

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

VRCLauncher/View/MainWindow.xaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<Window x:Class="VRCLauncher.View.MainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6-
mc:Ignorable="d" SizeToContent="WidthAndHeight"
74
Title="VRCLauncher" Height="550" Width="900"
8-
Style="{DynamicResource WindowStyle}">
5+
Style="{StaticResource WindowStyle}">
96
<Window.Resources>
107
<Style TargetType="{x:Type CheckBox}">
118
<Setter Property="Width" Value="15" />

VRCLauncher/View/MainWindow.xaml.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public MainWindow()
1919
InitializeComponent();
2020
DataContext = _viewModel;
2121

22+
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, OnCloseWindow));
23+
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, OnMaximizeWindow, OnCanResizeWindow));
24+
CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, OnMinimizeWindow, OnCanMinimizeWindow));
25+
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, OnRestoreWindow, OnCanResizeWindow));
26+
2227
if (Environment.GetCommandLineArgs().Length > 0)
2328
{
2429
foreach (string arg in Environment.GetCommandLineArgs())
@@ -54,4 +59,34 @@ private void ValidateFloatTextBox(object sender, TextCompositionEventArgs e)
5459
e.Handled = !float.TryParse(text, out _) || text.Contains(",");
5560
}
5661
}
62+
63+
private void OnCanResizeWindow(object sender, CanExecuteRoutedEventArgs e)
64+
{
65+
e.CanExecute = ResizeMode == ResizeMode.CanResize || ResizeMode == ResizeMode.CanResizeWithGrip;
66+
}
67+
68+
private void OnCanMinimizeWindow(object sender, CanExecuteRoutedEventArgs e)
69+
{
70+
e.CanExecute = ResizeMode != ResizeMode.NoResize;
71+
}
72+
73+
private void OnCloseWindow(object target, ExecutedRoutedEventArgs e)
74+
{
75+
SystemCommands.CloseWindow(this);
76+
}
77+
78+
private void OnMaximizeWindow(object target, ExecutedRoutedEventArgs e)
79+
{
80+
SystemCommands.MaximizeWindow(this);
81+
}
82+
83+
private void OnMinimizeWindow(object target, ExecutedRoutedEventArgs e)
84+
{
85+
SystemCommands.MinimizeWindow(this);
86+
}
87+
88+
private void OnRestoreWindow(object target, ExecutedRoutedEventArgs e)
89+
{
90+
SystemCommands.RestoreWindow(this);
91+
}
5792
}

0 commit comments

Comments
 (0)