Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.UI;
using Microsoft.UI.Composition;
using System;
using Windows.UI.ViewManagement;
using Microsoft.UI.System;

namespace WinUIGallery.SamplePages;

Expand Down Expand Up @@ -124,7 +126,8 @@ bool TrySetMicaBackdrop(bool useMicaAlt)
if (MicaController.IsSupported())
{
// Hooking up the policy object.
configurationSource = new SystemBackdropConfiguration();
configurationSource = new SystemBackdropConfiguration();
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
Comment on lines +129 to +130
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic to set 'IsHighContrast' is duplicated between this line and line 207. Consider extracting this operation into a helper method to improve maintainability.

Suggested change
configurationSource = new SystemBackdropConfiguration();
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
configurationSource = new SystemBackdropConfiguration();
configurationSource.IsHighContrast = GetIsHighContrast();

Copilot uses AI. Check for mistakes.
Activated += Window_Activated;
Closed += Window_Closed;
((FrameworkElement)Content).ActualThemeChanged += Window_ThemeChanged;
Expand Down Expand Up @@ -200,6 +203,7 @@ private void Window_ThemeChanged(FrameworkElement sender, object args)

private void SetConfigurationSourceTheme()
{
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
configurationSource.Theme = (SystemBackdropTheme)((FrameworkElement)Content).ActualTheme;
}

Comment on lines +206 to 209
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repeated setting of 'IsHighContrast' here mirrors the logic at line 130. Extracting a dedicated method for this logic could reduce duplication and ease future updates.

Suggested change
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
configurationSource.Theme = (SystemBackdropTheme)((FrameworkElement)Content).ActualTheme;
}
UpdateIsHighContrast();
configurationSource.Theme = (SystemBackdropTheme)((FrameworkElement)Content).ActualTheme;
}
private void UpdateIsHighContrast()
{
if (configurationSource != null)
{
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
}
}

Copilot uses AI. Check for mistakes.
Expand Down