diff --git a/GalaxyBudsClient/Interface/Controls/SettingsSwitchItem.cs b/GalaxyBudsClient/Interface/Controls/SettingsSwitchItem.cs index 1f6ab501..cf28806b 100644 --- a/GalaxyBudsClient/Interface/Controls/SettingsSwitchItem.cs +++ b/GalaxyBudsClient/Interface/Controls/SettingsSwitchItem.cs @@ -3,6 +3,8 @@ using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Interactivity; +using GalaxyBudsClient.Generated.I18N; +using GalaxyBudsClient.Utils.Interface; namespace GalaxyBudsClient.Interface.Controls; @@ -13,38 +15,47 @@ public SettingsSwitchItem() { _toggle = new ToggleSwitch(); _toggle.IsCheckedChanged += (_, _) => IsChecked = _toggle.IsChecked; - + Click += OnClick; IsClickEnabled = true; Footer = _toggle; + + Loc.LanguageUpdated += OnLanguageUpdated; + OnLanguageUpdated(); } private readonly ToggleSwitch _toggle; - - public static readonly RoutedEvent IsCheckedChangedEvent = + + public static readonly RoutedEvent IsCheckedChangedEvent = RoutedEvent.Register(nameof(IsCheckedChanged), RoutingStrategies.Bubble); - public static readonly StyledProperty IsCheckedProperty = + public static readonly StyledProperty IsCheckedProperty = ToggleButton.IsCheckedProperty.AddOwner(); - + public event EventHandler? IsCheckedChanged { add => AddHandler(IsCheckedChangedEvent, value); remove => RemoveHandler(IsCheckedChangedEvent, value); } + private void OnLanguageUpdated() + { + _toggle.OnContent = Strings.On; + _toggle.OffContent = Strings.Off; + } + public bool? IsChecked { get => GetValue(IsCheckedProperty); set => SetValue(IsCheckedProperty, value); } - + private void OnClick(object? sender, RoutedEventArgs e) { IsChecked = !IsChecked; RaiseEvent(new RoutedEventArgs(IsCheckedChangedEvent)); } - + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { if (change.Property == IsCheckedProperty) diff --git a/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs b/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs index 5540f84b..e7cf5e8c 100644 --- a/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs +++ b/GalaxyBudsClient/Interface/ViewModels/Pages/BatteryHistoryPageViewModel.cs @@ -16,6 +16,7 @@ using ScottPlot.AxisRules; using ScottPlot.Plottables; using ScottPlot.TickGenerators; +using SkiaSharp; namespace GalaxyBudsClient.Interface.ViewModels.Pages; @@ -157,7 +158,9 @@ private async Task UpdatePlotAsync() } overlay?.AddNullFrame(DateTimeOffset.Now.DateTime.ToOADate()); - + var font = SKFontManager.Default.MatchCharacter(Strings.Left[0]).FamilyName; + Plot.Legend.FontName = font; + var plotBatteryL = Plot.Add.Scatter(timestamp, batteryL); plotBatteryL.MarkerShape = MarkerShape.None; plotBatteryL.LineWidth = 2; @@ -181,7 +184,8 @@ private async Task UpdatePlotAsync() { LabelFormatter = value => value is < 0 or > 100 ? string.Empty : NumericAutomatic.DefaultLabelFormatter(value) }; - + + Plot.Font.Set(font); Plot.YLabel(Strings.BattHistYAxis); UpdateLegendVisibility(); diff --git a/GalaxyBudsClient/Utils/Interface/WindowIconRenderer.cs b/GalaxyBudsClient/Utils/Interface/WindowIconRenderer.cs index d7db47b6..e7bd3716 100644 --- a/GalaxyBudsClient/Utils/Interface/WindowIconRenderer.cs +++ b/GalaxyBudsClient/Utils/Interface/WindowIconRenderer.cs @@ -19,22 +19,22 @@ namespace GalaxyBudsClient.Utils.Interface; public static class WindowIconRenderer { private static readonly WindowIcon DefaultIcon = MakeDefaultIcon(); - + public static void UpdateDynamicIcon(IBasicStatusUpdate status) { var trayIcons = TrayIcon.GetIcons(Application.Current!); - if (trayIcons == null) + if (trayIcons == null) return; var batteryLeft = status.BatteryL; var batteryRight = status.BatteryR; - + // Ignore battery level of disconnected earbuds if (batteryLeft <= 0) batteryLeft = batteryRight; if (batteryRight <= 0) batteryRight = batteryLeft; - + int? level = Settings.Data.DynamicTrayIconMode switch { DynamicTrayIconModes.BatteryMin => Math.Min(batteryLeft, batteryLeft), @@ -67,15 +67,15 @@ private static WindowIcon MakeFromBatteryLevel(int level) $"{level}", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, - Typeface.Default, - 210, + Typeface.Default, + 210, Brushes.Black // This brush does not matter since we use the geometry of the text. ); // Build the geometry object that represents the text. var textGeometry = formattedText.BuildGeometry(new Point(0, -30)); var render = new RenderTargetBitmap(new PixelSize(256, 256), new Vector(96, 96)); - + using (var ctx = render.CreateDrawingContext()) { ctx.PushRenderOptions(new RenderOptions @@ -85,11 +85,10 @@ private static WindowIcon MakeFromBatteryLevel(int level) EdgeMode = EdgeMode.Antialias, RequiresFullOpacityHandling = true }); - - var fillColor = PlatformUtils.IsOSX ? Brushes.Black : Brushes.White; - ctx.DrawGeometry(fillColor, new Pen(Brushes.Transparent, 0), textGeometry!); + + ctx.DrawGeometry(new SolidColorBrush(Settings.Data.AccentColor), new Pen(Brushes.Transparent, 0), textGeometry!); } - + return new WindowIcon(render); }