diff --git a/AutoDarkModeApp/Helpers/EnumToStretchConverter.cs b/AutoDarkModeApp/Helpers/EnumToStretchConverter.cs new file mode 100644 index 000000000..fc6d0bda7 --- /dev/null +++ b/AutoDarkModeApp/Helpers/EnumToStretchConverter.cs @@ -0,0 +1,33 @@ +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Media; + +namespace AutoDarkModeApp.Helpers; + +public partial class EnumToStretchConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, string language) + { + var mode = (WallpaperFillingMode)value; + return mode switch + { + WallpaperFillingMode.Center => Stretch.Uniform, + WallpaperFillingMode.Stretch => Stretch.Fill, + WallpaperFillingMode.Fit => Stretch.Uniform, + WallpaperFillingMode.Fill => Stretch.UniformToFill, + _ => Stretch.None, + }; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException("Two-way binding is not supported for EnumToStretchConverter."); + } +} + +public enum WallpaperFillingMode +{ + Center, + Stretch, + Fit, + Fill, +} diff --git a/AutoDarkModeApp/Strings/en-us/Resources.resw b/AutoDarkModeApp/Strings/en-us/Resources.resw index 57cacb4d9..df7f6519b 100644 --- a/AutoDarkModeApp/Strings/en-us/Resources.resw +++ b/AutoDarkModeApp/Strings/en-us/Resources.resw @@ -127,7 +127,7 @@ Switch theme - Enable automatic theme switching + Automatically switch themes Settings @@ -231,9 +231,6 @@ Currently installed version: {0}, new version: {1} Welcome - - Change settings here to modify the automatic theme switch behavior. - Translator: Armin Osaj & Samuel Schiegg @@ -262,7 +259,7 @@ Currently installed version: {0}, new version: {1} Delete/Disable - Pick file + Browse photos Wallpaper for light theme @@ -277,7 +274,7 @@ Currently installed version: {0}, new version: {1} Please select two wallpapers - Please select an image + Select an image Configure Desktop Background @@ -341,8 +338,7 @@ Please ensure: - the service is running - the config.yaml file is correct -Would you like to create an issue on the Auto Dark Mode repository? - +Would you like to create an issue on the Auto Dark Mode repository? Text like "Click yes to..." is (and should be) obvious @@ -361,11 +357,8 @@ Would you like to create an issue on the Auto Dark Mode repository? Offset - - Set - - These options are disabled while using a Windows Theme. You can set them up individually in your Windows Theme. + These options are disabled when using a Windows Theme. You can set them up individually in your Windows Theme. Apps @@ -386,7 +379,7 @@ Would you like to create an issue on the Auto Dark Mode repository? Create your themes - Pick your themes + Select your themes Light theme @@ -401,7 +394,7 @@ Would you like to create an issue on the Auto Dark Mode repository? Go to Windows Theme settings - Navigate to 'Colors' and change the system color to 'Light' for the light theme. Select your favorite wallpaper, mouse cursor and accent color. + Go to 'Colors' and change the system color to 'Light' for the light theme. Select your favorite wallpaper, mouse pointers and accent color. Go to theme settings and save your theme. @@ -422,7 +415,7 @@ Would you like to create an issue on the Auto Dark Mode repository? Restart - Set custom time + Custom time From sunset to sunrise (location service) @@ -510,7 +503,7 @@ Sidenote: NEVER run Auto Dark Mode as administrator manually! Energy saver mitigation for theme switch - This only works if you haven't manually enabled battery saver! + This only works if you haven't manually enabled battery saver Switch modes @@ -551,10 +544,10 @@ Sidenote: NEVER run Auto Dark Mode as administrator manually! Configuration - Pick a theme + Select a theme - Pick a wallpaper + Personalize your background Disabled @@ -572,7 +565,7 @@ Sidenote: NEVER run Auto Dark Mode as administrator manually! Select a different Windows theme for dark and light mode respectively. Allows full theme customization, but requires you to set up .theme files. - Customize your desktop wallpaper for all monitors, individual monitors, set a background color or enable spotlight. + Customize your desktop for all monitors, individual monitors, set a background color or enable spotlight. Check for new versions of Auto Dark Mode in the background. When an update is available, you will be notified. @@ -645,7 +638,7 @@ Sidenote: NEVER run Auto Dark Mode as administrator manually! Hex code - Enable wallpaper switch + Switch desktop background Don't switch while playing games @@ -737,9 +730,6 @@ Sidenote: NEVER run Auto Dark Mode as administrator manually! Every day - - Click Set to save changes. - Use Taskbar Accent Color during @@ -820,7 +810,7 @@ Sidenote: NEVER run Auto Dark Mode as administrator manually! Do you really want to continue? - Hide Tray Icon + Hide tray icon &Open Config Directory @@ -863,7 +853,7 @@ Do you really want to continue? System idle checker - Hit confirm to request a theme switch immediately. + Confirm to request a theme switch immediately. Resume @@ -1022,13 +1012,13 @@ Do you really want to continue? Ignore background - Ignore cursor + Ignore pointers Ignore desktop icons - Ignore sound + Ignore sounds Ignore settings @@ -1106,7 +1096,7 @@ Do you really want to continue? Enable custom scripts - Choose your wallpaper + Choose a photo Image path @@ -1121,7 +1111,7 @@ Do you really want to continue? Accent color - Pick an accent color + Select an accent color Customize the Windows system color scheme to your liking. @@ -1149,6 +1139,7 @@ Do you really want to continue? Choose a fit for your desktop image + Must match Windows settings Disconnected @@ -1157,9 +1148,9 @@ Do you really want to continue? Always refresh DWM on theme switch - Attempts to reduce the occurrence of wrong UI colors in the explorer, taskbar and start menu. If you experience this often or are bothered by it, try enabling this setting. + Attempts to reduce wrong UI colors in the explorer, taskbar and start menu. If you experience this often or are bothered by it, try enabling this setting. -This may introduce slight to moderate lag on some systems during theme switch similar to how it happened in Windows 10. +This may introduce slight to moderate lag on some systems during theme switch, similar to how it happened in Windows 10. On rare occasions, Windows may emit a beeping sound when the mouse is moved during DWM refreshes. @@ -1169,25 +1160,25 @@ On rare occasions, Windows may emit a beeping sound when the mouse is moved duri Ok - Enable mouse cursor switch + Switch mouse pointers Open Windows pointer settings - Select dark cursor + Select dark pointers - Select light cursor + Select light pointers - Cursors + Mouse pointers - Configure different mouse cursors for dark and light modes. + Configure different mouse pointers for dark and light modes. - Pick mouse cursors + Select mouse pointers Let Auto Dark Mode manage my theme @@ -1205,7 +1196,7 @@ On rare occasions, Windows may emit a beeping sound when the mouse is moved duri Open updater log - Enable Accent color switch + Switch accent colors Switch touch keyboard and input @@ -1244,7 +1235,7 @@ On rare occasions, Windows may emit a beeping sound when the mouse is moved duri Try to fix the theme - Settings + Select Scripts @@ -1264,4 +1255,7 @@ On rare occasions, Windows may emit a beeping sound when the mouse is moved duri UnDelay + + Set + \ No newline at end of file diff --git a/AutoDarkModeApp/Strings/fr/Resources.resw b/AutoDarkModeApp/Strings/fr/Resources.resw index 622dea817..76c1d7100 100644 --- a/AutoDarkModeApp/Strings/fr/Resources.resw +++ b/AutoDarkModeApp/Strings/fr/Resources.resw @@ -233,9 +233,6 @@ Version installée : {0}, nouvelle version : {1} Bienvenue - - Activez l'option pour activer le changement de thème automatique. - Traducteurs : Nathan Bonnemains & Damien Trouillet & Maxence CHAIX @@ -367,9 +364,6 @@ Mais elle réduit également l'autonomie de la batterie, alors ne l'activez que Décalage - - Définir - Ces options sont désactivées lorsque vous utilisez un thème Windows. Vous pouvez les configurer individuellement dans votre thème Windows. @@ -742,9 +736,6 @@ Remarque : N'exécutez JAMAIS Auto Dark Mode en tant qu'administrateur manuellem Chaque jour - - Cliquez sur Définir pour enregistrer les modifications. - Utiliser la couleur d'accentuation de la barre des tâches diff --git a/AutoDarkModeApp/Strings/ja/Resources.resw b/AutoDarkModeApp/Strings/ja/Resources.resw index 44790e6fb..66532d111 100644 --- a/AutoDarkModeApp/Strings/ja/Resources.resw +++ b/AutoDarkModeApp/Strings/ja/Resources.resw @@ -233,9 +233,6 @@ こんにちは - - ここで設定を変更すると、テーマ自動切り替えの動作を変更します。 - 翻訳者: maboroshin, zhixuan2333 @@ -367,9 +364,6 @@ Auto Dark Mode のリポジトリに issue (問題) を投稿しますか? 補正 - - 適用 - Windows テーマの使用中は、これらのオプションは無効です。 これらの設定は、Windowsテーマから個別に設定できます。 @@ -742,9 +736,6 @@ Auto Dark Mode のリポジトリに issue (問題) を投稿しますか? 毎日 - - 変更を保存するには「適用」をクリックします。 - 使用するタスクバーのアクセントカラー diff --git a/AutoDarkModeApp/Strings/zh-hans/Resources.resw b/AutoDarkModeApp/Strings/zh-hans/Resources.resw index 23a2cf91b..85413ba4c 100644 --- a/AutoDarkModeApp/Strings/zh-hans/Resources.resw +++ b/AutoDarkModeApp/Strings/zh-hans/Resources.resw @@ -233,9 +233,6 @@ GitHub 上发布的新版本包含一些漏洞修复和改进。 欢迎 - - 更改此处的设置以修改自动切换主题的行为。 - 翻译者: zheolls、没有字的回音、ThrRip、shenzhiming88、Bill Lee @@ -367,9 +364,6 @@ GitHub 上发布的新版本包含一些漏洞修复和改进。 调整 - - 设置 - 使用 Windows 主题模式时无法调整这些选项。 您可以在 Windows 主题中单独设置这些选项。 @@ -743,9 +737,6 @@ GitHub 上发布的新版本包含一些漏洞修复和改进。 每天 - - 单击“设置”保存更改。 - 使用任务栏主题色 diff --git a/AutoDarkModeApp/Utils/Handlers/ThemeCollectionHandler.cs b/AutoDarkModeApp/Utils/Handlers/ThemeCollectionHandler.cs index c91f66d1d..83fd2ccb5 100644 --- a/AutoDarkModeApp/Utils/Handlers/ThemeCollectionHandler.cs +++ b/AutoDarkModeApp/Utils/Handlers/ThemeCollectionHandler.cs @@ -1,4 +1,4 @@ -#region copyright +#region copyright // TODO: Should we reduced copyright header? Made it more concise while keeping all important info // Copyright (C) 2025 Auto Dark Mode // This program is free software under GNU GPL v3.0 diff --git a/AutoDarkModeApp/ViewModels/CursorsViewModel.cs b/AutoDarkModeApp/ViewModels/CursorsViewModel.cs index f960be453..950fc40dd 100644 --- a/AutoDarkModeApp/ViewModels/CursorsViewModel.cs +++ b/AutoDarkModeApp/ViewModels/CursorsViewModel.cs @@ -16,10 +16,10 @@ public partial class CursorsViewModel : ObservableRecipient public partial bool CursorsEnabled { get; set; } [ObservableProperty] - public partial object? SelectLightCusor { get; set; } + public partial object? SelectLightCursor { get; set; } [ObservableProperty] - public partial object? SelectDarkCusor { get; set; } + public partial object? SelectDarkCursor { get; set; } public CursorsViewModel(IErrorService errorService) { @@ -43,9 +43,9 @@ public CursorsViewModel(IErrorService errorService) private void LoadSettings() { - CursorsEnabled = _builder.Config.CursorSwitch.Enabled; - SelectLightCusor = _builder.Config.CursorSwitch.Component.CursorsLight; - SelectDarkCusor = _builder.Config.CursorSwitch.Component.CursorsDark; + IsCursorsEnabled = _builder.Config.CursorSwitch.Enabled; + SelectLightCursor = _builder.Config.CursorSwitch.Component.CursorsLight; + SelectDarkCursor = _builder.Config.CursorSwitch.Component.CursorsDark; } private void HandleConfigUpdate(object sender, FileSystemEventArgs e) @@ -74,7 +74,7 @@ partial void OnCursorsEnabledChanged(bool value) } } - partial void OnSelectLightCusorChanged(object? value) + partial void OnSelectLightCursorChanged(object? value) { if (value != null) { @@ -90,7 +90,7 @@ partial void OnSelectLightCusorChanged(object? value) } } - partial void OnSelectDarkCusorChanged(object? value) + partial void OnSelectDarkCursorChanged(object? value) { if (value != null) { diff --git a/AutoDarkModeApp/ViewModels/ThemePickerViewModel.cs b/AutoDarkModeApp/ViewModels/ThemePickerViewModel.cs index f418f64a1..379851e86 100644 --- a/AutoDarkModeApp/ViewModels/ThemePickerViewModel.cs +++ b/AutoDarkModeApp/ViewModels/ThemePickerViewModel.cs @@ -2,6 +2,7 @@ using AutoDarkModeApp.Utils.Handlers; using AutoDarkModeLib; using CommunityToolkit.Mvvm.ComponentModel; + using static AutoDarkModeLib.IThemeManager2.Flags; namespace AutoDarkModeApp.ViewModels; @@ -11,6 +12,7 @@ public partial class ThemePickerViewModel : ObservableRecipient private readonly AdmConfigBuilder _builder = AdmConfigBuilder.Instance(); private readonly Microsoft.UI.Dispatching.DispatcherQueue _dispatcherQueue; private readonly IErrorService _errorService; + private bool _isInitializing; [ObservableProperty] @@ -237,4 +239,5 @@ partial void OnIgnoreDesktopIconsEnabledChanged(bool value) { WriteSettings(); } + } diff --git a/AutoDarkModeApp/ViewModels/TimeViewModel.cs b/AutoDarkModeApp/ViewModels/TimeViewModel.cs index af64363c4..e649aa32d 100644 --- a/AutoDarkModeApp/ViewModels/TimeViewModel.cs +++ b/AutoDarkModeApp/ViewModels/TimeViewModel.cs @@ -8,6 +8,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Navigation; namespace AutoDarkModeApp.ViewModels; @@ -102,16 +103,8 @@ public TimeViewModel(IErrorService errorService) LoadSettings(); Task.Run(() => LoadPostponeTimer(null, new())); - StateUpdateHandler.AddDebounceEventOnConfigUpdate(() => HandleConfigUpdate()); - StateUpdateHandler.StartConfigWatcher(); - - StateUpdateHandler.OnPostponeTimerTick += LoadPostponeTimer; - StateUpdateHandler.StartPostponeTimer(); - - SaveCoordinatesCommand = new RelayCommand(() => - { - UpdateCoordinates(); - }); + StateUpdateHandler.StartConfigWatcherWithoutEvents(); + StateUpdateHandler.AddDebounceEventOnConfigUpdate(HandleConfigUpdate); SaveOffsetCommand = new RelayCommand(() => { @@ -475,35 +468,6 @@ partial void OnIsPostponedChanged(bool value) if (_isInitializing) return; - var postponeMinutes = (SelectedPostponeIndex) switch - { - 0 => 15, - 1 => 30, - 2 => 60, - 3 => 120, - 4 => 180, - 5 => 360, - 6 => 720, - 7 => 0, - _ => 0, - }; - - if (postponeMinutes != 0 && value) - { - MessageHandler.Client.SendMessageAndGetReply($"{Command.DelayBy} {postponeMinutes}"); - } - else if (postponeMinutes == 0 && value) - { - MessageHandler.Client.SendMessageAndGetReply(Command.ToggleSkipNext); - if (!value) - MessageHandler.Client.SendMessageAndGetReply(Command.RequestSwitch); - } - else - { - MessageHandler.Client.SendMessageAndGetReply(Command.ClearPostponeQueue); - MessageHandler.Client.SendMessageAndGetReply(Command.RequestSwitch); - } + partial void OnLonValueChanged(double value) => UpdateCoordinates(); - LoadPostponeTimer(null, new()); - } } diff --git a/AutoDarkModeApp/ViewModels/WallpaperPickerViewModel.cs b/AutoDarkModeApp/ViewModels/WallpaperPickerViewModel.cs index 68369e8f7..622db7c0e 100644 --- a/AutoDarkModeApp/ViewModels/WallpaperPickerViewModel.cs +++ b/AutoDarkModeApp/ViewModels/WallpaperPickerViewModel.cs @@ -1,13 +1,16 @@ using System.Windows.Input; using AutoDarkModeApp.Contracts.Services; +using AutoDarkModeApp.Services; using AutoDarkModeApp.Utils.Handlers; using AutoDarkModeLib; using AutoDarkModeLib.ComponentSettings.Base; +using AutoDarkModeSvc.Communication; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.WinUI.Helpers; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Media.Imaging; using Microsoft.UI.Xaml.Navigation; namespace AutoDarkModeApp.ViewModels; @@ -23,7 +26,7 @@ public enum WallpaperDisplayMode Picture, PictureMM, SolidColor, - Spotlight + Spotlight, } public enum WallpaperDisplayFlags @@ -36,17 +39,18 @@ public enum WallpaperDisplayFlags ShowSpotlight = 16, // Predefined combinations - PictureMode = ShowImageSettings, + PictureMode = ShowImageSettings | ShowFillingWaySettings, PictureMMMode = ShowImageSettings | ShowMonitorSettings | ShowFillingWaySettings, SolidColorMode = ShowColorSettings, - SpotlightMode = ShowSpotlight + SpotlightMode = ShowSpotlight, } public enum WallpaperFillingMode { - Fill, + Center, + Stretch, Fit, - Stretch + Fill, } [ObservableProperty] @@ -61,6 +65,9 @@ public enum WallpaperFillingMode [ObservableProperty] public partial WallpaperDisplayFlags CurrentDisplayFlags { get; set; } + [ObservableProperty] + public partial ImageSource? GlobalWallpaperSource { get; set; } + [ObservableProperty] public partial string? GlobalWallpaperPath { get; set; } @@ -102,7 +109,31 @@ public WallpaperPickerViewModel(IErrorService errorService) { ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail, SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary, - FileTypeFilter = { ".jpg", ".jpeg", ".bmp", ".dib", ".png", ".jff", ".jpe", ".gif", ".tif", ".tiff", ".wdp", ".heic", ".heif", ".heics", ".heifs", ".hif", ".avci", ".avcs", ".avif", ".avifs", ".jxr", ".jxl" } + FileTypeFilter = + { + ".jpg", + ".jpeg", + ".bmp", + ".dib", + ".png", + ".jff", + ".jpe", + ".gif", + ".tif", + ".tiff", + ".wdp", + ".heic", + ".heif", + ".heics", + ".heifs", + ".hif", + ".avci", + ".avcs", + ".avif", + ".avifs", + ".jxr", + ".jxl", + }, }; var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow); WinRT.Interop.InitializeWithWindow.Initialize(openPicker, hWnd); @@ -123,14 +154,13 @@ private void LoadSettings() WallpaperPosition.Fill => WallpaperFillingMode.Fill, WallpaperPosition.Fit => WallpaperFillingMode.Fit, WallpaperPosition.Stretch => WallpaperFillingMode.Stretch, - _ => WallpaperFillingMode.Fill + WallpaperPosition.Center => WallpaperFillingMode.Center, + _ => WallpaperFillingMode.Fill, }; CurrentDisplayFlags = WallpaperDisplayFlags.None; - var currentType = SelectWallpaperThemeMode == ApplicationTheme.Light - ? _builder.Config.WallpaperSwitch.Component.TypeLight - : _builder.Config.WallpaperSwitch.Component.TypeDark; + var currentType = SelectWallpaperThemeMode == ApplicationTheme.Light ? _builder.Config.WallpaperSwitch.Component.TypeLight : _builder.Config.WallpaperSwitch.Component.TypeDark; CurrentDisplayMode = currentType switch { @@ -138,7 +168,7 @@ private void LoadSettings() WallpaperType.Individual => WallpaperDisplayMode.PictureMM, WallpaperType.SolidColor => WallpaperDisplayMode.SolidColor, WallpaperType.Spotlight => WallpaperDisplayMode.Spotlight, - _ => WallpaperDisplayMode.Picture + _ => WallpaperDisplayMode.Picture, }; CurrentDisplayFlags = currentType switch @@ -147,45 +177,77 @@ private void LoadSettings() WallpaperType.Individual => WallpaperDisplayFlags.PictureMMMode, WallpaperType.SolidColor => WallpaperDisplayFlags.SolidColorMode, WallpaperType.Spotlight => WallpaperDisplayFlags.SpotlightMode, - _ => WallpaperDisplayFlags.None + _ => WallpaperDisplayFlags.None, }; if (currentType == WallpaperType.Global) { - GlobalWallpaperPath = SelectWallpaperThemeMode == ApplicationTheme.Light - ? _builder.Config.WallpaperSwitch.Component.GlobalWallpaper.Light - : _builder.Config.WallpaperSwitch.Component.GlobalWallpaper.Dark; + GlobalWallpaperPath = + SelectWallpaperThemeMode == ApplicationTheme.Light ? _builder.Config.WallpaperSwitch.Component.GlobalWallpaper.Light : _builder.Config.WallpaperSwitch.Component.GlobalWallpaper.Dark; + if (GlobalWallpaperPath != null) + { + GlobalWallpaperSource = new BitmapImage(new Uri(GlobalWallpaperPath)); + } + else + { + GlobalWallpaperSource = null; + } } else if (currentType == WallpaperType.Individual && SelectMonitor != null) { MonitorSettings monitorSettings = (MonitorSettings)SelectMonitor; - GlobalWallpaperPath = SelectWallpaperThemeMode == ApplicationTheme.Light - ? monitorSettings.LightThemeWallpaper - : monitorSettings.DarkThemeWallpaper; + GlobalWallpaperPath = SelectWallpaperThemeMode == ApplicationTheme.Light ? monitorSettings.LightThemeWallpaper : monitorSettings.DarkThemeWallpaper; + if (GlobalWallpaperPath != null) + { + GlobalWallpaperSource = new BitmapImage(new Uri(GlobalWallpaperPath)); + } + else + { + GlobalWallpaperSource = null; + } } - else + else if (currentType == WallpaperType.SolidColor) { - GlobalWallpaperPath = SelectWallpaperThemeMode == ApplicationTheme.Light - ? _builder.Config.WallpaperSwitch.Component.GlobalWallpaper.Light - : _builder.Config.WallpaperSwitch.Component.GlobalWallpaper.Dark; + GlobalWallpaperSource = null; + } + else if (currentType == WallpaperType.Spotlight) + { + //TODO: Need a better method + //GlobalWallpaperSource = new BitmapImage(new Uri(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Themes\TranscodedWallpaper")); + GlobalWallpaperSource = null; } - ColorPreviewBorderBackground = SelectWallpaperThemeMode == ApplicationTheme.Light - ? new SolidColorBrush(_builder.Config.WallpaperSwitch.Component.SolidColors.Light.ToColor()) - : new SolidColorBrush(_builder.Config.WallpaperSwitch.Component.SolidColors.Dark.ToColor()); + ColorPreviewBorderBackground = + SelectWallpaperThemeMode == ApplicationTheme.Light + ? new SolidColorBrush(_builder.Config.WallpaperSwitch.Component.SolidColors.Light.ToColor()) + : new SolidColorBrush(_builder.Config.WallpaperSwitch.Component.SolidColors.Dark.ToColor()); } private void HandleConfigUpdate(object sender, FileSystemEventArgs e) { + StateUpdateHandler.StopConfigWatcher(); _dispatcherQueue.TryEnqueue(() => { - StateUpdateHandler.StopConfigWatcher(); - _builder.Load(); LoadSettings(); - - StateUpdateHandler.StartConfigWatcher(); }); + StateUpdateHandler.StartConfigWatcher(); + } + + private async void RequestThemeSwitch() + { + try + { + var result = await MessageHandler.Client.SendMessageAndGetReplyAsync(Command.RequestSwitch, 15); + if (result != StatusCode.Ok) + { + throw new SwitchThemeException(result, "PageApps"); + } + } + catch (Exception ex) + { + await _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "AppsPage"); + } } partial void OnIsWallpaperSwitchEnabledChanged(bool value) @@ -216,7 +278,7 @@ partial void OnCurrentDisplayModeChanged(WallpaperDisplayMode value) WallpaperDisplayMode.PictureMM => WallpaperType.Individual, WallpaperDisplayMode.SolidColor => WallpaperType.SolidColor, WallpaperDisplayMode.Spotlight => WallpaperType.Spotlight, - _ => WallpaperType.Unknown + _ => WallpaperType.Unknown, }; } else @@ -227,7 +289,7 @@ partial void OnCurrentDisplayModeChanged(WallpaperDisplayMode value) WallpaperDisplayMode.PictureMM => WallpaperType.Individual, WallpaperDisplayMode.SolidColor => WallpaperType.SolidColor, WallpaperDisplayMode.Spotlight => WallpaperType.Spotlight, - _ => WallpaperType.Unknown + _ => WallpaperType.Unknown, }; } try @@ -238,6 +300,7 @@ partial void OnCurrentDisplayModeChanged(WallpaperDisplayMode value) { _errorService.ShowErrorMessage(ex, App.MainWindow.Content.XamlRoot, "WallpaperPickerPage"); } + RequestThemeSwitch(); } partial void OnGlobalWallpaperPathChanged(string? value) @@ -305,7 +368,8 @@ partial void OnSelectWallpaperFillingModeChanged(WallpaperFillingMode value) WallpaperFillingMode.Fill => WallpaperPosition.Fill, WallpaperFillingMode.Fit => WallpaperPosition.Fit, WallpaperFillingMode.Stretch => WallpaperPosition.Stretch, - _ => WallpaperPosition.Fill + WallpaperFillingMode.Center => WallpaperPosition.Center, + _ => WallpaperPosition.Fill, }; try { diff --git a/AutoDarkModeApp/Views/ColorizationPage.xaml b/AutoDarkModeApp/Views/ColorizationPage.xaml index 9a391d993..429505582 100644 --- a/AutoDarkModeApp/Views/ColorizationPage.xaml +++ b/AutoDarkModeApp/Views/ColorizationPage.xaml @@ -23,7 +23,10 @@ - + @@ -49,7 +52,10 @@ - + @@ -74,6 +80,7 @@ + - + - + + IsEnabled="{x:Bind ViewModel.IsCursorsEnabled, Mode=OneWay}" + IsExpanded="True"> + + x:Name="LightCursorComboBox" + SelectedItem="{x:Bind ViewModel.SelectLightCursor, Mode=TwoWay}" + SelectionChanged="LightCursorComboBox_SelectionChanged" /> - + + IsEnabled="{x:Bind ViewModel.IsCursorsEnabled, Mode=OneWay}" + IsExpanded="True"> + + x:Name="DarkCursorComboBox" + SelectedItem="{x:Bind ViewModel.SelectDarkCursor, Mode=TwoWay}" + SelectionChanged="DarkCursorComboBox_SelectionChanged" /> (); InitializeComponent(); - DispatcherQueue.TryEnqueue(() => LoadCurosSource()); - DispatcherQueue.TryEnqueue(() => LoadCurosPreview()); + DispatcherQueue.TryEnqueue(() => LoadCursorSources()); + DispatcherQueue.TryEnqueue(() => LoadCursorPreview()); } - private void LoadCurosSource() + private void LoadCursorSources() { try { List cursors = CursorCollectionHandler.GetCursors(); - LightCurosComboBox.ItemsSource = cursors; - DarkCurosComboBox.ItemsSource = cursors; + LightCursorComboBox.ItemsSource = cursors; + DarkCursorComboBox.ItemsSource = cursors; } catch (Exception ex) { @@ -37,12 +37,12 @@ private void LoadCurosSource() } } - private void LoadCurosPreview() + private void LoadCursorPreview() { - if (ViewModel.SelectLightCusor != null) + if (ViewModel.SelectLightCursor != null) { LightImageStackPanel.Children.Clear(); - string[] cursors = CursorCollectionHandler.GetCursorScheme(ViewModel.SelectLightCusor.ToString()!); + string[] cursors = CursorCollectionHandler.GetCursorScheme(ViewModel.SelectLightCursor.ToString()!); foreach (string cursor in cursors) { try @@ -71,10 +71,10 @@ private void LoadCurosPreview() } } - if (ViewModel.SelectDarkCusor != null) + if (ViewModel.SelectDarkCursor != null) { DarkImageStackPanel.Children.Clear(); - string[] cursors = CursorCollectionHandler.GetCursorScheme(ViewModel.SelectDarkCusor.ToString()!); + string[] cursors = CursorCollectionHandler.GetCursorScheme(ViewModel.SelectDarkCursor.ToString()!); foreach (string cursor in cursors) { try @@ -104,14 +104,14 @@ private void LoadCurosPreview() } } - private void LightCurosComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void LightCursorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - DispatcherQueue.TryEnqueue(() => LoadCurosPreview()); + DispatcherQueue.TryEnqueue(() => LoadCursorPreview()); } - private void DarkCurosComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void DarkCursorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - DispatcherQueue.TryEnqueue(() => LoadCurosPreview()); + DispatcherQueue.TryEnqueue(() => LoadCursorPreview()); } protected override void OnNavigatedFrom(NavigationEventArgs e) => ViewModel.OnViewModelNavigatedFrom(e); diff --git a/AutoDarkModeApp/Views/SystemAreasPage.xaml b/AutoDarkModeApp/Views/SystemAreasPage.xaml index 4ab13ca85..0a171f7a8 100644 --- a/AutoDarkModeApp/Views/SystemAreasPage.xaml +++ b/AutoDarkModeApp/Views/SystemAreasPage.xaml @@ -17,8 +17,6 @@ - - diff --git a/AutoDarkModeApp/Views/ThemePickerPage.xaml b/AutoDarkModeApp/Views/ThemePickerPage.xaml index b2b5b0fd9..193e6de3f 100644 --- a/AutoDarkModeApp/Views/ThemePickerPage.xaml +++ b/AutoDarkModeApp/Views/ThemePickerPage.xaml @@ -63,6 +63,7 @@ MinWidth="120" SelectedItem="{x:Bind ViewModel.SelectedDarkTheme, Mode=TwoWay}" /> + + - - - - + + + + + + + - - + + - - - - - + + + - - - - - - - - - - - - - - - -