diff --git a/ColorPicker/Classes/ColorInfo.cs b/ColorPicker/Classes/ColorInfo.cs index afa89b6b..83574cca 100644 --- a/ColorPicker/Classes/ColorInfo.cs +++ b/ColorPicker/Classes/ColorInfo.cs @@ -28,7 +28,7 @@ namespace ColorPicker.Classes public class ColorInfo(RGB rgb) { public RGB RGB { get; set; } = rgb; - public HEX HEX { get; set; } = ColorConverter.RgbToHex(rgb); + public HEX HEX { get; set; } = GetHex(rgb); public HSV HSV { get; set; } = ColorConverter.RgbToHsv(rgb); public HSL HSL { get; set; } = ColorConverter.RgbToHsl(rgb); public CMYK CMYK { get; set; } = ColorConverter.RgbToCmyk(rgb); @@ -37,10 +37,8 @@ public class ColorInfo(RGB rgb) public YUV YUV { get; set; } = ColorConverter.RgbToYuv(rgb); public DEC DEC { get; set; } = DEC.FromRgb(rgb); - public override string ToString() - { - return $"{Properties.Resources.RGB}: {RGB.R}{Global.Settings.RgbSeparator}{RGB.G}{Global.Settings.RgbSeparator}{RGB.B}\n" + - $"{Properties.Resources.HEX}: {(HEX.Value.StartsWith("#") ? "" : "#")}{HEX.Value}\n" + + public override string ToString() => $"{Properties.Resources.RGB}: {RGB.R}{Global.Settings.RgbSeparator}{RGB.G}{Global.Settings.RgbSeparator}{RGB.B}\n" + + $"{Properties.Resources.HEX}: {(HEX.Value.StartsWith('#') ? "" : "#")}{((Global.Settings.UseUpperCasesHex ?? false) ? HEX.Value.ToUpper() : HEX.Value.ToLower())}\n" + $"{Properties.Resources.HSV}: {HSV.H},{HSV.S},{HSV.V}\n" + $"{Properties.Resources.HSL}: {HSL.H},{HSL.S},{HSL.L}\n" + $"{Properties.Resources.CMYK}: {CMYK.C},{CMYK.M},{CMYK.Y},{CMYK.K}\n" + @@ -48,6 +46,12 @@ public override string ToString() $"{Properties.Resources.XYZ}: {XYZ.X:0.00}..; {XYZ.Y:0.00}..; {XYZ.Z:0.00}..\n" + $"{Properties.Resources.YIQ}: {YIQ.Y:0.00}..; {YIQ.I:0.00}..; {YIQ.Q:0.00}..\n" + $"{Properties.Resources.YUV}: {YUV.Y:0.00}..; {YUV.U:0.00}..; {YUV.V:0.00}.."; + + private static HEX GetHex(RGB rgb) + { + var hex = ColorConverter.RgbToHex(rgb); + hex.Value = (Global.Settings.UseUpperCasesHex ?? false) ? hex.Value.ToUpper() : hex.Value.ToLower(); + return hex; } } } diff --git a/ColorPicker/Classes/Settings.cs b/ColorPicker/Classes/Settings.cs index 614b1c12..f39fbee9 100644 --- a/ColorPicker/Classes/Settings.cs +++ b/ColorPicker/Classes/Settings.cs @@ -48,6 +48,7 @@ public Settings() Model = "gpt-3.5-turbo"; SupportedModels = ["gpt-3.5-turbo", "gpt-4"]; RgbSeparator = ";"; + UseUpperCasesHex = false; } public Themes Theme { get; set; } @@ -69,5 +70,6 @@ public Settings() public string? Model { get; set; } public string[]? SupportedModels { get; set; } public string? RgbSeparator { get; set; } + public bool? UseUpperCasesHex { get; set; } } } diff --git a/ColorPicker/Pages/SettingsPage.xaml b/ColorPicker/Pages/SettingsPage.xaml index 81a9b4ba..dfd732e9 100644 --- a/ColorPicker/Pages/SettingsPage.xaml +++ b/ColorPicker/Pages/SettingsPage.xaml @@ -391,6 +391,16 @@ TextChanged="RgbSeparatorTxt_TextChanged" /> + - /// Looks up a localized string similar to Background color detail. + /// Looks up a localized string similar to Background color details. /// public static string BackgroundDetails { get { @@ -1851,6 +1851,15 @@ public static string UseKeyboardShortcuts { } } + /// + /// Looks up a localized string similar to Use upper cases for HEX color. + /// + public static string UseUpperCasesHex { + get { + return ResourceManager.GetString("UseUpperCasesHex", resourceCulture); + } + } + /// /// Looks up a localized string similar to Version. /// diff --git a/ColorPicker/Properties/Resources.en-US.resx b/ColorPicker/Properties/Resources.en-US.resx index ac74f669..726cf469 100644 --- a/ColorPicker/Properties/Resources.en-US.resx +++ b/ColorPicker/Properties/Resources.en-US.resx @@ -735,4 +735,7 @@ Background color details + + Use upper cases for HEX color + \ No newline at end of file diff --git a/ColorPicker/Properties/Resources.fr-FR.resx b/ColorPicker/Properties/Resources.fr-FR.resx index de52da44..2dc3311d 100644 --- a/ColorPicker/Properties/Resources.fr-FR.resx +++ b/ColorPicker/Properties/Resources.fr-FR.resx @@ -739,4 +739,7 @@ Détails de la couleur d'arrière-plan + + Utiliser des majuscules pour les couleurs HEX + \ No newline at end of file diff --git a/ColorPicker/Properties/Resources.resx b/ColorPicker/Properties/Resources.resx index baabc8f2..517238ee 100644 --- a/ColorPicker/Properties/Resources.resx +++ b/ColorPicker/Properties/Resources.resx @@ -715,4 +715,7 @@ Background color details + + Use upper cases for HEX color + \ No newline at end of file diff --git a/ColorPicker/Properties/Resources.zh-CN.resx b/ColorPicker/Properties/Resources.zh-CN.resx index 9b07c855..e3e76e7a 100644 --- a/ColorPicker/Properties/Resources.zh-CN.resx +++ b/ColorPicker/Properties/Resources.zh-CN.resx @@ -743,4 +743,7 @@ 背景颜色细节 + + 使用大写字母表示 HEX 颜色 + \ No newline at end of file diff --git a/ColorPicker/UserControls/ColorFrequenceItem.xaml.cs b/ColorPicker/UserControls/ColorFrequenceItem.xaml.cs index d02163ac..dc9b644c 100644 --- a/ColorPicker/UserControls/ColorFrequenceItem.xaml.cs +++ b/ColorPicker/UserControls/ColorFrequenceItem.xaml.cs @@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ using ColorHelper; +using ColorPicker.Classes; using ColorPicker.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -49,7 +50,7 @@ public ColorFrequenceItem(RGB color, int freq) private void InitUI() { ColorBorder.Background = new SolidColorBrush { Color = System.Windows.Media.Color.FromRgb(Color.R, Color.G, Color.B) }; - ColorTxt.Text = $"#{ColorHelper.ColorConverter.RgbToHex(Color).Value}"; + ColorTxt.Text = $"#{((Global.Settings.UseUpperCasesHex ?? false) ? ColorHelper.ColorConverter.RgbToHex(Color).Value.ToUpper() : ColorHelper.ColorConverter.RgbToHex(Color).Value.ToLower())}"; FreqTxt.Text = Freq.ToString(); } diff --git a/ColorPicker/UserControls/ColorItem.xaml.cs b/ColorPicker/UserControls/ColorItem.xaml.cs index 826f9674..eb6a7a86 100644 --- a/ColorPicker/UserControls/ColorItem.xaml.cs +++ b/ColorPicker/UserControls/ColorItem.xaml.cs @@ -41,7 +41,7 @@ public partial class ColorItem : UserControl public ColorItem(string hexColor) { InitializeComponent(); - HexColor = hexColor; + HexColor = (Global.Settings.UseUpperCasesHex ?? false) ? hexColor.ToUpper() : hexColor.ToLower(); ColorInfo = new(ColorHelper.ColorConverter.HexToRgb(new(HexColor))); InitUI();