1.1.3 -> 1.1.4 第11次更新

This commit is contained in:
Space Time 2024-11-24 21:41:19 +08:00
parent 5bd9ef3e58
commit 94ede5b64b
3 changed files with 27 additions and 20 deletions

View File

@ -1,18 +0,0 @@
using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignThemes.Wpf;
namespace Sheas_Cealer.Preses;
internal partial class AppPres : ObservableObject
{
[ObservableProperty]
private bool? isLightTheme = null;
partial void OnIsLightThemeChanged(bool? value)
{
PaletteHelper paletteHelper = new();
Theme newTheme = paletteHelper.GetTheme();
newTheme.SetBaseTheme(value.HasValue ? value.GetValueOrDefault() ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
paletteHelper.SetTheme(newTheme);
}
}

26
Preses/GlobalPres.cs Normal file
View File

@ -0,0 +1,26 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using MaterialDesignThemes.Wpf;
namespace Sheas_Cealer.Preses;
internal partial class GlobalPres : ObservableRecipient, IRecipient<PropertyChangedMessage<object>>
{
internal GlobalPres() => IsActive = true;
[ObservableProperty, NotifyPropertyChangedRecipients]
private bool? isLightTheme = null;
partial void OnIsLightThemeChanged(bool? value)
{
PaletteHelper paletteHelper = new();
Theme newTheme = paletteHelper.GetTheme();
newTheme.SetBaseTheme(value.HasValue ? value.GetValueOrDefault() ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
paletteHelper.SetTheme(newTheme);
}
protected override void Broadcast<T>(T oldValue, T newValue, string? propertyName) => Messenger.Send(new PropertyChangedMessage<object>(this, propertyName, oldValue!, newValue!));
public void Receive(PropertyChangedMessage<object> message) => GetType().GetProperty(message.PropertyName!)!.SetValue(this, message.NewValue);
}

View File

@ -2,7 +2,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignThemes.Wpf;
using Microsoft.Win32; using Microsoft.Win32;
using Sheas_Cealer.Consts; using Sheas_Cealer.Consts;
using Sheas_Cealer.Props; using Sheas_Cealer.Props;
@ -10,7 +9,7 @@ using File = System.IO.File;
namespace Sheas_Cealer.Preses; namespace Sheas_Cealer.Preses;
internal partial class MainPres : AppPres internal partial class MainPres : GlobalPres
{ {
internal MainPres(string[] args) internal MainPres(string[] args)
{ {