Skip to content

Commit

Permalink
[ColorPicker] HEX format tweak (#13989)
Browse files Browse the repository at this point in the history
* Added HEX2

* Revert "Added HEX2"

This reverts commit 6d7b23f.

* Lowercase HEX without hash

* Update ColorRepresentationHelper.cs

* Update expect.txt

Co-authored-by: Laute <Niels.Laute@philips.com>
  • Loading branch information
2 people authored and jaimecbernardo committed Oct 27, 2021
1 parent af8366f commit f5bc789
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ finalizer
findfast
findstr
FIXEDFILEINFO
FFAA
FLASHZONES
FLASHZONESONQUICKSWITCH
flt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static string ColorToCMYK(Color color)
/// <param name="color">The see cref="Color"/> for the hexadecimal presentation</param>
/// <returns>A hexadecimal <see cref="string"/> representation of a RGB color</returns>
private static string ColorToHex(Color color)
=> $"#{color.R.ToString("X2", CultureInfo.InvariantCulture)}"
=> $"{color.R.ToString("X2", CultureInfo.InvariantCulture)}"
+ $"{color.G.ToString("X2", CultureInfo.InvariantCulture)}"
+ $"{color.B.ToString("X2", CultureInfo.InvariantCulture)}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ private void SetupAllColorRepresentations()
new ColorFormatModel()
{
FormatName = ColorRepresentationType.HEX.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HEX); },
#pragma warning disable CA1304 // Specify CultureInfo
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HEX).ToLower(); },
#pragma warning restore CA1304 // Specify CultureInfo
});

_allColorRepresentations.Add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ColorRepresentationHelperTest
{
[TestMethod]
[DataRow(ColorRepresentationType.CMYK, "cmyk(0%, 0%, 0%, 100%)")]
[DataRow(ColorRepresentationType.HEX, "#000000")]
[DataRow(ColorRepresentationType.HEX, "000000")]
[DataRow(ColorRepresentationType.NCol, "R0, 0%, 100%")]
[DataRow(ColorRepresentationType.HSB, "hsb(0, 0%, 0%)")]
[DataRow(ColorRepresentationType.HSI, "hsi(0, 0%, 0%)")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ColorPickerViewModel(ISettingsUtils settingsUtils, ISettingsRepository<Ge
SelectableColorRepresentations = new Dictionary<ColorRepresentationType, string>
{
{ ColorRepresentationType.CMYK, "CMYK - cmyk(100%, 50%, 75%, 0%)" },
{ ColorRepresentationType.HEX, "HEX - #FFAA00" },
{ ColorRepresentationType.HEX, "HEX - ffaa00" },
{ ColorRepresentationType.HSB, "HSB - hsb(100, 50%, 75%)" },
{ ColorRepresentationType.HSI, "HSI - hsi(100, 50%, 75%)" },
{ ColorRepresentationType.HSL, "HSL - hsl(100, 50%, 75%)" },
Expand Down Expand Up @@ -199,7 +199,7 @@ private void InitializeColorFormats()
var cielabFormatName = ColorRepresentationType.CIELAB.ToString();
var ciexyzFormatName = ColorRepresentationType.CIEXYZ.ToString();

formatsUnordered.Add(new ColorFormatModel(hexFormatName, "#EF68FF", visibleFormats.ContainsKey(hexFormatName) && visibleFormats[hexFormatName]));
formatsUnordered.Add(new ColorFormatModel(hexFormatName, "ef68ff", visibleFormats.ContainsKey(hexFormatName) && visibleFormats[hexFormatName]));
formatsUnordered.Add(new ColorFormatModel(rgbFormatName, "rgb(239, 104, 255)", visibleFormats.ContainsKey(rgbFormatName) && visibleFormats[rgbFormatName]));
formatsUnordered.Add(new ColorFormatModel(hslFormatName, "hsl(294, 100%, 70%)", visibleFormats.ContainsKey(hslFormatName) && visibleFormats[hslFormatName]));
formatsUnordered.Add(new ColorFormatModel(hsvFormatName, "hsv(294, 59%, 100%)", visibleFormats.ContainsKey(hsvFormatName) && visibleFormats[hsvFormatName]));
Expand Down

0 comments on commit f5bc789

Please sign in to comment.