From fb3a77283e73004f2e00a1aa84333474ed47a62d Mon Sep 17 00:00:00 2001 From: gil zhang Date: Mon, 1 Jan 2024 17:51:50 +0800 Subject: [PATCH] hide todo view --- src/ElectronBot.Braincase/App.xaml.cs | 10 ++++---- .../Hw75Views/Hw75CustomView.xaml | 3 +++ .../Hw75Views/Hw75WeatherView.xaml | 25 +++++++++++-------- .../Hw75Views/Hw75YellowCalendarView.xaml | 3 +++ .../Services/ComboxDataService.cs | 2 +- .../ViewModels/Hw75/Hw75CustomViewModel.cs | 25 ++++++++++--------- .../ViewModels/Hw75/Hw75WeatherViewModel.cs | 6 +++++ .../Hw75/Hw75YellowCalendarViewModel.cs | 6 +++++ .../ViewModels/Hw75ViewModel.cs | 5 +--- 9 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/ElectronBot.Braincase/App.xaml.cs b/src/ElectronBot.Braincase/App.xaml.cs index ba2b211..9fe9eb1 100644 --- a/src/ElectronBot.Braincase/App.xaml.cs +++ b/src/ElectronBot.Braincase/App.xaml.cs @@ -238,15 +238,15 @@ public partial class App : Application services.AddTransient(); - services.AddSingleton(); + services.AddTransient(); - services.AddSingleton(); + services.AddTransient(); - services.AddSingleton(); - services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); - services.AddSingleton(); + services.AddTransient(); services.AddGrpcClient(o => { diff --git a/src/ElectronBot.Braincase/Hw75Views/Hw75CustomView.xaml b/src/ElectronBot.Braincase/Hw75Views/Hw75CustomView.xaml index 1c3ad88..cb79574 100644 --- a/src/ElectronBot.Braincase/Hw75Views/Hw75CustomView.xaml +++ b/src/ElectronBot.Braincase/Hw75Views/Hw75CustomView.xaml @@ -14,6 +14,9 @@ + + + diff --git a/src/ElectronBot.Braincase/Hw75Views/Hw75WeatherView.xaml b/src/ElectronBot.Braincase/Hw75Views/Hw75WeatherView.xaml index c514fbe..444046a 100644 --- a/src/ElectronBot.Braincase/Hw75Views/Hw75WeatherView.xaml +++ b/src/ElectronBot.Braincase/Hw75Views/Hw75WeatherView.xaml @@ -13,6 +13,9 @@ + + + @@ -48,15 +51,15 @@ Orientation="Horizontal"> @@ -104,8 +107,8 @@ @@ -115,8 +118,8 @@ x:Name="wind_sd" Margin="4" HorizontalAlignment="Center" - FontSize="12" FontFamily="/Assets/Font/fusion-pixel-12px-monospaced-zh_hans.ttf#Fusion Pixel 12px Monospaced zh_hans" + FontSize="12" Foreground="Black" Text="{x:Bind ViewModel.GpsResult.Now.Wind_sd, Mode=OneWay}" /> @@ -124,9 +127,9 @@ @@ -135,18 +138,18 @@ diff --git a/src/ElectronBot.Braincase/Hw75Views/Hw75YellowCalendarView.xaml b/src/ElectronBot.Braincase/Hw75Views/Hw75YellowCalendarView.xaml index bc239ee..50ab2a2 100644 --- a/src/ElectronBot.Braincase/Hw75Views/Hw75YellowCalendarView.xaml +++ b/src/ElectronBot.Braincase/Hw75Views/Hw75YellowCalendarView.xaml @@ -13,6 +13,9 @@ + + + diff --git a/src/ElectronBot.Braincase/Services/ComboxDataService.cs b/src/ElectronBot.Braincase/Services/ComboxDataService.cs index 443cc72..b5c5c05 100644 --- a/src/ElectronBot.Braincase/Services/ComboxDataService.cs +++ b/src/ElectronBot.Braincase/Services/ComboxDataService.cs @@ -26,7 +26,7 @@ public class ComboxDataService new ComboxItemModel { DataKey = "Hw75CustomView", DataValue = "Hw75CustomView".GetLocalized() }, new ComboxItemModel { DataKey = "Hw75WeatherView", DataValue ="Hw75WeatherView".GetLocalized() }, new ComboxItemModel { DataKey = "Hw75YellowCalendarView", DataValue ="Hw75YellowCalendarView".GetLocalized() }, - new ComboxItemModel { DataKey = "TodoView", DataValue ="TodoView".GetLocalized() }, + //new ComboxItemModel { DataKey = "TodoView", DataValue ="TodoView".GetLocalized() }, }; } diff --git a/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75CustomViewModel.cs b/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75CustomViewModel.cs index aa0c9e6..34af075 100644 --- a/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75CustomViewModel.cs +++ b/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75CustomViewModel.cs @@ -1,5 +1,4 @@ -using System.Windows.Input; -using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using ElectronBot.Braincase.Contracts.Services; using ElectronBot.Braincase.Helpers; @@ -11,13 +10,10 @@ namespace ElectronBot.Braincase.ViewModels; public partial class Hw75CustomViewModel : ObservableRecipient { - private readonly DispatcherTimer _dispatcherTimer; + private readonly DispatcherTimer _dispatcherTimer = new(); private readonly ILocalSettingsService _localSettingsService; - private ICommand _loadedCommand; - public ICommand LoadedCommand => _loadedCommand ??= new RelayCommand(OnLoaded); - private string _todayWeek = DateTimeOffset.Now.ToString("ddd"); private ClockDiagnosticInfo _clockDiagnosticInfo = new(); @@ -75,7 +71,9 @@ public partial class Hw75CustomViewModel : ObservableRecipient get => _todayTime; set => SetProperty(ref _todayTime, value); } - private async void OnLoaded() + + [RelayCommand] + private async Task OnLoaded() { _dispatcherTimer.Start(); @@ -86,11 +84,17 @@ public partial class Hw75CustomViewModel : ObservableRecipient CustomContentVisibility = ClockTitleConfig.Hw75CustomContentIsVisibility ? Visibility.Visible : Visibility.Collapsed; DateVisibility = ClockTitleConfig.Hw75TimeIsVisibility ? Visibility.Visible : Visibility.Collapsed; - _diagnosticService.ClockDiagnosticInfoResult += DiagnosticService_ClockDiagnosticInfoResult; + _diagnosticService.ClockDiagnosticInfoResult += DiagnosticService_ClockDiagnosticInfoResult; Hw75Helper.Instance.InvokeHandler(); } + [RelayCommand] + private void OnUnLoaded() + { + _dispatcherTimer.Stop(); + } + private void DiagnosticService_ClockDiagnosticInfoResult(object? sender, ClockDiagnosticInfo e) { App.MainWindow.DispatcherQueue.TryEnqueue(() => @@ -108,12 +112,9 @@ public partial class Hw75CustomViewModel : ObservableRecipient Hw75Helper.Instance.InvokeHandler(); } - public Hw75CustomViewModel(DispatcherTimer dispatcherTimer, - ClockDiagnosticService clockDiagnosticService, - ILocalSettingsService localSettingsService + public Hw75CustomViewModel(ClockDiagnosticService clockDiagnosticService, ILocalSettingsService localSettingsService ) { - _dispatcherTimer = dispatcherTimer; _diagnosticService = clockDiagnosticService; _localSettingsService = localSettingsService; diff --git a/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75WeatherViewModel.cs b/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75WeatherViewModel.cs index 75a2e01..32eac5c 100644 --- a/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75WeatherViewModel.cs +++ b/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75WeatherViewModel.cs @@ -66,4 +66,10 @@ public partial class Hw75WeatherViewModel : ObservableRecipient Hw75Helper.Instance.InvokeHandler(); } + + [RelayCommand] + private void OnUnLoaded() + { + _dispatcherTimer.Stop(); + } } diff --git a/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75YellowCalendarViewModel.cs b/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75YellowCalendarViewModel.cs index 52fc763..9ac242e 100644 --- a/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75YellowCalendarViewModel.cs +++ b/src/ElectronBot.Braincase/ViewModels/Hw75/Hw75YellowCalendarViewModel.cs @@ -40,4 +40,10 @@ public partial class Hw75YellowCalendarViewModel : ObservableRecipient Hw75Helper.Instance.InvokeHandler(); } + + [RelayCommand] + private void OnUnLoaded() + { + _dispatcherTimer.Stop(); + } } diff --git a/src/ElectronBot.Braincase/ViewModels/Hw75ViewModel.cs b/src/ElectronBot.Braincase/ViewModels/Hw75ViewModel.cs index af72b3f..61f3b77 100644 --- a/src/ElectronBot.Braincase/ViewModels/Hw75ViewModel.cs +++ b/src/ElectronBot.Braincase/ViewModels/Hw75ViewModel.cs @@ -79,7 +79,7 @@ public partial class Hw75ViewModel : ObservableRecipient, INavigationAware /// 表盘切换方法 /// [RelayCommand] - private async Task ClockChanged() + private void ClockChanged() { var clockName = ClockComBoxSelect?.DataKey; @@ -88,9 +88,6 @@ public partial class Hw75ViewModel : ObservableRecipient, INavigationAware var viewProvider = _viewProviderFactory.CreateHw75DynamicViewProvider(clockName); Element = viewProvider.CreateHw75DynamickView(clockName); - - await Task.Delay(1000); - await Hw75Helper.Instance.SyncDataToDeviceAsync(Element); } }