给设置界面添加是否最小化到通知栏选项

This commit is contained in:
2025-07-09 20:48:14 +08:00
parent cba1c1abf4
commit 5915a6c87b
4 changed files with 41 additions and 3 deletions

View File

@@ -33,9 +33,17 @@ public partial class MainView : Window
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// Hide the window instead of closing it
e.Cancel = true;
Hide();
var settings = Config.ConnectionSettings.Load();
if (settings.MinimizeToTrayOnClose)
{
// Hide the window instead of closing it
e.Cancel = true;
Hide();
}
else
{
Application.Current.Shutdown();
}
}
public void ShowApplication()

View File

@@ -9,6 +9,19 @@
d:DesignHeight="450"
d:DesignWidth="800">
<StackPanel>
<ui:SettingsExpander Header="通用设置"
Description="通用程序行为设置">
<ui:SettingsExpander.HeaderIcon>
<ui:FontIcon Glyph="&#xE713;" />
</ui:SettingsExpander.HeaderIcon>
<ui:SettingsExpander.Items>
<ui:SettingsCard Header="点击关闭按钮时最小化到通知栏"
Description="开启后,点击主窗口的关闭按钮会将程序最小化到系统通知栏,而不是直接退出。"
IsClickEnabled="True">
<ui:ToggleSwitch IsOn="{Binding MinimizeToTrayOnClose, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</ui:SettingsCard>
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<ui:SettingsExpander x:Name="dbSettingCard"
Header="设置数据库"
@@ -132,6 +145,8 @@
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<ui:SettingsExpander Header="SettingsExpander"
Description="The SettingsExpander has the same properties as a SettingsCard">
<ui:SettingsExpander.HeaderIcon>