Skip to content

Commit 194f39f

Browse files
committed
v1.2.2
1 parent 49e33b0 commit 194f39f

25 files changed

+114
-56
lines changed

.vs/quick-color-picker/v16/.suo

12 KB
Binary file not shown.
Binary file not shown.

QuickColorPicker-Setup/QuickColorPicker-Setup.vdproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,15 @@
383383
{
384384
"Name" = "8:Microsoft Visual Studio"
385385
"ProductName" = "8:Quick Color Picker"
386-
"ProductCode" = "8:{B9F52475-2E86-4166-BB34-FF96E1067878}"
387-
"PackageCode" = "8:{D7762BF7-0AF5-447E-8AF8-3FB540142975}"
386+
"ProductCode" = "8:{06C44308-7E70-41D2-913B-E5F1F815F49C}"
387+
"PackageCode" = "8:{9ED5BB0E-CE15-48DA-A73D-572D8C1A4D95}"
388388
"UpgradeCode" = "8:{B447EAAB-B636-490E-8AC4-266A6136D6BF}"
389389
"AspNetVersion" = "8:2.0.50727.0"
390390
"RestartWWWService" = "11:FALSE"
391391
"RemovePreviousVersions" = "11:TRUE"
392392
"DetectNewerInstalledVersion" = "11:TRUE"
393393
"InstallAllUsers" = "11:FALSE"
394-
"ProductVersion" = "8:1.2.1"
394+
"ProductVersion" = "8:1.2.2"
395395
"Manufacturer" = "8:Module Art"
396396
"ARPHELPTELEPHONE" = "8:"
397397
"ARPHELPLINK" = "8:"
@@ -943,7 +943,7 @@
943943
{
944944
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_E929A9F44EE84118A9055D6931B25A82"
945945
{
946-
"SourcePath" = "8:..\\quick-color-picker\\obj\\Debug\\quick-color-picker.exe"
946+
"SourcePath" = "8:..\\quick-color-picker\\obj\\Release\\quick-color-picker.exe"
947947
"TargetName" = "8:"
948948
"Tag" = "8:"
949949
"Folder" = "8:_4E105E1FB7D74141BA826FE0A8CC7FE5"
Binary file not shown.

quick-color-picker/AboutForm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public AboutForm()
3131
licenseLink.LinkColor = linkColor;
3232

3333
okButton.BackColor = ThemeManager.SecondColorDark;
34+
35+
ThemeManager.enableDarkTitlebar(this.Handle, true);
3436
}
3537
}
3638

quick-color-picker/MainForm.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quick-color-picker/MainForm.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ private void applyDarkTheme()
366366
deleteButton.Image = Properties.Resources.white_trash;
367367
formatButton.Image = Properties.Resources.white_format;
368368
aboutButton.Image = Properties.Resources.white_about;
369+
370+
ThemeManager.enableDarkTitlebar(this.Handle, true);
369371
}
370372

371373
private void hslCopyButton_Click(object sender, EventArgs e)
@@ -541,10 +543,18 @@ private void SaveColorList()
541543
{
542544
try
543545
{
544-
string path = "color-list.txt";
545-
FileInfo fi1 = new FileInfo(path);
546+
string appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Quick Color Picker");
547+
DirectoryInfo di = new DirectoryInfo(appDataFolder);
548+
549+
if (!di.Exists)
550+
{
551+
di.Create();
552+
}
553+
554+
string path = Path.Combine(appDataFolder, "color-list.txt");
555+
FileInfo fi = new FileInfo(path);
546556

547-
using (StreamWriter sw = fi1.CreateText())
557+
using (StreamWriter sw = fi.CreateText())
548558
{
549559
string[] linesToWrite = new string[colorList.Items.Count];
550560
for (int i = 0; i < colorList.Items.Count; i++)
@@ -563,7 +573,13 @@ private void LoadColorList()
563573
{
564574
try
565575
{
566-
string[] lines = File.ReadAllLines("color-list.txt");
576+
string path = Path.Combine(
577+
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
578+
"Quick Color Picker",
579+
"color-list.txt"
580+
);
581+
582+
string[] lines = File.ReadAllLines(path);
567583

568584
for (int i = 0; i < lines.Length; i++)
569585
{

quick-color-picker/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ static void Main()
1313
SetProcessDPIAware();
1414
}
1515

16+
ThemeManager.allowDarkModeForApp(true);
17+
1618
Application.EnableVisualStyles();
1719
Application.SetCompatibleTextRenderingDefault(false);
1820
Application.Run(new MainForm());

quick-color-picker/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Resources;
22
using System.Reflection;
3-
using System.Runtime.CompilerServices;
43
using System.Runtime.InteropServices;
54

65
// General Information about an assembly is controlled through the following
@@ -33,6 +32,6 @@
3332
// You can specify all the values or you can default the Build and Revision Numbers
3433
// by using the '*' as shown below:
3534
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("1.2.1")]
37-
[assembly: AssemblyFileVersion("1.2.1")]
35+
[assembly: AssemblyVersion("1.2.2")]
36+
[assembly: AssemblyFileVersion("1.2.2")]
3837
[assembly: NeutralResourcesLanguage("en")]

quick-color-picker/ThemeManager.cs

Lines changed: 77 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,88 @@ namespace quick_color_picker
77
{
88
class ThemeManager
99
{
10-
public static Color MainColorDark = Color.FromArgb(23, 23, 23);
11-
public static Color BackColorDark = Color.FromArgb(37, 37, 37);
12-
public static Color SecondColorDark = Color.FromArgb(56, 56, 56);
10+
public static Color MainColorDark = Color.Black;
11+
public static Color BackColorDark = Color.FromArgb(32, 32, 32);
12+
public static Color SecondColorDark = Color.FromArgb(51, 51, 51);
1313
public static Color AccentColorDark = Color.FromArgb(73, 169, 207);
1414

15+
private enum WindowCompositionAttribute
16+
{
17+
WCA_UNDEFINED = 0,
18+
WCA_NCRENDERING_ENABLED = 1,
19+
WCA_NCRENDERING_POLICY = 2,
20+
WCA_TRANSITIONS_FORCEDISABLED = 3,
21+
WCA_ALLOW_NCPAINT = 4,
22+
WCA_CAPTION_BUTTON_BOUNDS = 5,
23+
WCA_NONCLIENT_RTL_LAYOUT = 6,
24+
WCA_FORCE_ICONIC_REPRESENTATION = 7,
25+
WCA_EXTENDED_FRAME_BOUNDS = 8,
26+
WCA_HAS_ICONIC_BITMAP = 9,
27+
WCA_THEME_ATTRIBUTES = 10,
28+
WCA_NCRENDERING_EXILED = 11,
29+
WCA_NCADORNMENTINFO = 12,
30+
WCA_EXCLUDED_FROM_LIVEPREVIEW = 13,
31+
WCA_VIDEO_OVERLAY_ACTIVE = 14,
32+
WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15,
33+
WCA_DISALLOW_PEEK = 16,
34+
WCA_CLOAK = 17,
35+
WCA_CLOAKED = 18,
36+
WCA_ACCENT_POLICY = 19,
37+
WCA_FREEZE_REPRESENTATION = 20,
38+
WCA_EVER_UNCLOAKED = 21,
39+
WCA_VISUAL_OWNER = 22,
40+
WCA_HOLOGRAPHIC = 23,
41+
WCA_EXCLUDED_FROM_DDA = 24,
42+
WCA_PASSIVEUPDATEMODE = 25,
43+
WCA_USEDARKMODECOLORS = 26,
44+
WCA_LAST = 27
45+
};
46+
47+
private struct WindowCompositionAttribData
48+
{
49+
public WindowCompositionAttribute Attribute;
50+
public IntPtr Data;
51+
public int SizeOfData;
52+
}
53+
1554
[DllImport("uxtheme.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
1655
private static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
1756

57+
[DllImport("uxtheme.dll", EntryPoint = "#133", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
58+
private static extern bool AllowDarkModeForWindow(IntPtr hWnd, bool allow);
59+
60+
[DllImport("uxtheme.dll", EntryPoint = "#135", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
61+
private static extern bool AllowDarkModeForApp(bool allow);
62+
63+
[DllImport("user32.dll")]
64+
private static extern bool SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttribData data);
65+
66+
[DllImport("user32.dll")]
67+
private static extern bool UpdateWindow(IntPtr hWnd);
68+
69+
public static void allowDarkModeForApp(bool dark)
70+
{
71+
AllowDarkModeForApp(dark);
72+
}
73+
74+
public static void enableDarkTitlebar(IntPtr handle, bool dark)
75+
{
76+
AllowDarkModeForWindow(handle, dark);
77+
78+
var sizeOfData = Marshal.SizeOf(dark);
79+
var dataPtr = Marshal.AllocHGlobal(sizeOfData);
80+
81+
var data = new WindowCompositionAttribData
82+
{
83+
Attribute = WindowCompositionAttribute.WCA_USEDARKMODECOLORS,
84+
Data = dataPtr,
85+
SizeOfData = sizeOfData
86+
};
87+
SetWindowCompositionAttribute(handle, ref data);
88+
89+
UpdateWindow(handle);
90+
}
91+
1892
public static void setDarkModeToControl(IntPtr handle)
1993
{
2094
SetWindowTheme(handle, "DarkMode_Explorer", null);
@@ -40,33 +114,5 @@ public static bool isWindows10()
40114
string productName = (string)reg.GetValue("ProductName");
41115
return productName.StartsWith("Windows 10");
42116
}
43-
44-
public static Color getColorizationColor()
45-
{
46-
if (isWindows10())
47-
{
48-
string root = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\DWM";
49-
string colorcode = Registry.GetValue(root, "ColorizationColor", null).ToString();
50-
return System.Drawing.ColorTranslator.FromHtml(colorcode);
51-
}
52-
else
53-
{
54-
return Color.Blue;
55-
}
56-
}
57-
58-
public static Color getAccentColor()
59-
{
60-
if (isWindows10())
61-
{
62-
string root = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\DWM";
63-
string colorcode = Registry.GetValue(root, "AccentColor", null).ToString();
64-
return System.Drawing.ColorTranslator.FromHtml(colorcode);
65-
}
66-
else
67-
{
68-
return Color.White;
69-
}
70-
}
71117
}
72118
}

quick-color-picker/UpdateForm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public UpdateForm(UpdateChecker checker, string appName)
2929
buttonYes.BackColor = ThemeManager.SecondColorDark;
3030
buttonNo.BackColor = ThemeManager.SecondColorDark;
3131
boxReleaseNotes.BackColor = ThemeManager.SecondColorDark;
32+
33+
ThemeManager.enableDarkTitlebar(this.Handle, true);
3234
}
3335
}
3436

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
90, 126, 143
1+
32, 32, 32
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
62, 185, 204
2-
255, 163, 0
3-
255, 74, 0
4-
223, 16, 0
5-
188, 9, 0
6-
96, 35, 25
7-
204, 185, 62
8-
102, 92, 31
9-
224, 162, 153
10-
92, 45, 145
1+
30, 30, 30
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)