plot window refactor

This commit is contained in:
2026-06-01 18:45:00 -05:00
parent 667cb4117f
commit 54a88e1f31
7 changed files with 899 additions and 77 deletions
@@ -4,6 +4,7 @@
using System;
using LibreHardwareMonitor.Windows.WinUI.Services;
using LibreHardwareMonitor.Windows.WinUI.ViewModels;
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
@@ -18,6 +19,7 @@ public sealed class PlotWindow : Window
{
private readonly AppSettings _settings;
private readonly AppWindow _appWindow;
private readonly Grid _root;
private bool _closingFromOwner;
public PlotWindow(AppSettings settings)
@@ -28,14 +30,17 @@ public sealed class PlotWindow : Window
_appWindow = AppWindow.GetFromWindowId(Win32Interop.GetWindowIdFromWindow(hwnd));
_appWindow.Title = "Sensor Plot";
_root = new Grid();
PlotCanvas = new Canvas
{
MinWidth = 320,
MinHeight = 220,
Background = (Brush)Application.Current.Resources["SystemControlBackgroundAltHighBrush"]
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch
};
PlotCanvas.SizeChanged += (_, _) => PlotSizeChanged?.Invoke(this, EventArgs.Empty);
Content = PlotCanvas;
_root.Children.Add(PlotCanvas);
Content = _root;
RestoreBounds();
Closed += PlotWindow_Closed;
@@ -47,6 +52,16 @@ public sealed class PlotWindow : Window
public Canvas PlotCanvas { get; }
public void ApplyTheme(AppThemeMode themeMode)
{
_root.RequestedTheme = themeMode switch
{
AppThemeMode.Light => ElementTheme.Light,
AppThemeMode.Dark or AppThemeMode.Black => ElementTheme.Dark,
_ => ElementTheme.Default
};
}
public void CloseFromOwner()
{
_closingFromOwner = true;