Skip to content

Commit

Permalink
Optimize KnownColor value lookup via a combined color table (dotnet#5…
Browse files Browse the repository at this point in the history
…0489)

* Optimize KnownColor value lookup via a combined color table
L2 authored Apr 14, 2021
1 parent c7596ea commit 5f95440
Showing 3 changed files with 508 additions and 125 deletions.
444 changes: 320 additions & 124 deletions src/libraries/Common/src/System/Drawing/KnownColorTable.cs
Original file line number Diff line number Diff line change
@@ -7,11 +7,73 @@ namespace System.Drawing
{
internal static class KnownColorTable
{
// All non system colors (in order of definition in the KnownColor enum).
private static readonly uint[] s_colorTable = new uint[]
{
// First contiguous set.
public const byte KnownColorKindSystem = 0;
public const byte KnownColorKindWeb = 1;
public const byte KnownColorKindUnknown = 2;

// All known color values (in order of definition in the KnownColor enum).
public static readonly uint[] s_colorValueTable = new uint[]
{
// "not a known color"
0,
// "System" colors, Part 1
#if FEATURE_WINDOWS_SYSTEM_COLORS
(uint)(byte)Interop.User32.Win32SystemColors.ActiveBorder,
(uint)(byte)Interop.User32.Win32SystemColors.ActiveCaption,
(uint)(byte)Interop.User32.Win32SystemColors.ActiveCaptionText,
(uint)(byte)Interop.User32.Win32SystemColors.AppWorkspace,
(uint)(byte)Interop.User32.Win32SystemColors.Control,
(uint)(byte)Interop.User32.Win32SystemColors.ControlDark,
(uint)(byte)Interop.User32.Win32SystemColors.ControlDarkDark,
(uint)(byte)Interop.User32.Win32SystemColors.ControlLight,
(uint)(byte)Interop.User32.Win32SystemColors.ControlLightLight,
(uint)(byte)Interop.User32.Win32SystemColors.ControlText,
(uint)(byte)Interop.User32.Win32SystemColors.Desktop,
(uint)(byte)Interop.User32.Win32SystemColors.GrayText,
(uint)(byte)Interop.User32.Win32SystemColors.Highlight,
(uint)(byte)Interop.User32.Win32SystemColors.HighlightText,
(uint)(byte)Interop.User32.Win32SystemColors.HotTrack,
(uint)(byte)Interop.User32.Win32SystemColors.InactiveBorder,
(uint)(byte)Interop.User32.Win32SystemColors.InactiveCaption,
(uint)(byte)Interop.User32.Win32SystemColors.InactiveCaptionText,
(uint)(byte)Interop.User32.Win32SystemColors.Info,
(uint)(byte)Interop.User32.Win32SystemColors.InfoText,
(uint)(byte)Interop.User32.Win32SystemColors.Menu,
(uint)(byte)Interop.User32.Win32SystemColors.MenuText,
(uint)(byte)Interop.User32.Win32SystemColors.ScrollBar,
(uint)(byte)Interop.User32.Win32SystemColors.Window,
(uint)(byte)Interop.User32.Win32SystemColors.WindowFrame,
(uint)(byte)Interop.User32.Win32SystemColors.WindowText,
#else
// Hard-coded constants, based on default Windows settings.
0xFFD4D0C8, // ActiveBorder
0xFF0054E3, // ActiveCaption
0xFFFFFFFF, // ActiveCaptionText
0xFF808080, // AppWorkspace
0xFFECE9D8, // Control
0xFFACA899, // ControlDark
0xFF716F64, // ControlDarkDark
0xFFF1EFE2, // ControlLight
0xFFFFFFFF, // ControlLightLight
0xFF000000, // ControlText
0xFF004E98, // Desktop
0xFFACA899, // GrayText
0xFF316AC5, // Highlight
0xFFFFFFFF, // HighlightText
0xFF000080, // HotTrack
0xFFD4D0C8, // InactiveBorder
0xFF7A96DF, // InactiveCaption
0xFFD8E4F8, // InactiveCaptionText
0xFFFFFFE1, // Info
0xFF000000, // InfoText
0xFFFFFFFF, // Menu
0xFF000000, // MenuText
0xFFD4D0C8, // ScrollBar
0xFFFFFFFF, // Window
0xFF000000, // WindowFrame
0xFF000000, // WindowText
#endif
// "Web" Colors, Part 1
0x00FFFFFF, // Transparent
0xFFF0F8FF, // AliceBlue
0xFFFAEBD7, // AntiqueWhite
@@ -153,30 +215,264 @@ internal static class KnownColorTable
0xFFF5F5F5, // WhiteSmoke
0xFFFFFF00, // Yellow
0xFF9ACD32, // YellowGreen

// Second contiguous set.

#if FEATURE_WINDOWS_SYSTEM_COLORS
// "System" colors, Part 2
(uint)(byte)Interop.User32.Win32SystemColors.ButtonFace,
(uint)(byte)Interop.User32.Win32SystemColors.ButtonHighlight,
(uint)(byte)Interop.User32.Win32SystemColors.ButtonShadow,
(uint)(byte)Interop.User32.Win32SystemColors.GradientActiveCaption,
(uint)(byte)Interop.User32.Win32SystemColors.GradientInactiveCaption,
(uint)(byte)Interop.User32.Win32SystemColors.MenuBar,
(uint)(byte)Interop.User32.Win32SystemColors.MenuHighlight,
#else
0xFFF0F0F0, // ButtonFace
0xFFFFFFFF, // ButtonHighlight
0xFFA0A0A0, // ButtonShadow
0xFFB9D1EA, // GradientActiveCaption
0xFFD7E4F2, // GradientInactiveCaption
0xFFF0F0F0, // MenuBar
0xFF3399FF, // MenuHighlight
#endif
// "Web" colors, Part 2
0xFF663399, // RebeccaPurple
};

// All known color kinds (in order of definition in the KnownColor enum).
public static readonly byte[] s_colorKindTable = new byte[]
{
// "not a known color"
KnownColorKindUnknown,
// "System" colors, Part 1
#if FEATURE_WINDOWS_SYSTEM_COLORS
KnownColorKindSystem, // ActiveBorder
KnownColorKindSystem, // ActiveCaption
KnownColorKindSystem, // ActiveCaptionText
KnownColorKindSystem, // AppWorkspace
KnownColorKindSystem, // Control
KnownColorKindSystem, // ControlDark
KnownColorKindSystem, // ControlDarkDark
KnownColorKindSystem, // ControlLight
KnownColorKindSystem, // ControlLightLight
KnownColorKindSystem, // ControlText
KnownColorKindSystem, // Desktop
KnownColorKindSystem, // GrayText
KnownColorKindSystem, // Highlight
KnownColorKindSystem, // HighlightText
KnownColorKindSystem, // HotTrack
KnownColorKindSystem, // InactiveBorder
KnownColorKindSystem, // InactiveCaption
KnownColorKindSystem, // InactiveCaptionText
KnownColorKindSystem, // Info
KnownColorKindSystem, // InfoText
KnownColorKindSystem, // Menu
KnownColorKindSystem, // MenuText
KnownColorKindSystem, // ScrollBar
KnownColorKindSystem, // Window
KnownColorKindSystem, // WindowFrame
KnownColorKindSystem, // WindowText
#else
// Hard-coded constants, based on default Windows settings.
KnownColorKindSystem, // ActiveBorder
KnownColorKindSystem, // ActiveCaption
KnownColorKindSystem, // ActiveCaptionText
KnownColorKindSystem, // AppWorkspace
KnownColorKindSystem, // Control
KnownColorKindSystem, // ControlDark
KnownColorKindSystem, // ControlDarkDark
KnownColorKindSystem, // ControlLight
KnownColorKindSystem, // ControlLightLight
KnownColorKindSystem, // ControlText
KnownColorKindSystem, // Desktop
KnownColorKindSystem, // GrayText
KnownColorKindSystem, // Highlight
KnownColorKindSystem, // HighlightText
KnownColorKindSystem, // HotTrack
KnownColorKindSystem, // InactiveBorder
KnownColorKindSystem, // InactiveCaption
KnownColorKindSystem, // InactiveCaptionText
KnownColorKindSystem, // Info
KnownColorKindSystem, // InfoText
KnownColorKindSystem, // Menu
KnownColorKindSystem, // MenuText
KnownColorKindSystem, // ScrollBar
KnownColorKindSystem, // Window
KnownColorKindSystem, // WindowFrame
KnownColorKindSystem, // WindowText
#endif
// "Web" Colors, Part 1
KnownColorKindWeb, // Transparent
KnownColorKindWeb, // AliceBlue
KnownColorKindWeb, // AntiqueWhite
KnownColorKindWeb, // Aqua
KnownColorKindWeb, // Aquamarine
KnownColorKindWeb, // Azure
KnownColorKindWeb, // Beige
KnownColorKindWeb, // Bisque
KnownColorKindWeb, // Black
KnownColorKindWeb, // BlanchedAlmond
KnownColorKindWeb, // Blue
KnownColorKindWeb, // BlueViolet
KnownColorKindWeb, // Brown
KnownColorKindWeb, // BurlyWood
KnownColorKindWeb, // CadetBlue
KnownColorKindWeb, // Chartreuse
KnownColorKindWeb, // Chocolate
KnownColorKindWeb, // Coral
KnownColorKindWeb, // CornflowerBlue
KnownColorKindWeb, // Cornsilk
KnownColorKindWeb, // Crimson
KnownColorKindWeb, // Cyan
KnownColorKindWeb, // DarkBlue
KnownColorKindWeb, // DarkCyan
KnownColorKindWeb, // DarkGoldenrod
KnownColorKindWeb, // DarkGray
KnownColorKindWeb, // DarkGreen
KnownColorKindWeb, // DarkKhaki
KnownColorKindWeb, // DarkMagenta
KnownColorKindWeb, // DarkOliveGreen
KnownColorKindWeb, // DarkOrange
KnownColorKindWeb, // DarkOrchid
KnownColorKindWeb, // DarkRed
KnownColorKindWeb, // DarkSalmon
KnownColorKindWeb, // DarkSeaGreen
KnownColorKindWeb, // DarkSlateBlue
KnownColorKindWeb, // DarkSlateGray
KnownColorKindWeb, // DarkTurquoise
KnownColorKindWeb, // DarkViolet
KnownColorKindWeb, // DeepPink
KnownColorKindWeb, // DeepSkyBlue
KnownColorKindWeb, // DimGray
KnownColorKindWeb, // DodgerBlue
KnownColorKindWeb, // Firebrick
KnownColorKindWeb, // FloralWhite
KnownColorKindWeb, // ForestGreen
KnownColorKindWeb, // Fuchsia
KnownColorKindWeb, // Gainsboro
KnownColorKindWeb, // GhostWhite
KnownColorKindWeb, // Gold
KnownColorKindWeb, // Goldenrod
KnownColorKindWeb, // Gray
KnownColorKindWeb, // Green
KnownColorKindWeb, // GreenYellow
KnownColorKindWeb, // Honeydew
KnownColorKindWeb, // HotPink
KnownColorKindWeb, // IndianRed
KnownColorKindWeb, // Indigo
KnownColorKindWeb, // Ivory
KnownColorKindWeb, // Khaki
KnownColorKindWeb, // Lavender
KnownColorKindWeb, // LavenderBlush
KnownColorKindWeb, // LawnGreen
KnownColorKindWeb, // LemonChiffon
KnownColorKindWeb, // LightBlue
KnownColorKindWeb, // LightCoral
KnownColorKindWeb, // LightCyan
KnownColorKindWeb, // LightGoldenrodYellow
KnownColorKindWeb, // LightGray
KnownColorKindWeb, // LightGreen
KnownColorKindWeb, // LightPink
KnownColorKindWeb, // LightSalmon
KnownColorKindWeb, // LightSeaGreen
KnownColorKindWeb, // LightSkyBlue
KnownColorKindWeb, // LightSlateGray
KnownColorKindWeb, // LightSteelBlue
KnownColorKindWeb, // LightYellow
KnownColorKindWeb, // Lime
KnownColorKindWeb, // LimeGreen
KnownColorKindWeb, // Linen
KnownColorKindWeb, // Magenta
KnownColorKindWeb, // Maroon
KnownColorKindWeb, // MediumAquamarine
KnownColorKindWeb, // MediumBlue
KnownColorKindWeb, // MediumOrchid
KnownColorKindWeb, // MediumPurple
KnownColorKindWeb, // MediumSeaGreen
KnownColorKindWeb, // MediumSlateBlue
KnownColorKindWeb, // MediumSpringGreen
KnownColorKindWeb, // MediumTurquoise
KnownColorKindWeb, // MediumVioletRed
KnownColorKindWeb, // MidnightBlue
KnownColorKindWeb, // MintCream
KnownColorKindWeb, // MistyRose
KnownColorKindWeb, // Moccasin
KnownColorKindWeb, // NavajoWhite
KnownColorKindWeb, // Navy
KnownColorKindWeb, // OldLace
KnownColorKindWeb, // Olive
KnownColorKindWeb, // OliveDrab
KnownColorKindWeb, // Orange
KnownColorKindWeb, // OrangeRed
KnownColorKindWeb, // Orchid
KnownColorKindWeb, // PaleGoldenrod
KnownColorKindWeb, // PaleGreen
KnownColorKindWeb, // PaleTurquoise
KnownColorKindWeb, // PaleVioletRed
KnownColorKindWeb, // PapayaWhip
KnownColorKindWeb, // PeachPuff
KnownColorKindWeb, // Peru
KnownColorKindWeb, // Pink
KnownColorKindWeb, // Plum
KnownColorKindWeb, // PowderBlue
KnownColorKindWeb, // Purple
KnownColorKindWeb, // Red
KnownColorKindWeb, // RosyBrown
KnownColorKindWeb, // RoyalBlue
KnownColorKindWeb, // SaddleBrown
KnownColorKindWeb, // Salmon
KnownColorKindWeb, // SandyBrown
KnownColorKindWeb, // SeaGreen
KnownColorKindWeb, // SeaShell
KnownColorKindWeb, // Sienna
KnownColorKindWeb, // Silver
KnownColorKindWeb, // SkyBlue
KnownColorKindWeb, // SlateBlue
KnownColorKindWeb, // SlateGray
KnownColorKindWeb, // Snow
KnownColorKindWeb, // SpringGreen
KnownColorKindWeb, // SteelBlue
KnownColorKindWeb, // Tan
KnownColorKindWeb, // Teal
KnownColorKindWeb, // Thistle
KnownColorKindWeb, // Tomato
KnownColorKindWeb, // Turquoise
KnownColorKindWeb, // Violet
KnownColorKindWeb, // Wheat
KnownColorKindWeb, // White
KnownColorKindWeb, // WhiteSmoke
KnownColorKindWeb, // Yellow
KnownColorKindWeb, // YellowGreen
#if FEATURE_WINDOWS_SYSTEM_COLORS
// "System" colors, Part 2
KnownColorKindSystem, // ButtonFace
KnownColorKindSystem, // ButtonHighlight
KnownColorKindSystem, // ButtonShadow
KnownColorKindSystem, // GradientActiveCaption
KnownColorKindSystem, // GradientInactiveCaption
KnownColorKindSystem, // MenuBar
KnownColorKindSystem, // MenuHighlight
#else
KnownColorKindSystem, // ButtonFace
KnownColorKindSystem, // ButtonHighlight
KnownColorKindSystem, // ButtonShadow
KnownColorKindSystem, // GradientActiveCaption
KnownColorKindSystem, // GradientInactiveCaption
KnownColorKindSystem, // MenuBar
KnownColorKindSystem, // MenuHighlight
#endif
// "Web" colors, Part 2
KnownColorKindWeb, // RebeccaPurple
};

internal static Color ArgbToKnownColor(uint argb)
{
// Should be fully opaque (and as such we can skip the first entry
// which is transparent).
Debug.Assert((argb & Color.ARGBAlphaMask) == Color.ARGBAlphaMask);
Debug.Assert(s_colorValueTable.Length == s_colorKindTable.Length);

for (int index = 1; index < s_colorTable.Length; ++index)
for (int index = 1; index < s_colorValueTable.Length; ++index)
{
if (s_colorTable[index] == argb)
if (s_colorKindTable[index] == KnownColorKindWeb && s_colorValueTable[index] == argb)
{
var knownColor = KnownColor.Transparent + index;
// Handles the mismatching of the RebeccaPurple color with ButtonFace color ("System" colors, Part 2)
if (knownColor > KnownColor.YellowGreen)
{
knownColor += (int)KnownColor.RebeccaPurple - (int)KnownColor.ButtonFace;
}

return Color.FromKnownColor(knownColor);
return Color.FromKnownColor((KnownColor)index);
}
}

@@ -188,124 +484,24 @@ public static uint KnownColorToArgb(KnownColor color)
{
Debug.Assert(color > 0 && color <= KnownColor.RebeccaPurple);

if (Color.IsKnownColorSystem(color))
{
return GetSystemColorArgb(color);
}

return color < KnownColor.ButtonFace
? s_colorTable[(int)color - (int)KnownColor.Transparent]
: s_colorTable[(int)color - (int)KnownColor.RebeccaPurple + ((int)KnownColor.YellowGreen - (int)KnownColor.WindowText)];
return s_colorKindTable[(int)color] == KnownColorKindSystem
? GetSystemColorArgb(color)
: s_colorValueTable[(int)color];
}

#if FEATURE_WINDOWS_SYSTEM_COLORS

private static ReadOnlySpan<byte> SystemColorIdTable => new byte[]
{
// In order of definition in KnownColor enum

// The original group of contiguous system KnownColors
(byte)Interop.User32.Win32SystemColors.ActiveBorder,
(byte)Interop.User32.Win32SystemColors.ActiveCaption,
(byte)Interop.User32.Win32SystemColors.ActiveCaptionText,
(byte)Interop.User32.Win32SystemColors.AppWorkspace,
(byte)Interop.User32.Win32SystemColors.Control,
(byte)Interop.User32.Win32SystemColors.ControlDark,
(byte)Interop.User32.Win32SystemColors.ControlDarkDark,
(byte)Interop.User32.Win32SystemColors.ControlLight,
(byte)Interop.User32.Win32SystemColors.ControlLightLight,
(byte)Interop.User32.Win32SystemColors.ControlText,
(byte)Interop.User32.Win32SystemColors.Desktop,
(byte)Interop.User32.Win32SystemColors.GrayText,
(byte)Interop.User32.Win32SystemColors.Highlight,
(byte)Interop.User32.Win32SystemColors.HighlightText,
(byte)Interop.User32.Win32SystemColors.HotTrack,
(byte)Interop.User32.Win32SystemColors.InactiveBorder,
(byte)Interop.User32.Win32SystemColors.InactiveCaption,
(byte)Interop.User32.Win32SystemColors.InactiveCaptionText,
(byte)Interop.User32.Win32SystemColors.Info,
(byte)Interop.User32.Win32SystemColors.InfoText,
(byte)Interop.User32.Win32SystemColors.Menu,
(byte)Interop.User32.Win32SystemColors.MenuText,
(byte)Interop.User32.Win32SystemColors.ScrollBar,
(byte)Interop.User32.Win32SystemColors.Window,
(byte)Interop.User32.Win32SystemColors.WindowFrame,
(byte)Interop.User32.Win32SystemColors.WindowText,

// The appended group of SystemColors (i.e. not sequential with WindowText above)
(byte)Interop.User32.Win32SystemColors.ButtonFace,
(byte)Interop.User32.Win32SystemColors.ButtonHighlight,
(byte)Interop.User32.Win32SystemColors.ButtonShadow,
(byte)Interop.User32.Win32SystemColors.GradientActiveCaption,
(byte)Interop.User32.Win32SystemColors.GradientInactiveCaption,
(byte)Interop.User32.Win32SystemColors.MenuBar,
(byte)Interop.User32.Win32SystemColors.MenuHighlight
};

public static uint GetSystemColorArgb(KnownColor color)
=> ColorTranslator.COLORREFToARGB(Interop.User32.GetSysColor(GetSystemColorId(color)));

private static int GetSystemColorId(KnownColor color)
{
Debug.Assert(Color.IsKnownColorSystem(color));

return color < KnownColor.Transparent
? SystemColorIdTable[(int)color - (int)KnownColor.ActiveBorder]
: SystemColorIdTable[(int)color - (int)KnownColor.ButtonFace + (int)KnownColor.WindowText];
return ColorTranslator.COLORREFToARGB(Interop.User32.GetSysColor((byte)s_colorValueTable[(int)color]));
}
#else
private static readonly uint[] s_staticSystemColors = new uint[]
{
// Hard-coded constants, based on default Windows settings.
// (In order of definition in KnownColor enum.)

// First contiguous set.

0xFFD4D0C8, // ActiveBorder
0xFF0054E3, // ActiveCaption
0xFFFFFFFF, // ActiveCaptionText
0xFF808080, // AppWorkspace
0xFFECE9D8, // Control
0xFFACA899, // ControlDark
0xFF716F64, // ControlDarkDark
0xFFF1EFE2, // ControlLight
0xFFFFFFFF, // ControlLightLight
0xFF000000, // ControlText
0xFF004E98, // Desktop
0xFFACA899, // GrayText
0xFF316AC5, // Highlight
0xFFFFFFFF, // HighlightText
0xFF000080, // HotTrack
0xFFD4D0C8, // InactiveBorder
0xFF7A96DF, // InactiveCaption
0xFFD8E4F8, // InactiveCaptionText
0xFFFFFFE1, // Info
0xFF000000, // InfoText
0xFFFFFFFF, // Menu
0xFF000000, // MenuText
0xFFD4D0C8, // ScrollBar
0xFFFFFFFF, // Window
0xFF000000, // WindowFrame
0xFF000000, // WindowText

// Second contiguous set.

0xFFF0F0F0, // ButtonFace
0xFFFFFFFF, // ButtonHighlight
0xFFA0A0A0, // ButtonShadow
0xFFB9D1EA, // GradientActiveCaption
0xFFD7E4F2, // GradientInactiveCaption
0xFFF0F0F0, // MenuBar
0xFF3399FF, // MenuHighlight
};

public static uint GetSystemColorArgb(KnownColor color)
{
Debug.Assert(Color.IsKnownColorSystem(color));

return color < KnownColor.Transparent
? s_staticSystemColors[(int)color - (int)KnownColor.ActiveBorder]
: s_staticSystemColors[(int)color - (int)KnownColor.ButtonFace + (int)KnownColor.WindowText];
return s_colorValueTable[(int)color];
}
#endif
}
Original file line number Diff line number Diff line change
@@ -374,7 +374,7 @@ private Color(long value, short state, string? name, KnownColor knownColor)
public bool IsSystemColor => IsKnownColor && IsKnownColorSystem((KnownColor)knownColor);

internal static bool IsKnownColorSystem(KnownColor knownColor)
=> ((knownColor >= KnownColor.ActiveBorder) && (knownColor <= KnownColor.WindowText)) || ((knownColor >= KnownColor.ButtonFace) && (knownColor <= KnownColor.MenuHighlight));
=> KnownColorTable.s_colorKindTable[(int)knownColor] == KnownColorTable.KnownColorKindSystem;

// Used for the [DebuggerDisplay]. Inlining in the attribute is possible, but
// against best practices as the current project language parses the string with
187 changes: 187 additions & 0 deletions src/libraries/System.Drawing.Primitives/tests/ColorTests.cs
Original file line number Diff line number Diff line change
@@ -592,6 +592,10 @@ public void IsSystemColorFalseOnMatching(KnownColor known)
Assert.False(match.IsSystemColor);
}

[Theory, MemberData(nameof(SystemKindKnownColorPairs))]
public void SystemKindOrdering(bool isSystemColor, KnownColor known) =>
Assert.Equal(isSystemColor, Color.FromKnownColor(known).IsSystemColor);

[Theory]
[InlineData((KnownColor)(-1))]
[InlineData((KnownColor)0)]
@@ -694,6 +698,189 @@ public void GetHashCodeForUnknownNamed()
KnownColor.RebeccaPurple
}.Select(kc => new object[] { kc }).ToArray();

public static readonly IEnumerable<bool> SystemKindOrder =
new[]
{
true, // ActiveBorder
true, // ActiveCaption
true, // ActiveCaptionText
true, // AppWorkspace
true, // Control
true, // ControlDark
true, // ControlDarkDark
true, // ControlLight
true, // ControlLightLight
true, // ControlText
true, // Desktop
true, // GrayText
true, // Highlight
true, // HighlightText
true, // HotTrack
true, // InactiveBorder
true, // InactiveCaption
true, // InactiveCaptionText
true, // Info
true, // InfoText
true, // Menu
true, // MenuText
true, // ScrollBar
true, // Window
true, // WindowFrame
true, // WindowText
false, // Transparent
false, // AliceBlue
false, // AntiqueWhite
false, // Aqua
false, // Aquamarine
false, // Azure
false, // Beige
false, // Bisque
false, // Black
false, // BlanchedAlmond
false, // Blue
false, // BlueViolet
false, // Brown
false, // BurlyWood
false, // CadetBlue
false, // Chartreuse
false, // Chocolate
false, // Coral
false, // CornflowerBlue
false, // Cornsilk
false, // Crimson
false, // Cyan
false, // DarkBlue
false, // DarkCyan
false, // DarkGoldenrod
false, // DarkGray
false, // DarkGreen
false, // DarkKhaki
false, // DarkMagenta
false, // DarkOliveGreen
false, // DarkOrange
false, // DarkOrchid
false, // DarkRed
false, // DarkSalmon
false, // DarkSeaGreen
false, // DarkSlateBlue
false, // DarkSlateGray
false, // DarkTurquoise
false, // DarkViolet
false, // DeepPink
false, // DeepSkyBlue
false, // DimGray
false, // DodgerBlue
false, // Firebrick
false, // FloralWhite
false, // ForestGreen
false, // Fuchsia
false, // Gainsboro
false, // GhostWhite
false, // Gold
false, // Goldenrod
false, // Gray
false, // Green
false, // GreenYellow
false, // Honeydew
false, // HotPink
false, // IndianRed
false, // Indigo
false, // Ivory
false, // Khaki
false, // Lavender
false, // LavenderBlush
false, // LawnGreen
false, // LemonChiffon
false, // LightBlue
false, // LightCoral
false, // LightCyan
false, // LightGoldenrodYellow
false, // LightGray
false, // LightGreen
false, // LightPink
false, // LightSalmon
false, // LightSeaGreen
false, // LightSkyBlue
false, // LightSlateGray
false, // LightSteelBlue
false, // LightYellow
false, // Lime
false, // LimeGreen
false, // Linen
false, // Magenta
false, // Maroon
false, // MediumAquamarine
false, // MediumBlue
false, // MediumOrchid
false, // MediumPurple
false, // MediumSeaGreen
false, // MediumSlateBlue
false, // MediumSpringGreen
false, // MediumTurquoise
false, // MediumVioletRed
false, // MidnightBlue
false, // MintCream
false, // MistyRose
false, // Moccasin
false, // NavajoWhite
false, // Navy
false, // OldLace
false, // Olive
false, // OliveDrab
false, // Orange
false, // OrangeRed
false, // Orchid
false, // PaleGoldenrod
false, // PaleGreen
false, // PaleTurquoise
false, // PaleVioletRed
false, // PapayaWhip
false, // PeachPuff
false, // Peru
false, // Pink
false, // Plum
false, // PowderBlue
false, // Purple
false, // Red
false, // RosyBrown
false, // RoyalBlue
false, // SaddleBrown
false, // Salmon
false, // SandyBrown
false, // SeaGreen
false, // SeaShell
false, // Sienna
false, // Silver
false, // SkyBlue
false, // SlateBlue
false, // SlateGray
false, // Snow
false, // SpringGreen
false, // SteelBlue
false, // Tan
false, // Teal
false, // Thistle
false, // Tomato
false, // Turquoise
false, // Violet
false, // Wheat
false, // White
false, // WhiteSmoke
false, // Yellow
false, // YellowGreen
true, // ButtonFace
true, // ButtonHighlight
true, // ButtonShadow
true, // GradientActiveCaption
true, // GradientInactiveCaption
true, // MenuBar
true, // MenuHighlight
false, // RebeccaPurple
};

public static IEnumerable<object[]> SystemKindKnownColorPairs =>
SystemKindOrder.Zip(AllKnownColors, (isSystemKind, color) => new[] { isSystemKind, color[0] });

[DllImport("user32.dll", SetLastError = true)]
private static extern int SetSysColors(int cElements, int[] lpaElements, int[] lpaRgbValues);

0 comments on commit 5f95440

Please sign in to comment.