private static void InstallHooks(Theme theme) { Win32ThemeHooks.WindowCreated += Handle_WindowCreated; try { Win32ThemeHooks.InstallHooks(theme, new SystemDialogDetector()); } catch (Exception) { Win32ThemeHooks.Uninstall(); throw; } ResetGdiCaches(); }
private static bool TryInstallHooks(Theme theme) { Win32ThemeHooks.WindowCreated += Handle_WindowCreated; try { Win32ThemeHooks.InstallHooks(theme, new SystemDialogDetector()); } catch (Exception ex) { Trace.WriteLine($"Failed to install Win32 theming hooks: {ex}"); Win32ThemeHooks.Uninstall(); return(false); } ResetGdiCaches(); return(true); }
private static bool TryInitialize() { try { Deployment.DeployThemesToUserDirectory(); } catch (Exception ex) { // non mission-critical, proceed Trace.WriteLine($"Failed to deploy schemes to user directory: {ex}"); } var invariantTheme = Controller.LoadInvariantTheme(); if (invariantTheme == null) { return(false); } if (!Controller.SetInitialTheme(AppSettings.UIThemeName, AppSettings.UseSystemVisualStyle)) { return(false); } ThemeFix.UseSystemVisualStyle = Controller.UseSystemVisualStyleInitial; try { Win32ThemeHooks.InstallHooks(ThemeManager, SystemDialogDetector); } catch (Exception ex) { Trace.WriteLine($"Failed to install Win32 theming hooks: {ex}"); Win32ThemeHooks.Uninstall(); return(false); } Win32ThemeHooks.WindowCreated += Handle_WindowCreated; ColorHelper.SetUITheme(ThemeManager, invariantTheme); return(true); }
public static void Unload() { Win32ThemeHooks.Uninstall(); Win32ThemeHooks.WindowCreated -= Handle_WindowCreated; }