Skip to content

Commit

Permalink
correct order + correct docu
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasSekan committed Nov 9, 2020
1 parent 767ce22 commit c4eccb3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,48 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Enumerations
public enum ColorRepresentationType
{
/// <summary>
/// Color presentation as hexadecimal color value without the alpha-value (e.g. #0055FF)
/// Color presentation as CMYK color value (cyan[0%..100%], magenta[0%..100%], yellow[0%..100%], black key[0%..100%])
/// </summary>
HEX = 0,
CMYK = 0,

/// <summary>
/// Color presentation as RGB color value (red[0..255], green[0..255], blue[0..255])
/// Color presentation as hexadecimal color value without the alpha-value (e.g. #0055FF)
/// </summary>
RGB = 1,
HEX = 1,

/// <summary>
/// Color presentation as CMYK color value (cyan[0%..100%], magenta[0%..100%], yellow[0%..100%], black key[0%..100%])
/// Color presentation as HSB color value (hue[0°..360°], saturation[0%..100%], brightness[0%..100%])
/// </summary>
CMYK = 2,
HSB = 2,

/// <summary>
/// Color presentation as HSL color value (hue[0°..360°], saturation[0..100%], lightness[0%..100%])
/// Color presentation as HSI color value (hue[0°..360°], saturation[0%..100%], intensity[0%..100%])
/// </summary>
HSL = 3,
HSI = 3,

/// <summary>
/// Color presentation as HSV color value (hue[0°..360°], saturation[0%..100%], value[0%..100%])
/// Color presentation as HSL color value (hue[0°..360°], saturation[0..100%], lightness[0%..100%])
/// </summary>
HSV = 4,
HSL = 4,

/// <summary>
/// Color presentation as HSB color value (hue[0°..360°], saturation[0%..100%], brightness[0%..100%])
/// Color presentation as HSV color value (hue[0°..360°], saturation[0%..100%], value[0%..100%])
/// </summary>
HSB = 5,
HSV = 5,

/// <summary>
/// Color presentation as HSI color value (hue[0°..360°], saturation[0%..100%], value[0%..100%])
/// Color presentation as HWB color value (hue[0°..360°], whiteness[0%..100%], blackness[0%..100%])
/// </summary>
HSI = 6,
HWB = 6,

/// <summary>
/// Color presentation as HWB color value (hue[0°..360°], whiteness[0%..100%], blackness[0%..100%])
/// Color presentation as natural color (hue, whiteness[0%..100%], blackness[0%..100%])
/// </summary>
HWB = 7,
NCol = 7,

/// <summary>
/// Color presentation as natural color (hue, saturation[0%..100%], value[0%..100%])
/// Color presentation as RGB color value (red[0..255], green[0..255], blue[0..255])
/// </summary>
NCol = 8,
RGB = 8,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
IsEnabled="{Binding IsEnabled}"
HorizontalAlignment="Left"
MinWidth="240">
<ComboBoxItem Content="HEX - #FFAA00"/>
<ComboBoxItem Content="RGB - rgb(100, 50, 75)"/>
<ComboBoxItem Content="CMYK - cmyk(100%, 50%, 75%, 0%)"/>
<ComboBoxItem Content="HSL - hsl(100, 50%, 75%)"/>
<ComboBoxItem Content="HSV - hsv(100, 50%, 75%)"/>
<ComboBoxItem Content="HEX - #FFAA00"/>
<ComboBoxItem Content="HSB - hsb(100, 50%, 75%)"/>
<ComboBoxItem Content="HSI - hsi(100, 50%, 75%)"/>
<ComboBoxItem Content="HSL - hsl(100, 50%, 75%)"/>
<ComboBoxItem Content="HSV - hsv(100, 50%, 75%)"/>
<ComboBoxItem Content="HBW - hbw(100, 50%, 75%)"/>
<ComboBoxItem Content="NCob - 10R, 50%, 75%"/>
<ComboBoxItem Content="NCol - 10R, 50%, 75%"/>
<ComboBoxItem Content="RGB - rgb(100, 50, 75)"/>
</ComboBox>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ internal static string GetStringRepresentation(Color color, ColorRepresentationT
=> colorRepresentationType switch
{
ColorRepresentationType.CMYK => ColorToCYMK(color),
ColorRepresentationType.NCol => ColorToNCol(color),
ColorRepresentationType.HEX => ColorToHex(color),
ColorRepresentationType.HSB => ColorToHSB(color),
ColorRepresentationType.HSI => ColorToHSI(color),
ColorRepresentationType.HSL => ColorToHSL(color),
ColorRepresentationType.HSV => ColorToHSV(color),
ColorRepresentationType.HWB => ColorToHWB(color),
ColorRepresentationType.NCol => ColorToNCol(color),
ColorRepresentationType.RGB => ColorToRGB(color),

// Fall-back value, when "_userSettings.CopiedColorRepresentation.Value" is incorrect
Expand All @@ -57,23 +57,6 @@ private static string ColorToCYMK(Color color)
+ $", {blackKey.ToString(CultureInfo.InvariantCulture)}%)";
}

/// <summary>
/// Return a <see cref="string"/> representation of a natural color
/// </summary>
/// <param name="color">The <see cref="Color"/> for the natural color presentation</param>
/// <returns>A <see cref="string"/> representation of a natural color</returns>
private static string ColorToNCol(Color color)
{
var (hue, whiteness, blackness) = ColorHelper.ConvertToNaturalColor(color);

whiteness = Math.Round(whiteness * 100);
blackness = Math.Round(blackness * 100);

return $"{hue}"
+ $", {whiteness.ToString(CultureInfo.InvariantCulture)}%"
+ $", {blackness.ToString(CultureInfo.InvariantCulture)}%";
}

/// <summary>
/// Return a hexadecimal <see cref="string"/> representation of a RGB color
/// </summary>
Expand Down Expand Up @@ -176,6 +159,23 @@ private static string ColorToHWB(Color color)
+ $", {blackness.ToString(CultureInfo.InvariantCulture)}%)";
}

/// <summary>
/// Return a <see cref="string"/> representation of a natural color
/// </summary>
/// <param name="color">The <see cref="Color"/> for the natural color presentation</param>
/// <returns>A <see cref="string"/> representation of a natural color</returns>
private static string ColorToNCol(Color color)
{
var (hue, whiteness, blackness) = ColorHelper.ConvertToNaturalColor(color);

whiteness = Math.Round(whiteness * 100);
blackness = Math.Round(blackness * 100);

return $"{hue}"
+ $", {whiteness.ToString(CultureInfo.InvariantCulture)}%"
+ $", {blackness.ToString(CultureInfo.InvariantCulture)}%";
}

/// <summary>
/// Return a <see cref="string"/> representation of a RGB color
/// </summary>
Expand Down

0 comments on commit c4eccb3

Please sign in to comment.