Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWes Haggard <Wes.Haggard@microsoft.com>2017-04-06 19:18:14 +0300
committerWes Haggard <Wes.Haggard@microsoft.com>2017-04-06 22:27:49 +0300
commit9eb75a26a32de61fd4b9e51a1e029df1b2d59ff9 (patch)
treee512289d4b36d22c3fb55af0fcbcbcf817f2a12a /src/System.Drawing.Primitives
parent0325187c9d2ef504a2adf984f94655408ec1315e (diff)
Remove KnownColors and SystemColors from .NET Core
Kept KnownColors as an internal enum for implementation ease but removed the public surface area for it. Remove SystemColors from .NET Core Fix TypeConverter tests to work on netfx and core
Diffstat (limited to 'src/System.Drawing.Primitives')
-rw-r--r--src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs217
-rw-r--r--src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj1
-rw-r--r--src/System.Drawing.Primitives/src/System/Drawing/Color.cs10
-rw-r--r--src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs10
-rw-r--r--src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs84
-rw-r--r--src/System.Drawing.Primitives/src/System/Drawing/SystemColors.cs75
-rw-r--r--src/System.Drawing.Primitives/tests/ColorTests.cs50
-rw-r--r--src/System.Drawing.Primitives/tests/SerializationTests.cs2
8 files changed, 22 insertions, 427 deletions
diff --git a/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs b/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs
index 9e7d3c63a9..e28d6de3f0 100644
--- a/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs
+++ b/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs
@@ -72,9 +72,7 @@ namespace System.Drawing
public static System.Drawing.Color IndianRed { get { throw null; } }
public static System.Drawing.Color Indigo { get { throw null; } }
public bool IsEmpty { get { throw null; } }
- public bool IsKnownColor { get { throw null; } }
public bool IsNamedColor { get { throw null; } }
- public bool IsSystemColor { get { throw null; } }
public static System.Drawing.Color Ivory { get { throw null; } }
public static System.Drawing.Color Khaki { get { throw null; } }
public static System.Drawing.Color Lavender { get { throw null; } }
@@ -167,7 +165,6 @@ namespace System.Drawing
public static System.Drawing.Color FromArgb(int alpha, System.Drawing.Color baseColor) { throw null; }
public static System.Drawing.Color FromArgb(int red, int green, int blue) { throw null; }
public static System.Drawing.Color FromArgb(int alpha, int red, int green, int blue) { throw null; }
- public static System.Drawing.Color FromKnownColor(System.Drawing.KnownColor color) { throw null; }
public static System.Drawing.Color FromName(string name) { throw null; }
public float GetBrightness() { throw null; }
public override int GetHashCode() { throw null; }
@@ -176,186 +173,8 @@ namespace System.Drawing
public static bool operator ==(System.Drawing.Color left, System.Drawing.Color right) { throw null; }
public static bool operator !=(System.Drawing.Color left, System.Drawing.Color right) { throw null; }
public int ToArgb() { throw null; }
- public System.Drawing.KnownColor ToKnownColor() { throw null; }
public override string ToString() { throw null; }
}
- public enum KnownColor
- {
- ActiveBorder = 1,
- ActiveCaption = 2,
- ActiveCaptionText = 3,
- AliceBlue = 28,
- AntiqueWhite = 29,
- AppWorkspace = 4,
- Aqua = 30,
- Aquamarine = 31,
- Azure = 32,
- Beige = 33,
- Bisque = 34,
- Black = 35,
- BlanchedAlmond = 36,
- Blue = 37,
- BlueViolet = 38,
- Brown = 39,
- BurlyWood = 40,
- ButtonFace = 168,
- ButtonHighlight = 169,
- ButtonShadow = 170,
- CadetBlue = 41,
- Chartreuse = 42,
- Chocolate = 43,
- Control = 5,
- ControlDark = 6,
- ControlDarkDark = 7,
- ControlLight = 8,
- ControlLightLight = 9,
- ControlText = 10,
- Coral = 44,
- CornflowerBlue = 45,
- Cornsilk = 46,
- Crimson = 47,
- Cyan = 48,
- DarkBlue = 49,
- DarkCyan = 50,
- DarkGoldenrod = 51,
- DarkGray = 52,
- DarkGreen = 53,
- DarkKhaki = 54,
- DarkMagenta = 55,
- DarkOliveGreen = 56,
- DarkOrange = 57,
- DarkOrchid = 58,
- DarkRed = 59,
- DarkSalmon = 60,
- DarkSeaGreen = 61,
- DarkSlateBlue = 62,
- DarkSlateGray = 63,
- DarkTurquoise = 64,
- DarkViolet = 65,
- DeepPink = 66,
- DeepSkyBlue = 67,
- Desktop = 11,
- DimGray = 68,
- DodgerBlue = 69,
- Firebrick = 70,
- FloralWhite = 71,
- ForestGreen = 72,
- Fuchsia = 73,
- Gainsboro = 74,
- GhostWhite = 75,
- Gold = 76,
- Goldenrod = 77,
- GradientActiveCaption = 171,
- GradientInactiveCaption = 172,
- Gray = 78,
- GrayText = 12,
- Green = 79,
- GreenYellow = 80,
- Highlight = 13,
- HighlightText = 14,
- Honeydew = 81,
- HotPink = 82,
- HotTrack = 15,
- InactiveBorder = 16,
- InactiveCaption = 17,
- InactiveCaptionText = 18,
- IndianRed = 83,
- Indigo = 84,
- Info = 19,
- InfoText = 20,
- Ivory = 85,
- Khaki = 86,
- Lavender = 87,
- LavenderBlush = 88,
- LawnGreen = 89,
- LemonChiffon = 90,
- LightBlue = 91,
- LightCoral = 92,
- LightCyan = 93,
- LightGoldenrodYellow = 94,
- LightGray = 95,
- LightGreen = 96,
- LightPink = 97,
- LightSalmon = 98,
- LightSeaGreen = 99,
- LightSkyBlue = 100,
- LightSlateGray = 101,
- LightSteelBlue = 102,
- LightYellow = 103,
- Lime = 104,
- LimeGreen = 105,
- Linen = 106,
- Magenta = 107,
- Maroon = 108,
- MediumAquamarine = 109,
- MediumBlue = 110,
- MediumOrchid = 111,
- MediumPurple = 112,
- MediumSeaGreen = 113,
- MediumSlateBlue = 114,
- MediumSpringGreen = 115,
- MediumTurquoise = 116,
- MediumVioletRed = 117,
- Menu = 21,
- MenuBar = 173,
- MenuHighlight = 174,
- MenuText = 22,
- MidnightBlue = 118,
- MintCream = 119,
- MistyRose = 120,
- Moccasin = 121,
- NavajoWhite = 122,
- Navy = 123,
- OldLace = 124,
- Olive = 125,
- OliveDrab = 126,
- Orange = 127,
- OrangeRed = 128,
- Orchid = 129,
- PaleGoldenrod = 130,
- PaleGreen = 131,
- PaleTurquoise = 132,
- PaleVioletRed = 133,
- PapayaWhip = 134,
- PeachPuff = 135,
- Peru = 136,
- Pink = 137,
- Plum = 138,
- PowderBlue = 139,
- Purple = 140,
- Red = 141,
- RosyBrown = 142,
- RoyalBlue = 143,
- SaddleBrown = 144,
- Salmon = 145,
- SandyBrown = 146,
- ScrollBar = 23,
- SeaGreen = 147,
- SeaShell = 148,
- Sienna = 149,
- Silver = 150,
- SkyBlue = 151,
- SlateBlue = 152,
- SlateGray = 153,
- Snow = 154,
- SpringGreen = 155,
- SteelBlue = 156,
- Tan = 157,
- Teal = 158,
- Thistle = 159,
- Tomato = 160,
- Transparent = 27,
- Turquoise = 161,
- Violet = 162,
- Wheat = 163,
- White = 164,
- WhiteSmoke = 165,
- Window = 24,
- WindowFrame = 25,
- WindowText = 26,
- Yellow = 166,
- YellowGreen = 167,
- }
public partial struct Point : System.IEquatable<System.Drawing.Point>
{
public static readonly System.Drawing.Point Empty;
@@ -546,40 +365,4 @@ namespace System.Drawing
public System.Drawing.Size ToSize() { throw null; }
public override string ToString() { throw null; }
}
- public static partial class SystemColors
- {
- public static System.Drawing.Color ActiveBorder { get { throw null; } }
- public static System.Drawing.Color ActiveCaption { get { throw null; } }
- public static System.Drawing.Color ActiveCaptionText { get { throw null; } }
- public static System.Drawing.Color AppWorkspace { get { throw null; } }
- public static System.Drawing.Color ButtonFace { get { throw null; } }
- public static System.Drawing.Color ButtonHighlight { get { throw null; } }
- public static System.Drawing.Color ButtonShadow { get { throw null; } }
- public static System.Drawing.Color Control { get { throw null; } }
- public static System.Drawing.Color ControlDark { get { throw null; } }
- public static System.Drawing.Color ControlDarkDark { get { throw null; } }
- public static System.Drawing.Color ControlLight { get { throw null; } }
- public static System.Drawing.Color ControlLightLight { get { throw null; } }
- public static System.Drawing.Color ControlText { get { throw null; } }
- public static System.Drawing.Color Desktop { get { throw null; } }
- public static System.Drawing.Color GradientActiveCaption { get { throw null; } }
- public static System.Drawing.Color GradientInactiveCaption { get { throw null; } }
- public static System.Drawing.Color GrayText { get { throw null; } }
- public static System.Drawing.Color Highlight { get { throw null; } }
- public static System.Drawing.Color HighlightText { get { throw null; } }
- public static System.Drawing.Color HotTrack { get { throw null; } }
- public static System.Drawing.Color InactiveBorder { get { throw null; } }
- public static System.Drawing.Color InactiveCaption { get { throw null; } }
- public static System.Drawing.Color InactiveCaptionText { get { throw null; } }
- public static System.Drawing.Color Info { get { throw null; } }
- public static System.Drawing.Color InfoText { get { throw null; } }
- public static System.Drawing.Color Menu { get { throw null; } }
- public static System.Drawing.Color MenuBar { get { throw null; } }
- public static System.Drawing.Color MenuHighlight { get { throw null; } }
- public static System.Drawing.Color MenuText { get { throw null; } }
- public static System.Drawing.Color ScrollBar { get { throw null; } }
- public static System.Drawing.Color Window { get { throw null; } }
- public static System.Drawing.Color WindowFrame { get { throw null; } }
- public static System.Drawing.Color WindowText { get { throw null; } }
- }
}
diff --git a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj
index e000d8d2ea..0cd290b3b9 100644
--- a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj
+++ b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj
@@ -37,7 +37,6 @@
</Compile>
<Compile Include="System\Drawing\KnownColor.cs" />
<Compile Include="System\Drawing\KnownColorTable.cs" />
- <Compile Include="System\Drawing\SystemColors.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project> \ No newline at end of file
diff --git a/src/System.Drawing.Primitives/src/System/Drawing/Color.cs b/src/System.Drawing.Primitives/src/System/Drawing/Color.cs
index aa38fd658c..07ff82e444 100644
--- a/src/System.Drawing.Primitives/src/System/Drawing/Color.cs
+++ b/src/System.Drawing.Primitives/src/System/Drawing/Color.cs
@@ -363,14 +363,12 @@ namespace System.Drawing
public byte A => (byte)((Value >> ARGBAlphaShift) & 0xFF);
- public bool IsKnownColor => ((state & StateKnownColorValid) != 0);
+ private bool IsKnownColor => ((state & StateKnownColorValid) != 0);
public bool IsEmpty => state == 0;
public bool IsNamedColor => ((state & StateNameValid) != 0) || IsKnownColor;
- public bool IsSystemColor => IsKnownColor && ((((KnownColor)knownColor) <= KnownColor.WindowText) || (((KnownColor)knownColor) > KnownColor.YellowGreen));
-
// Not localized because it's only used for the DebuggerDisplayAttribute, and the values are
// programmatic items.
// Also, don't inline into the attribute for performance reasons. This way means the debugger
@@ -451,10 +449,10 @@ namespace System.Drawing
public static Color FromArgb(int red, int green, int blue) => FromArgb(255, red, green, blue);
- public static Color FromKnownColor(KnownColor color)
+ private static Color FromKnownColor(KnownColor color)
{
var value = (int)color;
- if (value < (int)KnownColor.ActiveBorder || value > (int)KnownColor.MenuHighlight)
+ if (value < (int)KnownColor.FirstColor || value > (int)KnownColor.LastColor)
{
return FromName(color.ToString());
}
@@ -576,7 +574,7 @@ namespace System.Drawing
public int ToArgb() => unchecked((int)Value);
- public KnownColor ToKnownColor() => (KnownColor)knownColor;
+ private KnownColor ToKnownColor() => (KnownColor)knownColor;
public override string ToString()
{
diff --git a/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs b/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs
index 2385fa9fdc..450f3bfbf7 100644
--- a/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs
+++ b/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs
@@ -7,7 +7,7 @@ using System.Diagnostics.CodeAnalysis;
namespace System.Drawing
{
[SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")]
- public enum KnownColor
+ internal enum KnownColor
{
// This enum is order dependant!!!
//
@@ -19,6 +19,7 @@ namespace System.Drawing
// 0 - reserved for "not a known color"
// "System" colors
+ /*
ActiveBorder = 1,
ActiveCaption,
ActiveCaptionText,
@@ -45,9 +46,11 @@ namespace System.Drawing
Window,
WindowFrame,
WindowText,
+ */
// "Web" Colors
- Transparent,
+ FirstColor = 0,
+ Transparent = FirstColor,
AliceBlue,
AntiqueWhite,
Aqua,
@@ -188,9 +191,11 @@ namespace System.Drawing
WhiteSmoke,
Yellow,
YellowGreen,
+ LastColor = YellowGreen
// NEW ADDITIONS IN WHIDBEY - DO NOT MOVE THESE UP OR IT WILL BE A BREAKING CHANGE
+ /*
ButtonFace,
ButtonHighlight,
ButtonShadow,
@@ -198,5 +203,6 @@ namespace System.Drawing
GradientInactiveCaption,
MenuBar,
MenuHighlight,
+ */
}
} \ No newline at end of file
diff --git a/src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs b/src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs
index f24e967849..390e695844 100644
--- a/src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs
+++ b/src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs
@@ -21,11 +21,7 @@ namespace System.Drawing
private static void InitColorTable()
{
- int[] values = new int[(int)KnownColor.MenuHighlight + 1];
-
- // system
- //
- UpdateSystemColors(values);
+ int[] values = new int[KnownColor.LastColor - KnownColor.FirstColor + 1];
// just consts...
//
@@ -185,44 +181,10 @@ namespace System.Drawing
private static void InitColorNameTable()
{
- string[] values = new string[((int)KnownColor.MenuHighlight) + 1];
+ string[] values = new string[KnownColor.LastColor - KnownColor.FirstColor + 1];
// just consts...
//
- values[(int)KnownColor.ActiveBorder] = "ActiveBorder";
- values[(int)KnownColor.ActiveCaption] = "ActiveCaption";
- values[(int)KnownColor.ActiveCaptionText] = "ActiveCaptionText";
- values[(int)KnownColor.AppWorkspace] = "AppWorkspace";
- values[(int)KnownColor.ButtonFace] = "ButtonFace";
- values[(int)KnownColor.ButtonHighlight] = "ButtonHighlight";
- values[(int)KnownColor.ButtonShadow] = "ButtonShadow";
- values[(int)KnownColor.Control] = "Control";
- values[(int)KnownColor.ControlDark] = "ControlDark";
- values[(int)KnownColor.ControlDarkDark] = "ControlDarkDark";
- values[(int)KnownColor.ControlLight] = "ControlLight";
- values[(int)KnownColor.ControlLightLight] = "ControlLightLight";
- values[(int)KnownColor.ControlText] = "ControlText";
- values[(int)KnownColor.Desktop] = "Desktop";
- values[(int)KnownColor.GradientActiveCaption] = "GradientActiveCaption";
- values[(int)KnownColor.GradientInactiveCaption] = "GradientInactiveCaption";
- values[(int)KnownColor.GrayText] = "GrayText";
- values[(int)KnownColor.Highlight] = "Highlight";
- values[(int)KnownColor.HighlightText] = "HighlightText";
- values[(int)KnownColor.HotTrack] = "HotTrack";
- values[(int)KnownColor.InactiveBorder] = "InactiveBorder";
- values[(int)KnownColor.InactiveCaption] = "InactiveCaption";
- values[(int)KnownColor.InactiveCaptionText] = "InactiveCaptionText";
- values[(int)KnownColor.Info] = "Info";
- values[(int)KnownColor.InfoText] = "InfoText";
- values[(int)KnownColor.Menu] = "Menu";
- values[(int)KnownColor.MenuBar] = "MenuBar";
- values[(int)KnownColor.MenuHighlight] = "MenuHighlight";
- values[(int)KnownColor.MenuText] = "MenuText";
- values[(int)KnownColor.ScrollBar] = "ScrollBar";
- values[(int)KnownColor.Window] = "Window";
- values[(int)KnownColor.WindowFrame] = "WindowFrame";
- values[(int)KnownColor.WindowText] = "WindowText";
-
values[(int)KnownColor.Transparent] = "Transparent";
values[(int)KnownColor.AliceBlue] = "AliceBlue";
values[(int)KnownColor.AntiqueWhite] = "AntiqueWhite";
@@ -370,7 +332,7 @@ namespace System.Drawing
public static int KnownColorToArgb(KnownColor color)
{
EnsureColorTable();
- if (color <= KnownColor.MenuHighlight)
+ if (color >= KnownColor.FirstColor && color <= KnownColor.LastColor)
{
return s_colorTable[(int)color];
}
@@ -383,7 +345,7 @@ namespace System.Drawing
public static string KnownColorToName(KnownColor color)
{
EnsureColorNameTable();
- if (color <= KnownColor.MenuHighlight)
+ if (color >= KnownColor.FirstColor && color <= KnownColor.LastColor)
{
return s_colorNameTable[(int)color];
}
@@ -392,43 +354,5 @@ namespace System.Drawing
return null;
}
}
-
- private static void UpdateSystemColors(int[] colorTable)
- {
- // Colors from a default XP desktop for use by UI designers in ASP.NET: <EMAIL>mcartwri</EMAIL>
- colorTable[(int)KnownColor.ActiveBorder] = unchecked((int)0xffd4d0c8);
- colorTable[(int)KnownColor.ActiveCaption] = unchecked((int)0xff0054e3);
- colorTable[(int)KnownColor.ActiveCaptionText] = unchecked((int)0xffffffff);
- colorTable[(int)KnownColor.AppWorkspace] = unchecked((int)0xff808080);
- colorTable[(int)KnownColor.ButtonFace] = unchecked((int)0x0);
- colorTable[(int)KnownColor.ButtonHighlight] = unchecked((int)0x0);
- colorTable[(int)KnownColor.ButtonShadow] = unchecked((int)0x0);
- colorTable[(int)KnownColor.Control] = unchecked((int)0xffece9d8);
- colorTable[(int)KnownColor.ControlDark] = unchecked((int)0xffaca899);
- colorTable[(int)KnownColor.ControlDarkDark] = unchecked((int)0xff716f64);
- colorTable[(int)KnownColor.ControlLight] = unchecked((int)0xfff1efe2);
- colorTable[(int)KnownColor.ControlLightLight] = unchecked((int)0xffffffff);
- colorTable[(int)KnownColor.ControlText] = unchecked((int)0xff000000);
- colorTable[(int)KnownColor.Desktop] = unchecked((int)0xff004e98);
- colorTable[(int)KnownColor.GradientActiveCaption] = unchecked((int)0x0);
- colorTable[(int)KnownColor.GradientInactiveCaption] = unchecked((int)0x0);
- colorTable[(int)KnownColor.GrayText] = unchecked((int)0xffaca899);
- colorTable[(int)KnownColor.Highlight] = unchecked((int)0xff316ac5);
- colorTable[(int)KnownColor.HighlightText] = unchecked((int)0xffffffff);
- colorTable[(int)KnownColor.HotTrack] = unchecked((int)0xff000080);
- colorTable[(int)KnownColor.InactiveBorder] = unchecked((int)0xffd4d0c8);
- colorTable[(int)KnownColor.InactiveCaption] = unchecked((int)0xff7a96df);
- colorTable[(int)KnownColor.InactiveCaptionText] = unchecked((int)0xffd8e4f8);
- colorTable[(int)KnownColor.Info] = unchecked((int)0xffffffe1);
- colorTable[(int)KnownColor.InfoText] = unchecked((int)0xff000000);
- colorTable[(int)KnownColor.Menu] = unchecked((int)0xffffffff);
- colorTable[(int)KnownColor.MenuBar] = unchecked((int)0x0);
- colorTable[(int)KnownColor.MenuHighlight] = unchecked((int)0x0);
- colorTable[(int)KnownColor.MenuText] = unchecked((int)0xff000000);
- colorTable[(int)KnownColor.ScrollBar] = unchecked((int)0xffd4d0c8);
- colorTable[(int)KnownColor.Window] = unchecked((int)0xffffffff);
- colorTable[(int)KnownColor.WindowFrame] = unchecked((int)0xff000000);
- colorTable[(int)KnownColor.WindowText] = unchecked((int)0xff000000);
- }
}
}
diff --git a/src/System.Drawing.Primitives/src/System/Drawing/SystemColors.cs b/src/System.Drawing.Primitives/src/System/Drawing/SystemColors.cs
deleted file mode 100644
index 6f8e4ad98f..0000000000
--- a/src/System.Drawing.Primitives/src/System/Drawing/SystemColors.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Drawing
-{
- public static class SystemColors
- {
- public static Color ActiveBorder => new Color(KnownColor.ActiveBorder);
-
- public static Color ActiveCaption => new Color(KnownColor.ActiveCaption);
-
- public static Color ActiveCaptionText => new Color(KnownColor.ActiveCaptionText);
-
- public static Color AppWorkspace => new Color(KnownColor.AppWorkspace);
-
- public static Color ButtonFace => new Color(KnownColor.ButtonFace);
-
- public static Color ButtonHighlight => new Color(KnownColor.ButtonHighlight);
-
- public static Color ButtonShadow => new Color(KnownColor.ButtonShadow);
-
- public static Color Control => new Color(KnownColor.Control);
-
- public static Color ControlDark => new Color(KnownColor.ControlDark);
-
- public static Color ControlDarkDark => new Color(KnownColor.ControlDarkDark);
-
- public static Color ControlLight => new Color(KnownColor.ControlLight);
-
- public static Color ControlLightLight => new Color(KnownColor.ControlLightLight);
-
- public static Color ControlText => new Color(KnownColor.ControlText);
-
- public static Color Desktop => new Color(KnownColor.Desktop);
-
- public static Color GradientActiveCaption => new Color(KnownColor.GradientActiveCaption);
-
- public static Color GradientInactiveCaption => new Color(KnownColor.GradientInactiveCaption);
-
- public static Color GrayText => new Color(KnownColor.GrayText);
-
- public static Color Highlight => new Color(KnownColor.Highlight);
-
- public static Color HighlightText => new Color(KnownColor.HighlightText);
-
- public static Color HotTrack => new Color(KnownColor.HotTrack);
-
- public static Color InactiveBorder => new Color(KnownColor.InactiveBorder);
-
- public static Color InactiveCaption => new Color(KnownColor.InactiveCaption);
-
- public static Color InactiveCaptionText => new Color(KnownColor.InactiveCaptionText);
-
- public static Color Info => new Color(KnownColor.Info);
-
- public static Color InfoText => new Color(KnownColor.InfoText);
-
- public static Color Menu => new Color(KnownColor.Menu);
-
- public static Color MenuBar => new Color(KnownColor.MenuBar);
-
- public static Color MenuHighlight => new Color(KnownColor.MenuHighlight);
-
- public static Color MenuText => new Color(KnownColor.MenuText);
-
- public static Color ScrollBar => new Color(KnownColor.ScrollBar);
-
- public static Color Window => new Color(KnownColor.Window);
-
- public static Color WindowFrame => new Color(KnownColor.WindowFrame);
-
- public static Color WindowText => new Color(KnownColor.WindowText);
- }
-} \ No newline at end of file
diff --git a/src/System.Drawing.Primitives/tests/ColorTests.cs b/src/System.Drawing.Primitives/tests/ColorTests.cs
index 3798160347..a80796a587 100644
--- a/src/System.Drawing.Primitives/tests/ColorTests.cs
+++ b/src/System.Drawing.Primitives/tests/ColorTests.cs
@@ -157,7 +157,9 @@ namespace System.Drawing.Primitives.Tests
new object[] {"YellowGreen", 255, 154, 205, 50},
};
- public static IEnumerable<object[]> ColorNames => Enum.GetNames(typeof(KnownColor)).Select(n => new object[] { n });
+ public static IEnumerable<object[]> ColorNames => typeof(Color).GetProperties()
+ .Where(p => p.PropertyType == typeof(Color))
+ .Select(p => new object[] { p.Name} );
private Color? GetColorByProperty(string name)
{
@@ -215,37 +217,13 @@ namespace System.Drawing.Primitives.Tests
}
[Fact]
- public void IsKnownColor()
- {
- Assert.True(Color.FromKnownColor(KnownColor.AliceBlue).IsKnownColor);
- Assert.True(Color.FromName("AliceBlue").IsKnownColor);
-
- Assert.False(Color.FromKnownColor((KnownColor)(-1)).IsKnownColor);
- Assert.False(Color.FromKnownColor((KnownColor)(12345)).IsKnownColor);
- Assert.False(Color.FromName("SomethingNotAColor").IsKnownColor);
- Assert.False(Color.FromArgb(Color.AliceBlue.A, Color.AliceBlue.R, Color.AliceBlue.G, Color.AliceBlue.B).IsKnownColor);
- }
-
- [Fact]
public void IsNamedColor()
{
Assert.True(Color.AliceBlue.IsNamedColor);
- Assert.True(Color.FromKnownColor(KnownColor.AliceBlue).IsNamedColor);
Assert.True(Color.FromName("AliceBlue").IsNamedColor);
Assert.False(Color.FromArgb(Color.AliceBlue.A, Color.AliceBlue.R, Color.AliceBlue.G, Color.AliceBlue.B).IsNamedColor);
}
- [Fact]
- public void IsSystemColor()
- {
- Color c = Color.FromKnownColor(KnownColor.ActiveBorder);
- Assert.True(c.IsSystemColor);
- Assert.True(Color.FromName("ActiveBorder").IsSystemColor);
- Assert.False(Color.FromArgb(c.A, c.R, c.G, c.B).IsSystemColor);
- Assert.False(Color.FromKnownColor(KnownColor.AliceBlue).IsSystemColor);
- Assert.False(Color.FromName("AliceBlue").IsSystemColor);
- }
-
[Theory]
[MemberData(nameof(ColorNames))]
public void KnownNames(string name)
@@ -285,19 +263,6 @@ namespace System.Drawing.Primitives.Tests
Assert.Equal(argb, Color.FromArgb(alpha, red, green, blue).ToArgb());
}
- [Theory]
- [MemberData(nameof(ColorNames))]
- public void ToKnownColor(string name)
- {
- var knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), name);
- var colorByProperty = GetColorByProperty(name);
- if (colorByProperty.HasValue)
- {
- Assert.Equal(knownColor, colorByProperty.Value.ToKnownColor());
- }
- Assert.Equal(knownColor, Color.FromName(name).ToKnownColor());
- }
-
[Fact]
public void ToStringEmpty()
{
@@ -384,7 +349,7 @@ namespace System.Drawing.Primitives.Tests
Color.FromArgb(0, 0, 0, blue);
});
}
-
+
[Fact]
public void FromName_Invalid()
{
@@ -393,7 +358,7 @@ namespace System.Drawing.Primitives.Tests
Assert.Equal(0, c.ToArgb());
Assert.Equal("OingoBoingo", c.Name);
}
-
+
private void CheckRed(Color color)
{
Assert.Equal(255, color.A);
@@ -402,9 +367,7 @@ namespace System.Drawing.Primitives.Tests
Assert.Equal(0, color.B);
Assert.Equal("Red", color.Name);
Assert.False(color.IsEmpty, "IsEmpty");
- Assert.True(color.IsKnownColor, "IsKnownColor");
Assert.True(color.IsNamedColor, "IsNamedColor");
- Assert.False(color.IsSystemColor, "IsSystemColor");
}
[Theory]
@@ -472,9 +435,6 @@ namespace System.Drawing.Primitives.Tests
public static IEnumerable<object[]> Equality_MemberData()
{
- yield return new object[] { Color.FromKnownColor(KnownColor.AliceBlue), Color.FromKnownColor(KnownColor.AliceBlue), true };
- yield return new object[] { Color.FromKnownColor(KnownColor.AliceBlue), Color.FromKnownColor(KnownColor.Aquamarine), false };
-
yield return new object[] { Color.AliceBlue, Color.AliceBlue, true };
yield return new object[] { Color.AliceBlue, Color.White, false};
yield return new object[] { Color.AliceBlue, Color.Black, false };
diff --git a/src/System.Drawing.Primitives/tests/SerializationTests.cs b/src/System.Drawing.Primitives/tests/SerializationTests.cs
index acd62b1064..30cc4d5ec8 100644
--- a/src/System.Drawing.Primitives/tests/SerializationTests.cs
+++ b/src/System.Drawing.Primitives/tests/SerializationTests.cs
@@ -13,7 +13,7 @@ namespace System.Drawing.Primitives.Tests
public static IEnumerable<object[]> Color_Roundtrip_MemberData()
{
yield return new object[] { default(Color) };
- yield return new object[] { Color.FromKnownColor(KnownColor.AliceBlue) };
+ yield return new object[] { Color.FromName("AliceBlue") };
yield return new object[] { Color.AliceBlue };
yield return new object[] { Color.FromArgb(255, 1, 2, 3) };
yield return new object[] { Color.FromArgb(0, 1, 2, 3) };