Adopt Fluent/Mica look for light mode
Replaces WinUI 2 grey brushes with WinUI 3 equivalents and enables the Mica system backdrop on Windows 11. RootGrid is transparent when Mica is active so the material shows through; falls back to ApplicationPageBackgroundThemeBrush on Win10. Sensor header uses LayerFillColorDefaultBrush; plot pane border uses DividerStrokeColorDefaultBrush. Black theme keeps a solid background and disables Mica. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -85,7 +85,7 @@ public sealed partial class MainWindow : Window
|
||||
_columnMeasurer.SettleTriggered += (_, _) => UpdateSensorColumnWidths();
|
||||
|
||||
MeasureStartup("MainWindow.InitializeComponent", InitializeComponent);
|
||||
RootGrid.Background = new SolidColorBrush(Colors.White);
|
||||
TryApplyMicaBackdrop();
|
||||
RootGrid.Loaded += RootGrid_Loaded;
|
||||
RootGrid.LayoutUpdated += RootGrid_LayoutUpdated;
|
||||
Bind(ContentGrid, UIElement.IsHitTestVisibleProperty, ViewModel, nameof(ViewModel.IsHardwareInteractionEnabled));
|
||||
@@ -350,7 +350,7 @@ public sealed partial class MainWindow : Window
|
||||
{
|
||||
Grid header = _columnMeasurer.CreateHeaderGrid();
|
||||
header.Padding = new Thickness(8, 5, 8, 5);
|
||||
header.Background = (Brush)Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"];
|
||||
header.Background = (Brush)Application.Current.Resources["LayerFillColorDefaultBrush"];
|
||||
header.Children.Add(CreateHeaderText("Sensor", 0, Visibility.Visible));
|
||||
header.Children.Add(CreateHeaderText("Value", 1, ViewModel.ValueColumnVisibility, nameof(ViewModel.ValueColumnVisibility)));
|
||||
header.Children.Add(CreateHeaderText("Min", 2, ViewModel.MinColumnVisibility, nameof(ViewModel.MinColumnVisibility)));
|
||||
@@ -798,17 +798,43 @@ public sealed partial class MainWindow : Window
|
||||
_ => ElementTheme.Default
|
||||
};
|
||||
|
||||
RootGrid.Background = ViewModel.ThemeMode switch
|
||||
if (ViewModel.ThemeMode == AppThemeMode.Black)
|
||||
{
|
||||
AppThemeMode.Black => new SolidColorBrush(Colors.Black),
|
||||
AppThemeMode.Dark => new SolidColorBrush(global::Windows.UI.Color.FromArgb(255, 30, 30, 30)),
|
||||
_ => (Brush)Application.Current.Resources["ApplicationPageBackgroundThemeBrush"]
|
||||
};
|
||||
SystemBackdrop = null;
|
||||
RootGrid.Background = new SolidColorBrush(Colors.Black);
|
||||
}
|
||||
else if (SystemBackdrop is MicaBackdrop)
|
||||
{
|
||||
RootGrid.Background = new SolidColorBrush(Colors.Transparent);
|
||||
}
|
||||
else
|
||||
{
|
||||
TryApplyMicaBackdrop();
|
||||
RootGrid.Background = SystemBackdrop is MicaBackdrop
|
||||
? new SolidColorBrush(Colors.Transparent)
|
||||
: (Brush)Application.Current.Resources["ApplicationPageBackgroundThemeBrush"];
|
||||
}
|
||||
|
||||
PlotControl.ApplyTheme(ViewModel.ThemeMode);
|
||||
_secondaryWindows.ApplyTheme(ViewModel.ThemeMode);
|
||||
}
|
||||
|
||||
private void TryApplyMicaBackdrop()
|
||||
{
|
||||
if (SystemBackdrop is MicaBackdrop)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (Microsoft.UI.Composition.SystemBackdrops.MicaController.IsSupported())
|
||||
SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base };
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Mica unavailable (e.g. Win10) — fall back to theme brush in ApplyTheme.
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSensorColumnWidths()
|
||||
{
|
||||
MeasureStartup("MainWindow.UpdateSensorColumnWidths", _columnMeasurer.UpdateWidths, () => FormattableString.Invariant($"rows={_columnMeasurer.RowCount}, cacheEntries={_columnMeasurer.CacheEntryCount}, deviceWidth={_columnMeasurer.DeviceColumnWidth:F0}, settled={_columnMeasurer.IsSettled}"));
|
||||
|
||||
Reference in New Issue
Block a user