|
@@ -7,14 +7,88 @@ namespace quick_color_picker
|
|
|
{
|
|
|
class ThemeManager
|
|
|
{
|
|
|
- public static Color MainColorDark = Color.FromArgb(23, 23, 23);
|
|
|
- public static Color BackColorDark = Color.FromArgb(37, 37, 37);
|
|
|
- public static Color SecondColorDark = Color.FromArgb(56, 56, 56);
|
|
|
+ public static Color MainColorDark = Color.Black;
|
|
|
+ public static Color BackColorDark = Color.FromArgb(32, 32, 32);
|
|
|
+ public static Color SecondColorDark = Color.FromArgb(51, 51, 51);
|
|
|
public static Color AccentColorDark = Color.FromArgb(73, 169, 207);
|
|
|
|
|
|
+ private enum WindowCompositionAttribute
|
|
|
+ {
|
|
|
+ WCA_UNDEFINED = 0,
|
|
|
+ WCA_NCRENDERING_ENABLED = 1,
|
|
|
+ WCA_NCRENDERING_POLICY = 2,
|
|
|
+ WCA_TRANSITIONS_FORCEDISABLED = 3,
|
|
|
+ WCA_ALLOW_NCPAINT = 4,
|
|
|
+ WCA_CAPTION_BUTTON_BOUNDS = 5,
|
|
|
+ WCA_NONCLIENT_RTL_LAYOUT = 6,
|
|
|
+ WCA_FORCE_ICONIC_REPRESENTATION = 7,
|
|
|
+ WCA_EXTENDED_FRAME_BOUNDS = 8,
|
|
|
+ WCA_HAS_ICONIC_BITMAP = 9,
|
|
|
+ WCA_THEME_ATTRIBUTES = 10,
|
|
|
+ WCA_NCRENDERING_EXILED = 11,
|
|
|
+ WCA_NCADORNMENTINFO = 12,
|
|
|
+ WCA_EXCLUDED_FROM_LIVEPREVIEW = 13,
|
|
|
+ WCA_VIDEO_OVERLAY_ACTIVE = 14,
|
|
|
+ WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15,
|
|
|
+ WCA_DISALLOW_PEEK = 16,
|
|
|
+ WCA_CLOAK = 17,
|
|
|
+ WCA_CLOAKED = 18,
|
|
|
+ WCA_ACCENT_POLICY = 19,
|
|
|
+ WCA_FREEZE_REPRESENTATION = 20,
|
|
|
+ WCA_EVER_UNCLOAKED = 21,
|
|
|
+ WCA_VISUAL_OWNER = 22,
|
|
|
+ WCA_HOLOGRAPHIC = 23,
|
|
|
+ WCA_EXCLUDED_FROM_DDA = 24,
|
|
|
+ WCA_PASSIVEUPDATEMODE = 25,
|
|
|
+ WCA_USEDARKMODECOLORS = 26,
|
|
|
+ WCA_LAST = 27
|
|
|
+ };
|
|
|
+
|
|
|
+ private struct WindowCompositionAttribData
|
|
|
+ {
|
|
|
+ public WindowCompositionAttribute Attribute;
|
|
|
+ public IntPtr Data;
|
|
|
+ public int SizeOfData;
|
|
|
+ }
|
|
|
+
|
|
|
[DllImport("uxtheme.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
private static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
|
|
|
|
|
|
+ [DllImport("uxtheme.dll", EntryPoint = "#133", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
|
|
+ private static extern bool AllowDarkModeForWindow(IntPtr hWnd, bool allow);
|
|
|
+
|
|
|
+ [DllImport("uxtheme.dll", EntryPoint = "#135", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
|
|
|
+ private static extern bool AllowDarkModeForApp(bool allow);
|
|
|
+
|
|
|
+ [DllImport("user32.dll")]
|
|
|
+ private static extern bool SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttribData data);
|
|
|
+
|
|
|
+ [DllImport("user32.dll")]
|
|
|
+ private static extern bool UpdateWindow(IntPtr hWnd);
|
|
|
+
|
|
|
+ public static void allowDarkModeForApp(bool dark)
|
|
|
+ {
|
|
|
+ AllowDarkModeForApp(dark);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void enableDarkTitlebar(IntPtr handle, bool dark)
|
|
|
+ {
|
|
|
+ AllowDarkModeForWindow(handle, dark);
|
|
|
+
|
|
|
+ var sizeOfData = Marshal.SizeOf(dark);
|
|
|
+ var dataPtr = Marshal.AllocHGlobal(sizeOfData);
|
|
|
+
|
|
|
+ var data = new WindowCompositionAttribData
|
|
|
+ {
|
|
|
+ Attribute = WindowCompositionAttribute.WCA_USEDARKMODECOLORS,
|
|
|
+ Data = dataPtr,
|
|
|
+ SizeOfData = sizeOfData
|
|
|
+ };
|
|
|
+ SetWindowCompositionAttribute(handle, ref data);
|
|
|
+
|
|
|
+ UpdateWindow(handle);
|
|
|
+ }
|
|
|
+
|
|
|
public static void setDarkModeToControl(IntPtr handle)
|
|
|
{
|
|
|
SetWindowTheme(handle, "DarkMode_Explorer", null);
|
|
@@ -40,33 +114,5 @@ namespace quick_color_picker
|
|
|
string productName = (string)reg.GetValue("ProductName");
|
|
|
return productName.StartsWith("Windows 10");
|
|
|
}
|
|
|
-
|
|
|
- public static Color getColorizationColor()
|
|
|
- {
|
|
|
- if (isWindows10())
|
|
|
- {
|
|
|
- string root = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\DWM";
|
|
|
- string colorcode = Registry.GetValue(root, "ColorizationColor", null).ToString();
|
|
|
- return System.Drawing.ColorTranslator.FromHtml(colorcode);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return Color.Blue;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static Color getAccentColor()
|
|
|
- {
|
|
|
- if (isWindows10())
|
|
|
- {
|
|
|
- string root = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\DWM";
|
|
|
- string colorcode = Registry.GetValue(root, "AccentColor", null).ToString();
|
|
|
- return System.Drawing.ColorTranslator.FromHtml(colorcode);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return Color.White;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|