From 2afce9fde3232ee3ed59b5d2ffb24bdfba9da9cb Mon Sep 17 00:00:00 2001 From: gil zhang Date: Sun, 24 Mar 2024 02:54:58 +0800 Subject: [PATCH] update clock view --- .../ClockViews/CustomClockView.xaml | 4 ++-- .../ClockViews/CustomClockView.xaml.cs | 10 +++++----- .../ClockViews/GooeyFooter.xaml | 6 +++--- .../ClockViews/GradientsWithBlend.xaml | 4 ++-- .../ClockViews/HiddenTextView.xaml | 4 ++-- .../ClockViews/LongShadow.xaml | 4 ++-- .../ViewModels/ClockViewModel.cs | 16 ++++++---------- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml b/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml index 877e6fe..0527946 100644 --- a/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml +++ b/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml @@ -60,10 +60,10 @@ MaxWidth="120" Margin="2" HorizontalAlignment="Right" - FontSize="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitleFontSize, Mode=OneWay}" + FontSize="{x:Bind ViewModel.BotSetting.CustomClockTitleFontSize, Mode=OneWay}" FontWeight="Bold" Foreground="White" - Text="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitle, Mode=OneWay}" + Text="{x:Bind ViewModel.BotSetting.CustomClockTitle, Mode=OneWay}" TextWrapping="Wrap" /> diff --git a/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml.cs b/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml.cs index 9d29db6..3660a36 100644 --- a/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml.cs +++ b/src/ElectronBot.Braincase/ClockViews/CustomClockView.xaml.cs @@ -55,16 +55,16 @@ public sealed partial class CustomClockView : UserControl var blurAmount = 4.0f; - if (ViewModel.ClockTitleConfig != null) + if (ViewModel.BotSetting != null) { - if (!string.IsNullOrEmpty(ViewModel.ClockTitleConfig.CustomViewPicturePath)) + if (!string.IsNullOrEmpty(ViewModel.BotSetting.CustomViewPicturePath)) { - imgPath = ViewModel.ClockTitleConfig.CustomViewPicturePath; + imgPath = ViewModel.BotSetting.CustomViewPicturePath; } - blurAmount = ViewModel.ClockTitleConfig.GaussianBlurValue; + blurAmount = ViewModel.BotSetting.GaussianBlurValue; - if (!ViewModel.ClockTitleConfig.CustomViewContentIsVisibility) + if (!ViewModel.BotSetting.CustomViewContentIsVisibility) { PomodoroPanel.Visibility = Visibility.Collapsed; } diff --git a/src/ElectronBot.Braincase/ClockViews/GooeyFooter.xaml b/src/ElectronBot.Braincase/ClockViews/GooeyFooter.xaml index 56d3bca..9b37bd5 100644 --- a/src/ElectronBot.Braincase/ClockViews/GooeyFooter.xaml +++ b/src/ElectronBot.Braincase/ClockViews/GooeyFooter.xaml @@ -8,8 +8,8 @@ xmlns:local="using:ElectronBot.Braincase.ClockViews" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:xaml="using:Microsoft.Graphics.Canvas.UI.Xaml" - Unloaded="UserControl_Unloaded" Background="Black" + Unloaded="UserControl_Unloaded" mc:Ignorable="d"> @@ -146,10 +146,10 @@ MaxWidth="120" Margin="2" HorizontalAlignment="Right" - FontSize="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitleFontSize, Mode=OneWay}" + FontSize="{x:Bind ViewModel.BotSetting.CustomClockTitleFontSize, Mode=OneWay}" FontWeight="Bold" Foreground="White" - Text="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitle, Mode=OneWay}" + Text="{x:Bind ViewModel.BotSetting.CustomClockTitle, Mode=OneWay}" TextWrapping="Wrap" /> diff --git a/src/ElectronBot.Braincase/ClockViews/GradientsWithBlend.xaml b/src/ElectronBot.Braincase/ClockViews/GradientsWithBlend.xaml index 93e0faf..bd7f9cf 100644 --- a/src/ElectronBot.Braincase/ClockViews/GradientsWithBlend.xaml +++ b/src/ElectronBot.Braincase/ClockViews/GradientsWithBlend.xaml @@ -66,9 +66,9 @@ Margin="0,12,0,12" HorizontalAlignment="Center" FontFamily="/Assets/Font/SmileySans-Oblique.ttf#得意黑" - FontSize="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitleFontSize, Mode=OneWay}" + FontSize="{x:Bind ViewModel.BotSetting.CustomClockTitleFontSize, Mode=OneWay}" Foreground="White" - Text="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitle, Mode=OneWay}" /> + Text="{x:Bind ViewModel.BotSetting.CustomClockTitle, Mode=OneWay}" /> diff --git a/src/ElectronBot.Braincase/ClockViews/LongShadow.xaml b/src/ElectronBot.Braincase/ClockViews/LongShadow.xaml index 883088e..1db1c12 100644 --- a/src/ElectronBot.Braincase/ClockViews/LongShadow.xaml +++ b/src/ElectronBot.Braincase/ClockViews/LongShadow.xaml @@ -38,10 +38,10 @@ MaxWidth="120" HorizontalAlignment="Left" FontFamily="{StaticResource TimeFont}" - FontSize="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitleFontSize, Mode=OneWay}" + FontSize="{x:Bind ViewModel.BotSetting.CustomClockTitleFontSize, Mode=OneWay}" FontWeight="Bold" Foreground="White" - Text="{x:Bind ViewModel.ClockTitleConfig.CustomClockTitle, Mode=OneWay}" + Text="{x:Bind ViewModel.BotSetting.CustomClockTitle, Mode=OneWay}" TextWrapping="Wrap" /> diff --git a/src/ElectronBot.Braincase/ViewModels/ClockViewModel.cs b/src/ElectronBot.Braincase/ViewModels/ClockViewModel.cs index 13264d3..1b96c7d 100644 --- a/src/ElectronBot.Braincase/ViewModels/ClockViewModel.cs +++ b/src/ElectronBot.Braincase/ViewModels/ClockViewModel.cs @@ -5,10 +5,11 @@ using ElectronBot.Braincase.Contracts.Services; using ElectronBot.Braincase.Models; using ElectronBot.Braincase.Services; using Microsoft.UI.Xaml; +using Models; namespace ElectronBot.Braincase.ViewModels; -public class ClockViewModel : ObservableRecipient +public partial class ClockViewModel : ObservableRecipient { private readonly DispatcherTimer _dispatcherTimer; @@ -42,19 +43,14 @@ public class ClockViewModel : ObservableRecipient private string _customClockTitle; - private CustomClockTitleConfig _clockTitleConfig; - public string CustomClockTitle { get => _customClockTitle; set => SetProperty(ref _customClockTitle, value); } - public CustomClockTitleConfig ClockTitleConfig - { - get => _clockTitleConfig; - set => SetProperty(ref _clockTitleConfig, value); - } + [ObservableProperty] + private BotSetting _botSetting; public ClockDiagnosticInfo ClockDiagnosticInfo { @@ -73,9 +69,9 @@ public class ClockViewModel : ObservableRecipient { _dispatcherTimer.Start(); - var ret2 = await _localSettingsService.ReadSettingAsync(Constants.CustomClockTitleConfigKey); + var botSetting = await _localSettingsService.ReadSettingAsync(Constants.BotSettingKey); - ClockTitleConfig = ret2 ?? new CustomClockTitleConfig(); + BotSetting = botSetting ?? new BotSetting(); _diagnosticService.ClockDiagnosticInfoResult += DiagnosticService_ClockDiagnosticInfoResult; }