Skip to content

Commit

Permalink
FrmMain: sync dark/light theme with OS #434
Browse files Browse the repository at this point in the history
  • Loading branch information
d2phap committed Feb 24, 2023
1 parent b507988 commit 9390a68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
8 changes: 2 additions & 6 deletions v9/Components/ImageGlass.UI/Forms/ModernForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,8 @@ private async Task TriggerRequestUpdatingColorModeEventAsync(CancellationToken t
await Task.Delay(200, token);
token.ThrowIfCancellationRequested();

var eventArgs = new SystemColorModeChangedEventArgs();
if (DarkMode != eventArgs.IsDarkMode)
{
// emit event here
OnRequestUpdatingColorMode(eventArgs);
}
// emit event here
OnRequestUpdatingColorMode(new SystemColorModeChangedEventArgs());
}
catch (OperationCanceledException) { }
}
Expand Down
18 changes: 12 additions & 6 deletions v9/ImageGlass/FrmMain/FrmMain.Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,19 @@ protected override void OnSystemAccentColorChanged(SystemAccentColorChangedEvent
}


//protected override void OnRequestUpdatingColorMode(SystemColorModeChangedEventArgs e)
//{
// // update theme here
// ApplyTheme(e.IsDarkMode);
protected override void OnRequestUpdatingColorMode(SystemColorModeChangedEventArgs e)
{
// theme mode is changed, need to load the corresponding theme pack
Config.LoadThemePack(e.IsDarkMode, true, true);

// load the theme icons
OnDpiChanged();

// base.OnRequestUpdatingColorMode(e);
//}
// apply theme to controls
ApplyTheme(Config.Theme.Settings.IsDarkMode);

base.OnRequestUpdatingColorMode(e);
}

}

0 comments on commit 9390a68

Please sign in to comment.