Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Jul 2, 2020
2 parents 84aac3f + 21ba7cc commit 31b0b50
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/ControlzEx/Theming/ThemeManager.cs
Expand Up @@ -1300,9 +1300,8 @@ public void SyncThemeColorSchemeWithWindowsAccentColor(ThemeSyncMode? syncMode,
baseColor ??= detectedTheme?.BaseColorScheme ?? BaseColorLight;
}

var isHighContrast = detectedTheme?.IsHighContrast == true ||
(syncModeToUse.HasFlag(ThemeSyncMode.SyncWithHighContrast)
&& WindowsThemeHelper.IsHighContrastEnabled());
var isHighContrast = syncModeToUse.HasFlag(ThemeSyncMode.SyncWithHighContrast)
&& WindowsThemeHelper.IsHighContrastEnabled();

var accentColorAsString = accentColor.ToString();

Expand Down Expand Up @@ -1336,10 +1335,12 @@ public ThemeSyncMode ThemeSyncMode
// Always remove handler first.
// That way we prevent double registrations.
SystemEvents.UserPreferenceChanged -= this.HandleUserPreferenceChanged;
SystemParameters.StaticPropertyChanged -= this.HandleStaticPropertyChanged;

if (this.themeSyncMode != ThemeSyncMode.DoNotSync)
{
SystemEvents.UserPreferenceChanged += this.HandleUserPreferenceChanged;
SystemParameters.StaticPropertyChanged += this.HandleStaticPropertyChanged;
}
}
}
Expand All @@ -1355,6 +1356,17 @@ private void HandleUserPreferenceChanged(object sender, UserPreferenceChangedEve
}
}

private void HandleStaticPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SystemParameters.HighContrast)
&& this.isSyncScheduled == false)
{
this.isSyncScheduled = true;

Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.SyncTheme(this.ThemeSyncMode)));
}
}

private bool isSyncScheduled;

#endregion WindowsAppModeSetting
Expand Down

0 comments on commit 31b0b50

Please sign in to comment.