From ec1e7200b40b8a5ae84fe62b913e4475849c903a Mon Sep 17 00:00:00 2001 From: rmbgame Date: Sun, 7 Mar 2021 17:08:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=AE=BE=E7=BD=AE=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../App.axaml.cs | 34 ++++++--- ...amTools.Client.Desktop.Avalonia.App.csproj | 14 ++-- .../UI/Controls/ToastMessage.axaml | 23 ++++-- .../Application/UI/MainView.axaml | 4 +- .../UI/Pages/Settings/Settings_UI.axaml | 4 +- .../Application/UI/Pages/SettingsPage.axaml | 4 +- .../UI/Pages/SteamAccountPage.axaml | 2 +- .../UI/Windows/MessageWindow.axaml | 3 +- ....SteamTools.Client.Desktop.Avalonia.csproj | 2 +- .../Models/Enum/AppTheme.cs | 13 ++++ .../Models/Settings/UISettings.cs | 28 ++++++-- .../Services/IDesktopAppService.cs | 7 +- .../Services/Static/ToastService.cs | 72 +++++++++++++++++++ .../UI/ViewModels/Base/WindowViewModel.cs | 8 ++- .../Controls/ToastMessageViewModel.cs | 42 +++++++++++ .../Pages/Settings/SettingsPageViewModel.cs | 2 - 16 files changed, 224 insertions(+), 38 deletions(-) create mode 100644 System.Application.SteamTools.Client.Desktop/Models/Enum/AppTheme.cs create mode 100644 System.Application.SteamTools.Client.Desktop/Services/Static/ToastService.cs create mode 100644 System.Application.SteamTools.Client.Desktop/UI/ViewModels/Controls/ToastMessageViewModel.cs diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs b/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs index 1818cbf64..f1a0b9807 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs +++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs @@ -21,6 +21,7 @@ using System.Windows.Input; using System.Linq; using System.Application.Models.Settings; using System.Application.UI.Resx; +using System.Application.Models; #if WINDOWS using System.Windows.Shell; using WpfApplication = System.Windows.Application; @@ -40,9 +41,8 @@ namespace System.Application.UI [Obsolete("use AppHelper.ProgramName", true)] public string ProgramName => AppHelper.ProgramName; - bool mTheme; - - public bool Theme + AppTheme mTheme; + public AppTheme Theme { get { @@ -51,10 +51,25 @@ namespace System.Application.UI set { if (value == mTheme) return; - - var mode = value ? FluentThemeMode.Light : FluentThemeMode.Dark; - var uri_0 = new Uri($"avares://Avalonia.Themes.Fluent/Fluent{(value ? "Light" : "Dark")}.xaml"); - var uri_1 = new Uri($"avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Styles/Theme{(value ? "Light" : "Dark")}.xaml"); + var the = "Dark"; + var mode = FluentThemeMode.Dark; + switch (value) + { + case AppTheme.Light: + the = "Light"; + mode = mode = FluentThemeMode.Light; + break; + case AppTheme.Dark: + the = "Dark"; + mode = mode = FluentThemeMode.Dark; + break; + default: + the = "Dark"; + mode = mode = FluentThemeMode.Dark; + break; + } + var uri_0 = new Uri($"avares://Avalonia.Themes.Fluent/Fluent{the}.xaml"); + var uri_1 = new Uri($"avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Styles/Theme{the}.xaml"); Styles[0] = new FluentTheme(uri_0) { @@ -86,6 +101,7 @@ namespace System.Application.UI SettingsHost.Load(); compositeDisposable.Add(SettingsHost.Save); + UISettings.Theme.Subscribe(x => Theme = (AppTheme)x); UISettings.Language.Subscribe(x => R.ChangeLanguage(x)); #endregion @@ -138,12 +154,12 @@ namespace System.Application.UI mNotifyIconMenus.Add("Light", ReactiveCommand.Create(() => { - Theme = true; + Theme = AppTheme.Light; })); mNotifyIconMenus.Add("Dark", ReactiveCommand.Create(() => { - Theme = false; + Theme = AppTheme.Dark; })); mNotifyIconMenus.Add("Show", diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj b/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj index 78d113417..d676264b2 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj +++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj @@ -35,21 +35,21 @@ - - - + + + - + - + - +