Jake Volynko 5 years ago
parent
commit
194f39f98c
25 changed files with 114 additions and 56 deletions
  1. BIN
      .vs/quick-color-picker/v16/.suo
  2. BIN
      .vs/quick-color-picker/v16/Server/sqlite3/storage.ide
  3. 4 4
      QuickColorPicker-Setup/QuickColorPicker-Setup.vdproj
  4. BIN
      QuickColorPicker-Setup/Release/QuickColorPicker-Setup.msi
  5. 2 0
      quick-color-picker/AboutForm.cs
  6. 3 3
      quick-color-picker/MainForm.Designer.cs
  7. 20 4
      quick-color-picker/MainForm.cs
  8. 2 0
      quick-color-picker/Program.cs
  9. 2 3
      quick-color-picker/Properties/AssemblyInfo.cs
  10. 77 31
      quick-color-picker/ThemeManager.cs
  11. 2 0
      quick-color-picker/UpdateForm.cs
  12. 1 1
      quick-color-picker/bin/Debug/color-list.txt
  13. BIN
      quick-color-picker/bin/Debug/quick-color-picker.exe
  14. BIN
      quick-color-picker/bin/Debug/quick-color-picker.pdb
  15. 1 10
      quick-color-picker/bin/Release/color-list.txt
  16. BIN
      quick-color-picker/bin/Release/quick-color-picker.exe
  17. BIN
      quick-color-picker/bin/Release/quick-color-picker.pdb
  18. BIN
      quick-color-picker/obj/Debug/quick-color-picker.csproj.GenerateResource.cache
  19. BIN
      quick-color-picker/obj/Debug/quick-color-picker.csprojAssemblyReference.cache
  20. BIN
      quick-color-picker/obj/Debug/quick-color-picker.exe
  21. BIN
      quick-color-picker/obj/Debug/quick-color-picker.pdb
  22. BIN
      quick-color-picker/obj/Release/quick-color-picker.csproj.GenerateResource.cache
  23. BIN
      quick-color-picker/obj/Release/quick-color-picker.csprojAssemblyReference.cache
  24. BIN
      quick-color-picker/obj/Release/quick-color-picker.exe
  25. BIN
      quick-color-picker/obj/Release/quick-color-picker.pdb

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


BIN
.vs/quick-color-picker/v16/Server/sqlite3/storage.ide


+ 4 - 4
QuickColorPicker-Setup/QuickColorPicker-Setup.vdproj

@@ -383,15 +383,15 @@
         {
         "Name" = "8:Microsoft Visual Studio"
         "ProductName" = "8:Quick Color Picker"
-        "ProductCode" = "8:{B9F52475-2E86-4166-BB34-FF96E1067878}"
-        "PackageCode" = "8:{D7762BF7-0AF5-447E-8AF8-3FB540142975}"
+        "ProductCode" = "8:{06C44308-7E70-41D2-913B-E5F1F815F49C}"
+        "PackageCode" = "8:{9ED5BB0E-CE15-48DA-A73D-572D8C1A4D95}"
         "UpgradeCode" = "8:{B447EAAB-B636-490E-8AC4-266A6136D6BF}"
         "AspNetVersion" = "8:2.0.50727.0"
         "RestartWWWService" = "11:FALSE"
         "RemovePreviousVersions" = "11:TRUE"
         "DetectNewerInstalledVersion" = "11:TRUE"
         "InstallAllUsers" = "11:FALSE"
-        "ProductVersion" = "8:1.2.1"
+        "ProductVersion" = "8:1.2.2"
         "Manufacturer" = "8:Module Art"
         "ARPHELPTELEPHONE" = "8:"
         "ARPHELPLINK" = "8:"
@@ -943,7 +943,7 @@
         {
             "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_E929A9F44EE84118A9055D6931B25A82"
             {
-            "SourcePath" = "8:..\\quick-color-picker\\obj\\Debug\\quick-color-picker.exe"
+            "SourcePath" = "8:..\\quick-color-picker\\obj\\Release\\quick-color-picker.exe"
             "TargetName" = "8:"
             "Tag" = "8:"
             "Folder" = "8:_4E105E1FB7D74141BA826FE0A8CC7FE5"

BIN
QuickColorPicker-Setup/Release/QuickColorPicker-Setup.msi


+ 2 - 0
quick-color-picker/AboutForm.cs

@@ -31,6 +31,8 @@ namespace quick_color_picker
 				licenseLink.LinkColor = linkColor;
 
 				okButton.BackColor = ThemeManager.SecondColorDark;
+
+				ThemeManager.enableDarkTitlebar(this.Handle, true);
 			}
 		}
 

+ 3 - 3
quick-color-picker/MainForm.Designer.cs

@@ -167,7 +167,7 @@
 			this.colorList.Location = new System.Drawing.Point(325, 41);
 			this.colorList.Margin = new System.Windows.Forms.Padding(0);
 			this.colorList.Name = "colorList";
-			this.colorList.Size = new System.Drawing.Size(130, 257);
+			this.colorList.Size = new System.Drawing.Size(135, 257);
 			this.colorList.TabIndex = 1;
 			this.colorList.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.colorList_DrawItem);
 			this.colorList.SelectedIndexChanged += new System.EventHandler(this.colorList_SelectedIndexChanged);
@@ -266,7 +266,7 @@
 			this.toolStrip1.Name = "toolStrip1";
 			this.toolStrip1.Padding = new System.Windows.Forms.Padding(5);
 			this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
-			this.toolStrip1.Size = new System.Drawing.Size(144, 35);
+			this.toolStrip1.Size = new System.Drawing.Size(149, 35);
 			this.toolStrip1.TabIndex = 24;
 			this.toolStrip1.Text = "toolStrip1";
 			// 
@@ -547,7 +547,7 @@
 			// 
 			this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
 			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
-			this.ClientSize = new System.Drawing.Size(464, 307);
+			this.ClientSize = new System.Drawing.Size(469, 307);
 			this.Controls.Add(this.ratioPanel);
 			this.Controls.Add(this.hsvCopyButton);
 			this.Controls.Add(this.hsvTextBox);

+ 20 - 4
quick-color-picker/MainForm.cs

@@ -366,6 +366,8 @@ namespace quick_color_picker
 			deleteButton.Image = Properties.Resources.white_trash;
 			formatButton.Image = Properties.Resources.white_format;
 			aboutButton.Image = Properties.Resources.white_about;
+
+			ThemeManager.enableDarkTitlebar(this.Handle, true);
 		}
 
 		private void hslCopyButton_Click(object sender, EventArgs e)
@@ -541,10 +543,18 @@ namespace quick_color_picker
 		{
 			try
 			{
-				string path = "color-list.txt";
-				FileInfo fi1 = new FileInfo(path);
+				string appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Quick Color Picker");
+				DirectoryInfo di = new DirectoryInfo(appDataFolder);
+
+				if (!di.Exists)
+				{
+					di.Create();
+				}
+
+				string path = Path.Combine(appDataFolder, "color-list.txt");
+				FileInfo fi = new FileInfo(path);
 
-				using (StreamWriter sw = fi1.CreateText())
+				using (StreamWriter sw = fi.CreateText())
 				{
 					string[] linesToWrite = new string[colorList.Items.Count];
 					for (int i = 0; i < colorList.Items.Count; i++)
@@ -563,7 +573,13 @@ namespace quick_color_picker
 		{
 			try
 			{
-				string[] lines = File.ReadAllLines("color-list.txt");
+				string path = Path.Combine(
+					Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 
+					"Quick Color Picker",
+					"color-list.txt"
+				);
+
+				string[] lines = File.ReadAllLines(path);
 
 				for (int i = 0; i < lines.Length; i++)
 				{

+ 2 - 0
quick-color-picker/Program.cs

@@ -13,6 +13,8 @@ namespace quick_color_picker
 				SetProcessDPIAware();
 			}
 
+			ThemeManager.allowDarkModeForApp(true);
+
 			Application.EnableVisualStyles();
 			Application.SetCompatibleTextRenderingDefault(false);
 			Application.Run(new MainForm());

+ 2 - 3
quick-color-picker/Properties/AssemblyInfo.cs

@@ -1,6 +1,5 @@
 using System.Resources;
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // General Information about an assembly is controlled through the following
@@ -33,6 +32,6 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.1")]
-[assembly: AssemblyFileVersion("1.2.1")]
+[assembly: AssemblyVersion("1.2.2")]
+[assembly: AssemblyFileVersion("1.2.2")]
 [assembly: NeutralResourcesLanguage("en")]

+ 77 - 31
quick-color-picker/ThemeManager.cs

@@ -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;
-			}
-		}
 	}
 }

+ 2 - 0
quick-color-picker/UpdateForm.cs

@@ -29,6 +29,8 @@ namespace quick_color_picker
 				buttonYes.BackColor = ThemeManager.SecondColorDark;
 				buttonNo.BackColor = ThemeManager.SecondColorDark;
 				boxReleaseNotes.BackColor = ThemeManager.SecondColorDark;
+
+				ThemeManager.enableDarkTitlebar(this.Handle, true);
 			}
 		}
 

+ 1 - 1
quick-color-picker/bin/Debug/color-list.txt

@@ -1 +1 @@
-90, 126, 143
+32, 32, 32

BIN
quick-color-picker/bin/Debug/quick-color-picker.exe


BIN
quick-color-picker/bin/Debug/quick-color-picker.pdb


+ 1 - 10
quick-color-picker/bin/Release/color-list.txt

@@ -1,10 +1 @@
-62, 185, 204
-255, 163, 0
-255, 74, 0
-223, 16, 0
-188, 9, 0
-96, 35, 25
-204, 185, 62
-102, 92, 31
-224, 162, 153
-92, 45, 145
+30, 30, 30

BIN
quick-color-picker/bin/Release/quick-color-picker.exe


BIN
quick-color-picker/bin/Release/quick-color-picker.pdb


BIN
quick-color-picker/obj/Debug/quick-color-picker.csproj.GenerateResource.cache


BIN
quick-color-picker/obj/Debug/quick-color-picker.csprojAssemblyReference.cache


BIN
quick-color-picker/obj/Debug/quick-color-picker.exe


BIN
quick-color-picker/obj/Debug/quick-color-picker.pdb


BIN
quick-color-picker/obj/Release/quick-color-picker.csproj.GenerateResource.cache


BIN
quick-color-picker/obj/Release/quick-color-picker.csprojAssemblyReference.cache


BIN
quick-color-picker/obj/Release/quick-color-picker.exe


BIN
quick-color-picker/obj/Release/quick-color-picker.pdb