Set WindowState of main window to Minimized when closing

This commit is contained in:
Stone_Red
2025-02-25 23:04:44 +01:00
parent af9aa60bd9
commit 70d08aa4c3
2 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -38,7 +38,7 @@
<DockPanel Margin="0,0,2.5,0"> <DockPanel Margin="0,0,2.5,0">
<Grid DockPanel.Dock="Top"> <Grid DockPanel.Dock="Top">
<Rectangle Grid.Row="1" Fill="#FFECECEC" Height="24" /> <Rectangle Grid.Row="1" Fill="#FFECECEC" Height="24" />
<CheckBox x:Name="EditCheckBox" VerticalAlignment="Center" Grid.Row="1" Content="{DynamicResource edit}" Click="EditCheckBox_Click" Foreground="Black" BorderBrush="#FF323232" Style="{StaticResource MaterialDesignDarkCheckBox}" IsChecked="True" /> <CheckBox x:Name="editCheckBox" VerticalAlignment="Center" Grid.Row="1" Content="{DynamicResource edit}" Click="EditCheckBox_Click" Foreground="Black" BorderBrush="#FF323232" Style="{StaticResource MaterialDesignDarkCheckBox}" IsChecked="True" />
</Grid> </Grid>
<ScrollViewer Background="#FFBBBBBB" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"> <ScrollViewer Background="#FFBBBBBB" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<ItemsControl ItemsSource="{Binding Settings.CurrentLayout.Plugins}"> <ItemsControl ItemsSource="{Binding Settings.CurrentLayout.Plugins}">
+6 -5
View File
@@ -59,7 +59,7 @@ namespace DesktopMagic
Items = Items =
{ {
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["open"], null, (s, e) => RestoreWindow()), new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["open"], null, (s, e) => RestoreWindow()),
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary ["toggleEditMode"], null, (s, e) => { EditCheckBox.IsChecked = !EditCheckBox.IsChecked; EditCheckBox_Click(null, null); }), new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["toggleEditMode"], null, (s, e) => { editCheckBox.IsChecked = !editCheckBox.IsChecked; EditCheckBox_Click(null, null); }),
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["pluginManager"], null, (s, e) => PluginManagerButton_Click(null!, null!)), new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["pluginManager"], null, (s, e) => PluginManagerButton_Click(null!, null!)),
new System.Windows.Forms.ToolStripMenuItem("GitHub", null, (s, e) => GitHubButton_Click(null!, null!)), new System.Windows.Forms.ToolStripMenuItem("GitHub", null, (s, e) => GitHubButton_Click(null!, null!)),
new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["quit"], null, (s, e) => Quit()), new System.Windows.Forms.ToolStripMenuItem((string)App.LanguageDictionary["quit"], null, (s, e) => Quit()),
@@ -174,7 +174,7 @@ namespace DesktopMagic
{ {
foreach (PluginWindow window in Windows) foreach (PluginWindow window in Windows)
{ {
window.SetEditMode(EditCheckBox.IsChecked == true); window.SetEditMode(editCheckBox.IsChecked == true);
} }
SaveSettings(); SaveSettings();
@@ -264,7 +264,7 @@ namespace DesktopMagic
window.ShowInTaskbar = false; window.ShowInTaskbar = false;
window.Show(); window.Show();
window.SetEditMode(EditCheckBox.IsChecked == true); window.SetEditMode(editCheckBox.IsChecked == true);
window.ContentRendered += DisplayWindow_ContentRendered; window.ContentRendered += DisplayWindow_ContentRendered;
window.Closing += DisplayWindow_Closing; window.Closing += DisplayWindow_Closing;
Windows.Add(window); Windows.Add(window);
@@ -284,9 +284,10 @@ namespace DesktopMagic
{ {
e.Cancel = true; e.Cancel = true;
EditCheckBox.IsChecked = false; editCheckBox.IsChecked = false;
EditCheckBox_Click(null, null); EditCheckBox_Click(null, null);
ShowInTaskbar = false; ShowInTaskbar = false;
WindowState = WindowState.Minimized;
Visibility = Visibility.Collapsed; Visibility = Visibility.Collapsed;
foreach (Window item in Windows) foreach (Window item in Windows)
@@ -588,7 +589,7 @@ namespace DesktopMagic
window.Close(); window.Close();
} }
EditCheckBox.IsChecked = false; editCheckBox.IsChecked = false;
EditCheckBox_Click(null, null); EditCheckBox_Click(null, null);
blockWindowsClosing = true; blockWindowsClosing = true;
Windows.Clear(); Windows.Clear();