Skip to content

Commit

Permalink
Add option to kill the app on window close
Browse files Browse the repository at this point in the history
  • Loading branch information
reagcz committed Nov 1, 2024
1 parent 3b41e77 commit 4867fd7
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 1 deletion.
3 changes: 3 additions & 0 deletions IdeapadToolkit/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<setting name="Language" serializeAs="String">
<value />
</setting>
<setting name="KeepInTray" serializeAs="String">
<value>True</value>
</setting>
</IdeapadToolkit.Settings>
</userSettings>
</configuration>
9 changes: 9 additions & 0 deletions IdeapadToolkit/Localization/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions IdeapadToolkit/Localization/Strings.cs-CZ.resx
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<data name="RUN_ON_STARTUP" xml:space="preserve">
<value>Spustit při startu</value>
</data>
<data name="KEEP_IN_TRAY" xml:space="preserve">
<value>Ponechat spuštěné na pozadí</value>
</data>
</root>
5 changes: 4 additions & 1 deletion IdeapadToolkit/Localization/Strings.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<data name="RUN_ON_STARTUP" xml:space="preserve">
<value>Lancer au démarrage</value>
</data>
</root>
<data name="KEEP_IN_TRAY" xml:space="preserve">
<value>Laisser en cours d'exécution en arrière-plan</value>
</data>
</root>
3 changes: 3 additions & 0 deletions IdeapadToolkit/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<data name="RUN_ON_STARTUP" xml:space="preserve">
<value>Run On Startup</value>
</data>
<data name="KEEP_IN_TRAY" xml:space="preserve">
<value>Keep running in the background</value>
</data>
</root>
3 changes: 3 additions & 0 deletions IdeapadToolkit/Localization/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<data name="RUN_ON_STARTUP" xml:space="preserve">
<value>开机时自动启动</value>
</data>
<data name="KEEP_IN_TRAY" xml:space="preserve">
<value>在后台运行</value>
</data>
</root>
1 change: 1 addition & 0 deletions IdeapadToolkit/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ui:TitleBar.Style="{DynamicResource TitleBarStyle}"
ui:WindowHelper.UseModernWindowStyle="True"
Background="#0b0b0b"
Closing="_mainwindow_Closing"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<FrameworkElement.Resources>
Expand Down
8 changes: 8 additions & 0 deletions IdeapadToolkit/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,13 @@ private void NavigationView_ItemInvoked(ModernWpf.Controls.NavigationView sender
}
}
}

private void _mainwindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!Settings.Default.KeepInTray)
{
Application.Current.Shutdown();
}
}
}
}
12 changes: 12 additions & 0 deletions IdeapadToolkit/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions IdeapadToolkit/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<Setting Name="Language" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="KeepInTray" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
10 changes: 10 additions & 0 deletions IdeapadToolkit/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,15 @@ public Locale SelectedLocale
Settings.Default.Save();
}
}

public bool KeepInTray
{
get => Settings.Default.KeepInTray;
set
{
Settings.Default.KeepInTray = value;
Settings.Default.Save();
}
}
}
}
1 change: 1 addition & 0 deletions IdeapadToolkit/Views/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Grid Margin="16">
<ui:SimpleStackPanel>
<ui:ToggleSwitch ui:ControlHelper.Header="{x:Static loc:Strings.RUN_ON_STARTUP}" IsOn="{Binding IsRunOnStartupEnabled}" />
<ui:ToggleSwitch ui:ControlHelper.Header="{x:Static loc:Strings.KEEP_IN_TRAY}" IsOn="{Binding KeepInTray}" />
<ComboBox
ui:ControlHelper.Header="{x:Static loc:Strings.LANGUAGE}"
ItemsSource="{Binding SupportedLanguages}"
Expand Down

0 comments on commit 4867fd7

Please sign in to comment.