From 96ac6a6a124f58aeb7e1ae08c547a59cc7d094d3 Mon Sep 17 00:00:00 2001
From: Laszlo Nemeth <57342539+donlaci@users.noreply.github.com>
Date: Thu, 15 Dec 2022 10:33:17 +0100
Subject: [PATCH] [ColorPicker]Support BGR and RGB decimal value formats
(#22771)
* ColorPicker add both decimal value formats
* ColorPicker, custom format dialog, resizing columns
---
src/common/ManagedCommon/ColorFormatHelper.cs | 7 +++++--
.../Settings.UI/Strings/en-us/Resources.resw | 7 +++++--
.../Settings.UI/Views/ColorPickerPage.xaml | 21 +++++++++++--------
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/common/ManagedCommon/ColorFormatHelper.cs b/src/common/ManagedCommon/ColorFormatHelper.cs
index 1006410678..e68a78b763 100644
--- a/src/common/ManagedCommon/ColorFormatHelper.cs
+++ b/src/common/ManagedCommon/ColorFormatHelper.cs
@@ -285,7 +285,8 @@ namespace ManagedCommon
{ "Xv", 'i' }, // X value int
{ "Yv", 'i' }, // Y value int
{ "Zv", 'i' }, // Z value int
- { "Dv", 'i' }, // Decimal value int
+ { "Dr", 'i' }, // Decimal value (RGB) int
+ { "Dv", 'i' }, // Decimal value (BGR) int
{ "Na", 's' }, // Color name string
};
@@ -447,8 +448,10 @@ namespace ManagedCommon
var (_, _, z) = ConvertToCIEXYZColor(color);
z = Math.Round(z * 100, 4);
return z.ToString(CultureInfo.InvariantCulture);
- case "Dv":
+ case "Dr":
return ((color.R * 65536) + (color.G * 256) + color.B).ToString(CultureInfo.InvariantCulture);
+ case "Dv":
+ return (color.R + (color.G * 256) + (color.B * 65536)).ToString(CultureInfo.InvariantCulture);
case "Na":
return ColorNameHelper.GetColorName(color);
default: return string.Empty;
diff --git a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
index 197fbc47bb..43f6616ea0 100644
--- a/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
+++ b/src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
@@ -1374,8 +1374,11 @@ Made with 💗 by Microsoft and the PowerToys community.
Z value
-
- decimal value
+
+ decimal value (RGB)
+
+
+ decimal value (BGR)
color name
diff --git a/src/settings-ui/Settings.UI/Views/ColorPickerPage.xaml b/src/settings-ui/Settings.UI/Views/ColorPickerPage.xaml
index 4ecc9007be..d77072d265 100644
--- a/src/settings-ui/Settings.UI/Views/ColorPickerPage.xaml
+++ b/src/settings-ui/Settings.UI/Views/ColorPickerPage.xaml
@@ -261,14 +261,15 @@
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -321,9 +322,11 @@
-
-
-
+
+
+
+
+