给设置界面添加是否最小化到通知栏选项
This commit is contained in:
@@ -15,6 +15,7 @@ namespace PMSWPF.Config
|
|||||||
public bool EnableS7Service { get; set; } = true;
|
public bool EnableS7Service { get; set; } = true;
|
||||||
public bool EnableMqttService { get; set; } = true;
|
public bool EnableMqttService { get; set; } = true;
|
||||||
public bool EnableOpcUaService { get; set; } = true;
|
public bool EnableOpcUaService { get; set; } = true;
|
||||||
|
public bool MinimizeToTrayOnClose { get; set; } = true;
|
||||||
|
|
||||||
private static readonly string SettingsFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "connectionSettings.json");
|
private static readonly string SettingsFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "connectionSettings.json");
|
||||||
|
|
||||||
|
|||||||
@@ -179,6 +179,20 @@ public partial class SettingViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool MinimizeToTrayOnClose
|
||||||
|
{
|
||||||
|
get => _connectionSettings.MinimizeToTrayOnClose;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_connectionSettings.MinimizeToTrayOnClose != value)
|
||||||
|
{
|
||||||
|
_connectionSettings.MinimizeToTrayOnClose = value;
|
||||||
|
OnPropertyChanged(nameof(MinimizeToTrayOnClose));
|
||||||
|
_connectionSettings.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task TestConnection()
|
private async Task TestConnection()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,9 +33,17 @@ public partial class MainView : Window
|
|||||||
|
|
||||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
// Hide the window instead of closing it
|
var settings = Config.ConnectionSettings.Load();
|
||||||
e.Cancel = true;
|
if (settings.MinimizeToTrayOnClose)
|
||||||
Hide();
|
{
|
||||||
|
// Hide the window instead of closing it
|
||||||
|
e.Cancel = true;
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowApplication()
|
public void ShowApplication()
|
||||||
|
|||||||
@@ -9,6 +9,19 @@
|
|||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800">
|
d:DesignWidth="800">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
<ui:SettingsExpander Header="通用设置"
|
||||||
|
Description="通用程序行为设置">
|
||||||
|
<ui:SettingsExpander.HeaderIcon>
|
||||||
|
<ui:FontIcon Glyph="" />
|
||||||
|
</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"
|
<ui:SettingsExpander x:Name="dbSettingCard"
|
||||||
Header="设置数据库"
|
Header="设置数据库"
|
||||||
@@ -132,6 +145,8 @@
|
|||||||
</ui:SettingsExpander.Items>
|
</ui:SettingsExpander.Items>
|
||||||
</ui:SettingsExpander>
|
</ui:SettingsExpander>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ui:SettingsExpander Header="SettingsExpander"
|
<ui:SettingsExpander Header="SettingsExpander"
|
||||||
Description="The SettingsExpander has the same properties as a SettingsCard">
|
Description="The SettingsExpander has the same properties as a SettingsCard">
|
||||||
<ui:SettingsExpander.HeaderIcon>
|
<ui:SettingsExpander.HeaderIcon>
|
||||||
|
|||||||
Reference in New Issue
Block a user