You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingSystem.Management;
...
private const stringRegistryKeyPath=@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";privateconststringRegistryValueName="AppsUseLightTheme";privatestaticManagementEventWatcher_managementEventWatcher;privatestaticbool_watcherStarted;
#region System Theme
privatestaticvoidSwitchThemeInternal(Themetheme){varuri=themeswitch{Theme.Light=>newUri(LightRd),Theme.Dark=>newUri(DarkRd),
_ =>newUri(LightRd)};Application.Current.Resources.MergedDictionaries[0].Source=uri;}privatestaticvoidWatchTheme(){varcurrentUser=WindowsIdentity.GetCurrent();varquery=string.Format(CultureInfo.InvariantCulture,@"SELECT * FROM RegistryValueChangeEvent WHERE Hive = 'HKEY_USERS' AND KeyPath = '{0}\\{1}' AND ValueName = '{2}'",currentUser.User.Value,RegistryKeyPath.Replace(@"\",@"\\"),RegistryValueName);try{_managementEventWatcher=newManagementEventWatcher(query);_managementEventWatcher.EventArrived+=(_,_)=>{varnewWindowsTheme=GetWindowsTheme();SwitchThemeInternal(newWindowsTheme);// React to new theme};// Start listening for events_managementEventWatcher.Start();_watcherStarted=true;}catch(Exception){// This can fail on Windows 7}varinitialTheme=GetWindowsTheme();SwitchThemeInternal(initialTheme);}privatestaticThemeGetWindowsTheme(){usingvarkey=Registry.CurrentUser.OpenSubKey(RegistryKeyPath);varregistryValueObject=key?.GetValue(RegistryValueName);if(registryValueObject==null)returnTheme.Light;varregistryValue=(int)registryValueObject;returnregistryValue>0?Theme.Light:Theme.Dark;}
#endregion
Is your feature request related to a problem? Please describe.
目前 WPF 的 GUI 简易调试界面是浅色主题,底色为纯白,这对深夜写代码和习惯暗色的选手不是特别友好。
Describe the solution you'd like
可以考虑增加深色主题,选手可以选择浅色或深色,或跟随操作系统深浅色设置。
Describe alternatives you've considered
不知道 WPF / UWP / WinUI3 / MAUI 都有没有现成的轮子可以用(个人感觉至少后三者是有的)
Additional context
作为未来的饼吧(
The text was updated successfully, but these errors were encountered: