添加主题切换,未完成
This commit is contained in:
@@ -49,6 +49,7 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
||||||
|
ThemeHelper.InitializeTheme();
|
||||||
await Host.StartAsync();
|
await Host.StartAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace PMSWPF.Config
|
|||||||
public string UserId { get; set; } = "root";
|
public string UserId { get; set; } = "root";
|
||||||
public string Password { get; set; } = "Pgw15221236646";
|
public string Password { get; set; } = "Pgw15221236646";
|
||||||
public string Database { get; set; } = "pmswpf";
|
public string Database { get; set; } = "pmswpf";
|
||||||
|
public string Theme { get; set; } = "跟随系统";
|
||||||
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;
|
||||||
|
|||||||
@@ -25,6 +25,24 @@ public partial class SettingViewModel : ViewModelBase
|
|||||||
_s7BackgroundService = s7BackgroundService;
|
_s7BackgroundService = s7BackgroundService;
|
||||||
_mqttBackgroundService = mqttBackgroundService;
|
_mqttBackgroundService = mqttBackgroundService;
|
||||||
_opcUaBackgroundService = opcUaBackgroundService;
|
_opcUaBackgroundService = opcUaBackgroundService;
|
||||||
|
Themes = new List<string> { "浅色", "深色", "跟随系统" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> Themes { get; }
|
||||||
|
|
||||||
|
public string SelectedTheme
|
||||||
|
{
|
||||||
|
get => _connectionSettings.Theme;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_connectionSettings.Theme != value)
|
||||||
|
{
|
||||||
|
_connectionSettings.Theme = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
_connectionSettings.Save();
|
||||||
|
ThemeHelper.ApplyTheme(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> AvailableDbTypes { get; set; }
|
public List<string> AvailableDbTypes { get; set; }
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
CloseButtonText="取消"
|
CloseButtonText="取消"
|
||||||
DefaultButton="Primary"
|
DefaultButton="Primary"
|
||||||
PrimaryButtonText="{Binding PrimaryButContent}"
|
PrimaryButtonText="{Binding PrimaryButContent}"
|
||||||
Background="#fff"
|
|
||||||
d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}"
|
d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<ui:ContentDialog.Resources>
|
<ui:ContentDialog.Resources>
|
||||||
|
|||||||
@@ -15,6 +15,12 @@
|
|||||||
<ui:FontIcon Glyph="" />
|
<ui:FontIcon Glyph="" />
|
||||||
</ui:SettingsExpander.HeaderIcon>
|
</ui:SettingsExpander.HeaderIcon>
|
||||||
<ui:SettingsExpander.Items>
|
<ui:SettingsExpander.Items>
|
||||||
|
<ui:SettingsCard Header="主题切换"
|
||||||
|
Description="切换应用程序的主题">
|
||||||
|
<ComboBox Width="120"
|
||||||
|
ItemsSource="{Binding Themes}"
|
||||||
|
SelectedItem="{Binding SelectedTheme, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
|
</ui:SettingsCard>
|
||||||
<ui:SettingsCard Header="点击关闭按钮时最小化到通知栏"
|
<ui:SettingsCard Header="点击关闭按钮时最小化到通知栏"
|
||||||
Description="开启后,点击主窗口的关闭按钮会将程序最小化到系统通知栏,而不是直接退出。"
|
Description="开启后,点击主窗口的关闭按钮会将程序最小化到系统通知栏,而不是直接退出。"
|
||||||
IsClickEnabled="True">
|
IsClickEnabled="True">
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<Style TargetType="TextBlock"
|
<Style TargetType="TextBlock"
|
||||||
x:Key="VarTableLabelStyle">
|
x:Key="VarTableLabelStyle">
|
||||||
<Setter Property="Foreground"
|
<Setter Property="Foreground"
|
||||||
Value="#555" />
|
Value="{DynamicResource SecondaryTextBrush}" />
|
||||||
<Setter Property="FontSize"
|
<Setter Property="FontSize"
|
||||||
Value="16" />
|
Value="16" />
|
||||||
<Setter Property="VerticalAlignment"
|
<Setter Property="VerticalAlignment"
|
||||||
@@ -165,7 +165,8 @@
|
|||||||
CanUserSortColumns="True"
|
CanUserSortColumns="True"
|
||||||
SelectionMode="Extended"
|
SelectionMode="Extended"
|
||||||
SelectedItem="{Binding SelectedVariableData}"
|
SelectedItem="{Binding SelectedVariableData}"
|
||||||
ItemsSource="{Binding VariableDataView}">
|
ItemsSource="{Binding VariableDataView}"
|
||||||
|
Style="{StaticResource DataGridBaseStyle}">
|
||||||
<DataGrid.ContextMenu>
|
<DataGrid.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="添加变量"
|
<MenuItem Header="添加变量"
|
||||||
@@ -230,9 +231,9 @@
|
|||||||
<DataTrigger Binding="{Binding IsModified}"
|
<DataTrigger Binding="{Binding IsModified}"
|
||||||
Value="True">
|
Value="True">
|
||||||
<Setter Property="Background"
|
<Setter Property="Background"
|
||||||
Value="Pink" />
|
Value="{DynamicResource SecondaryRegionBrush}" />
|
||||||
<Setter Property="Foreground"
|
<Setter Property="Foreground"
|
||||||
Value="#000" />
|
Value="{DynamicResource PrimaryTextBrush}" />
|
||||||
<Setter Property="FontWeight"
|
<Setter Property="FontWeight"
|
||||||
Value="Bold" />
|
Value="Bold" />
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
@@ -240,14 +241,14 @@
|
|||||||
<Trigger Property="IsMouseOver"
|
<Trigger Property="IsMouseOver"
|
||||||
Value="True">
|
Value="True">
|
||||||
<Setter Property="Background"
|
<Setter Property="Background"
|
||||||
Value="LightBlue" />
|
Value="{DynamicResource HoverBrush}" />
|
||||||
</Trigger>
|
</Trigger>
|
||||||
<Trigger Property="IsSelected"
|
<Trigger Property="IsSelected"
|
||||||
Value="True">
|
Value="True">
|
||||||
<Setter Property="Background"
|
<Setter Property="Background"
|
||||||
Value="DodgerBlue" />
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
<Setter Property="Foreground"
|
<Setter Property="Foreground"
|
||||||
Value="White" />
|
Value="{DynamicResource TextIconBrush}" />
|
||||||
</Trigger>
|
</Trigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
|
|||||||
Reference in New Issue
Block a user