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:
authorMarek Safar <marek.safar@gmail.com>2017-08-07 17:37:26 +0300
committerMarek Safar <marek.safar@gmail.com>2017-08-07 17:37:26 +0300
commite2551d3cf4a2d2d5a6c037871e29777f9cda3a40 (patch)
treefa06b9687bfc12064222de451f1edf842d61b8b7 /src/System.Drawing.Primitives
parentcb1b049c95227465c1791b857cb5ba86385d9f29 (diff)
parent439bed9924d57694da64254a2e38f29a9d439df4 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/System.Drawing.Primitives')
-rw-r--r--src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj7
-rw-r--r--src/System.Drawing.Primitives/src/System/Drawing/Color.cs77
-rw-r--r--src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs899
-rw-r--r--src/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs172
-rw-r--r--src/System.Drawing.Primitives/tests/SerializationTests.cs55
-rw-r--r--src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj9
6 files changed, 233 insertions, 986 deletions
diff --git a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj
index 2b49c5a61a..75f440ee09 100644
--- a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj
+++ b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj
@@ -38,13 +38,18 @@
<Compile Include="$(CommonPath)\System\Drawing\ColorTable.cs">
<Link>System\Drawing\ColorTable.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)\System\Drawing\ColorUtil.netcoreapp21.cs">
+ <Link>System\Drawing\ColorUtil.netcoreapp21.cs</Link>
+ </Compile>
+ <Compile Include="$(CommonPath)\System\Drawing\KnownColor.cs">
+ <Link>System\Drawing\KnownColor.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)\System\Drawing\KnownColorTable.cs">
<Link>System\Drawing\KnownColorTable.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Numerics\Hashing\HashHelpers.cs">
<Link>Common\System\Numerics\Hashing\HashHelpers.cs</Link>
</Compile>
- <Compile Include="System\Drawing\KnownColor.cs" />
</ItemGroup>
<!-- System color features require Win32 PInvoke's which are disallowed in UAP. -->
<ItemGroup Condition="'$(TargetsWindows)' == 'true' And '$(TargetGroup)' != 'uap'">
diff --git a/src/System.Drawing.Primitives/src/System/Drawing/Color.cs b/src/System.Drawing.Primitives/src/System/Drawing/Color.cs
index e5fd831d7f..a57c7d2c6b 100644
--- a/src/System.Drawing.Primitives/src/System/Drawing/Color.cs
+++ b/src/System.Drawing.Primitives/src/System/Drawing/Color.cs
@@ -454,16 +454,8 @@ namespace System.Drawing
public static Color FromArgb(int red, int green, int blue) => FromArgb(255, red, green, blue);
- public static Color FromKnownColor(KnownColor color)
- {
- var value = (int)color;
- if (value < (int)KnownColor.FirstColor || value > (int)KnownColor.LastColor)
- {
- return FromName(color.ToString());
- }
-
- return new Color(color);
- }
+ public static Color FromKnownColor(KnownColor color) =>
+ color <= 0 || color > KnownColor.MenuHighlight ? FromName(color.ToString()) : new Color(color);
public static Color FromName(string name)
{
@@ -487,11 +479,23 @@ namespace System.Drawing
max = r; min = r;
- if (g > max) max = g;
- if (b > max) max = b;
+ if (g > max)
+ {
+ max = g;
+ }
+ else if (g < min)
+ {
+ min = g;
+ }
- if (g < min) min = g;
- if (b < min) min = b;
+ if (b > max)
+ {
+ max = b;
+ }
+ else if (b < min)
+ {
+ min = b;
+ }
return (max + min) / 2;
}
@@ -508,15 +512,27 @@ namespace System.Drawing
float max, min;
float delta;
- float hue = 0.0f;
+ float hue;
max = r; min = r;
- if (g > max) max = g;
- if (b > max) max = b;
+ if (g > max)
+ {
+ max = g;
+ }
+ else if (g < min)
+ {
+ min = g;
+ }
- if (g < min) min = g;
- if (b < min) min = b;
+ if (b > max)
+ {
+ max = b;
+ }
+ else if (b < min)
+ {
+ min = b;
+ }
delta = max - min;
@@ -528,8 +544,9 @@ namespace System.Drawing
{
hue = 2 + (b - r) / delta;
}
- else if (b == max)
+ else
{
+ Debug.Assert(b == max);
hue = 4 + (r - g) / delta;
}
hue *= 60;
@@ -552,11 +569,23 @@ namespace System.Drawing
float max = r;
float min = r;
- if (g > max) max = g;
- if (b > max) max = b;
+ if (g > max)
+ {
+ max = g;
+ }
+ else if (g < min)
+ {
+ min = g;
+ }
- if (g < min) min = g;
- if (b < min) min = b;
+ if (b > max)
+ {
+ max = b;
+ }
+ else if (b < min)
+ {
+ min = b;
+ }
// if max == min, then there is no color and
// the saturation is zero.
diff --git a/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs b/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs
deleted file mode 100644
index dbd287dd06..0000000000
--- a/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs
+++ /dev/null
@@ -1,899 +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.
-
-using System.Diagnostics.CodeAnalysis;
-
-namespace System.Drawing
-{
- [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")]
- public enum KnownColor
- {
- // This enum is order dependant!!!
- //
- // The value of these known colors are indexes into a color array.
- // Do not modify this enum without updating KnownColorTable.
- //
-
-
- // 0 - reserved for "not a known color"
- FirstColor = 0,
- // "System" colors
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ActiveBorder"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ActiveBorder = 1,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ActiveCaption"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ActiveCaption,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ActiveCaptionText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ActiveCaptionText,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.AppWorkspace"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- AppWorkspace,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Control"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Control,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ControlDark"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ControlDark,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ControlDarkDark"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ControlDarkDark,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ControlLight"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ControlLight,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ControlLightLight"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ControlLightLight,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ControlText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ControlText,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Desktop"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Desktop,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.GrayText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- GrayText,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Highlight"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Highlight,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.HighlightText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- HighlightText,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.HotTrack"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- HotTrack,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.InactiveBorder"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- InactiveBorder,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.InactiveCaption"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- InactiveCaption,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.InactiveCaptionText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- InactiveCaptionText,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Info"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Info,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.InfoText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- InfoText,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Menu"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Menu,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MenuText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MenuText,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ScrollBar"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ScrollBar,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Window"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Window,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.WindowFrame"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- WindowFrame,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.WindowText"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- WindowText,
-
- // "Web" Colors
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Transparent"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Transparent,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.AliceBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- AliceBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.AntiqueWhite"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- AntiqueWhite,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Aqua"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Aqua,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Aquamarine"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Aquamarine,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Azure"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Azure,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Beige"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Beige,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Bisque"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Bisque,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Black"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Black,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.BlanchedAlmond"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- BlanchedAlmond,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Blue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Blue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.BlueViolet"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- BlueViolet,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Brown"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Brown,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.BurlyWood"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- BurlyWood,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.CadetBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- CadetBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Chartreuse"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Chartreuse,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Chocolate"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Chocolate,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Coral"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Coral,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.CornflowerBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- CornflowerBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Cornsilk"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Cornsilk,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Crimson"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Crimson,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Cyan"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Cyan,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkCyan"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkCyan,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkGoldenrod"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkGoldenrod,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkGray"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkGray,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkKhaki"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkKhaki,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkMagenta"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkMagenta,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkOliveGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkOliveGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkOrange"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkOrange,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkOrchid"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkOrchid,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkRed"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkRed,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkSalmon"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkSalmon,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkSeaGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkSeaGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkSlateBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkSlateBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkSlateGray"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkSlateGray,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkTurquoise"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkTurquoise,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DarkViolet"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DarkViolet,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DeepPink"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DeepPink,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DeepSkyBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DeepSkyBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DimGray"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DimGray,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.DodgerBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- DodgerBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Firebrick"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Firebrick,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.FloralWhite"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- FloralWhite,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ForestGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ForestGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Fuchsia"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Fuchsia,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Gainsboro"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Gainsboro,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.GhostWhite"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- GhostWhite,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Gold"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Gold,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Goldenrod"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Goldenrod,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Gray"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Gray,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Green"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Green,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.GreenYellow"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- GreenYellow,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Honeydew"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Honeydew,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.HotPink"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- HotPink,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.IndianRed"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- IndianRed,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Indigo"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Indigo,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Ivory"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Ivory,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Khaki"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Khaki,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Lavender"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Lavender,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LavenderBlush"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LavenderBlush,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LawnGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LawnGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LemonChiffon"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LemonChiffon,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightCoral"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightCoral,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightCyan"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightCyan,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightGoldenrodYellow"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightGoldenrodYellow,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightGray"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightGray,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightPink"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightPink,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightSalmon"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightSalmon,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightSeaGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightSeaGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightSkyBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightSkyBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightSlateGray"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightSlateGray,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightSteelBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightSteelBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LightYellow"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LightYellow,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Lime"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Lime,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.LimeGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- LimeGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Linen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Linen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Magenta"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Magenta,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Maroon"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Maroon,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumAquamarine"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumAquamarine,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumOrchid"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumOrchid,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumPurple"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumPurple,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumSeaGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumSeaGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumSlateBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumSlateBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumSpringGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumSpringGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumTurquoise"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumTurquoise,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MediumVioletRed"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MediumVioletRed,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MidnightBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MidnightBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MintCream"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MintCream,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MistyRose"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MistyRose,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Moccasin"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Moccasin,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.NavajoWhite"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- NavajoWhite,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Navy"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Navy,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.OldLace"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- OldLace,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Olive"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Olive,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.OliveDrab"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- OliveDrab,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Orange"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Orange,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.OrangeRed"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- OrangeRed,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Orchid"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Orchid,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.PaleGoldenrod"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- PaleGoldenrod,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.PaleGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- PaleGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.PaleTurquoise"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- PaleTurquoise,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.PaleVioletRed"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- PaleVioletRed,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.PapayaWhip"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- PapayaWhip,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.PeachPuff"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- PeachPuff,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Peru"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Peru,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Pink"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Pink,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Plum"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Plum,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.PowderBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- PowderBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Purple"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Purple,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Red"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Red,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.RosyBrown"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- RosyBrown,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.RoyalBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- RoyalBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SaddleBrown"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SaddleBrown,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Salmon"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Salmon,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SandyBrown"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SandyBrown,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SeaGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SeaGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SeaShell"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SeaShell,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Sienna"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Sienna,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Silver"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Silver,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SkyBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SkyBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SlateBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SlateBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SlateGray"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SlateGray,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Snow"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Snow,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SpringGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SpringGreen,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.SteelBlue"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- SteelBlue,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Tan"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Tan,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Teal"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Teal,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Thistle"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Thistle,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Tomato"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Tomato,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Turquoise"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Turquoise,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Violet"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Violet,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Wheat"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Wheat,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.White"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- White,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.WhiteSmoke"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- WhiteSmoke,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.Yellow"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- Yellow,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.YellowGreen"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- YellowGreen,
-
- // NEW ADDITIONS IN WHIDBEY - DO NOT MOVE THESE UP OR IT WILL BE A BREAKING CHANGE
-
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ButtonFace"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ButtonFace,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ButtonHighlight"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ButtonHighlight,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.ButtonShadow"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- ButtonShadow,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.GradientActiveCaption"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- GradientActiveCaption,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.GradientInactiveCaption"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- GradientInactiveCaption,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MenuBar"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MenuBar,
- /// <include file='doc\KnownColor.uex' path='docs/doc[@for="KnownColor.MenuHighlight"]/*' />
- /// <devdoc>
- /// <para>[To be supplied.]</para>
- /// </devdoc>
- MenuHighlight,
- LastColor = MenuHighlight,
- }
-} \ No newline at end of file
diff --git a/src/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs b/src/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs
new file mode 100644
index 0000000000..513fd4aaea
--- /dev/null
+++ b/src/System.Drawing.Primitives/tests/ColorTests.netcoreapp.cs
@@ -0,0 +1,172 @@
+// 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.
+
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using Xunit;
+
+namespace System.Drawing.Primitives.Tests
+{
+ public partial class ColorTests
+ {
+ public static readonly IEnumerable<object[]> AllKnownColors = Enum.GetValues(typeof(KnownColor)).Cast<KnownColor>()
+ .Where(kc => kc != 0)
+ .Select(kc => new object[] { kc })
+ .ToArray();
+
+ public static readonly IEnumerable<object[]> SystemColors =
+ new[]
+ {
+ KnownColor.ActiveBorder, KnownColor.ActiveCaption, KnownColor.ActiveCaptionText,
+ KnownColor.AppWorkspace, KnownColor.Control, KnownColor.ControlDark, KnownColor.ControlDarkDark,
+ KnownColor.ControlLight, KnownColor.ControlLightLight, KnownColor.ControlText, KnownColor.Desktop,
+ KnownColor.GrayText, KnownColor.Highlight, KnownColor.HighlightText, KnownColor.HotTrack,
+ KnownColor.InactiveBorder, KnownColor.InactiveCaption, KnownColor.InactiveCaptionText, KnownColor.Info,
+ KnownColor.InfoText, KnownColor.Menu, KnownColor.MenuText, KnownColor.ScrollBar, KnownColor.Window,
+ KnownColor.WindowFrame, KnownColor.WindowText, KnownColor.ButtonFace, KnownColor.ButtonHighlight,
+ KnownColor.ButtonShadow, KnownColor.GradientActiveCaption, KnownColor.GradientInactiveCaption,
+ KnownColor.MenuBar, KnownColor.MenuHighlight
+ }.Select(kc => new object[] { kc }).ToArray();
+
+ public static readonly IEnumerable<object[]> NonSystemColors =
+ new[]
+ {
+ KnownColor.Transparent, KnownColor.AliceBlue, KnownColor.AntiqueWhite, KnownColor.Aqua,
+ KnownColor.Aquamarine, KnownColor.Azure, KnownColor.Beige, KnownColor.Bisque, KnownColor.Black,
+ KnownColor.BlanchedAlmond, KnownColor.Blue, KnownColor.BlueViolet, KnownColor.Brown,
+ KnownColor.BurlyWood, KnownColor.CadetBlue, KnownColor.Chartreuse, KnownColor.Chocolate,
+ KnownColor.Coral, KnownColor.CornflowerBlue, KnownColor.Cornsilk, KnownColor.Crimson, KnownColor.Cyan,
+ KnownColor.DarkBlue, KnownColor.DarkCyan, KnownColor.DarkGoldenrod, KnownColor.DarkGray,
+ KnownColor.DarkGreen, KnownColor.DarkKhaki, KnownColor.DarkMagenta, KnownColor.DarkOliveGreen,
+ KnownColor.DarkOrange, KnownColor.DarkOrchid, KnownColor.DarkRed, KnownColor.DarkSalmon,
+ KnownColor.DarkSeaGreen, KnownColor.DarkSlateBlue, KnownColor.DarkSlateGray, KnownColor.DarkTurquoise,
+ KnownColor.DarkViolet, KnownColor.DeepPink, KnownColor.DeepSkyBlue, KnownColor.DimGray,
+ KnownColor.DodgerBlue, KnownColor.Firebrick, KnownColor.FloralWhite, KnownColor.ForestGreen,
+ KnownColor.Fuchsia, KnownColor.Gainsboro, KnownColor.GhostWhite, KnownColor.Gold, KnownColor.Goldenrod,
+ KnownColor.Gray, KnownColor.Green, KnownColor.GreenYellow, KnownColor.Honeydew, KnownColor.HotPink,
+ KnownColor.IndianRed, KnownColor.Indigo, KnownColor.Ivory, KnownColor.Khaki, KnownColor.Lavender,
+ KnownColor.LavenderBlush, KnownColor.LawnGreen, KnownColor.LemonChiffon, KnownColor.LightBlue,
+ KnownColor.LightCoral, KnownColor.LightCyan, KnownColor.LightGoldenrodYellow, KnownColor.LightGray,
+ KnownColor.LightGreen, KnownColor.LightPink, KnownColor.LightSalmon, KnownColor.LightSeaGreen,
+ KnownColor.LightSkyBlue, KnownColor.LightSlateGray, KnownColor.LightSteelBlue, KnownColor.LightYellow,
+ KnownColor.Lime, KnownColor.LimeGreen, KnownColor.Linen, KnownColor.Magenta, KnownColor.Maroon,
+ KnownColor.MediumAquamarine, KnownColor.MediumBlue, KnownColor.MediumOrchid, KnownColor.MediumPurple,
+ KnownColor.MediumSeaGreen, KnownColor.MediumSlateBlue, KnownColor.MediumSpringGreen,
+ KnownColor.MediumTurquoise, KnownColor.MediumVioletRed, KnownColor.MidnightBlue, KnownColor.MintCream,
+ KnownColor.MistyRose, KnownColor.Moccasin, KnownColor.NavajoWhite, KnownColor.Navy, KnownColor.OldLace,
+ KnownColor.Olive, KnownColor.OliveDrab, KnownColor.Orange, KnownColor.OrangeRed, KnownColor.Orchid,
+ KnownColor.PaleGoldenrod, KnownColor.PaleGreen, KnownColor.PaleTurquoise, KnownColor.PaleVioletRed,
+ KnownColor.PapayaWhip, KnownColor.PeachPuff, KnownColor.Peru, KnownColor.Pink, KnownColor.Plum,
+ KnownColor.PowderBlue, KnownColor.Purple, KnownColor.Red, KnownColor.RosyBrown, KnownColor.RoyalBlue,
+ KnownColor.SaddleBrown, KnownColor.Salmon, KnownColor.SandyBrown, KnownColor.SeaGreen,
+ KnownColor.SeaShell, KnownColor.Sienna, KnownColor.Silver, KnownColor.SkyBlue, KnownColor.SlateBlue,
+ KnownColor.SlateGray, KnownColor.Snow, KnownColor.SpringGreen, KnownColor.SteelBlue, KnownColor.Tan,
+ KnownColor.Teal, KnownColor.Thistle, KnownColor.Tomato, KnownColor.Turquoise, KnownColor.Violet,
+ KnownColor.Wheat, KnownColor.White, KnownColor.WhiteSmoke, KnownColor.Yellow, KnownColor.YellowGreen
+ }.Select(kc => new object[] { kc }).ToArray();
+
+ [Theory, MemberData(nameof(NamedArgbValues))]
+ public void FromKnownColor(string name, int alpha, int red, int green, int blue)
+ {
+ Color color = Color.FromKnownColor(Enum.Parse<KnownColor>(name));
+ Assert.Equal(alpha, color.A);
+ Assert.Equal(red, color.R);
+ Assert.Equal(green, color.G);
+ Assert.Equal(blue, color.B);
+ }
+
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(0)]
+ [InlineData(KnownColor.MenuHighlight + 1)]
+ public void FromOutOfRangeKnownColor(KnownColor known)
+ {
+ Color color = Color.FromKnownColor(known);
+ Assert.Equal(0, color.A);
+ Assert.Equal(0, color.R);
+ Assert.Equal(0, color.G);
+ Assert.Equal(0, color.B);
+ }
+
+ [Theory, MemberData(nameof(AllKnownColors))]
+ public void ToKnownColor(KnownColor known) => Assert.Equal(known, Color.FromKnownColor(known).ToKnownColor());
+
+ [Theory, MemberData(nameof(AllKnownColors))]
+ public void ToKnownColorMatchesButIsNotKnown(KnownColor known)
+ {
+ Color color = Color.FromKnownColor(known);
+ Color match = Color.FromArgb(color.A, color.R, color.G, color.B);
+ Assert.Equal((KnownColor)0, match.ToKnownColor());
+ }
+
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(0)]
+ [InlineData(KnownColor.MenuHighlight + 1)]
+ public void FromOutOfRangeKnownColorToKnownColor(KnownColor known)
+ {
+ Color color = Color.FromKnownColor(known);
+ Assert.Equal((KnownColor)0, color.ToKnownColor());
+ }
+
+ [Theory, MemberData(nameof(SystemColors))]
+ public void IsSystemColorTrue(KnownColor known) => Assert.True(Color.FromKnownColor(known).IsSystemColor);
+
+ [Theory, MemberData(nameof(NonSystemColors))]
+ public void IsSystemColorFalse(KnownColor known) => Assert.False(Color.FromKnownColor(known).IsSystemColor);
+
+ [Theory, MemberData(nameof(SystemColors))]
+ public void IsSystemColorFalseOnMatching(KnownColor known)
+ {
+ Color color = Color.FromKnownColor(known);
+ Color match = Color.FromArgb(color.A, color.R, color.G, color.B);
+ Assert.False(match.IsSystemColor);
+ }
+
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(0)]
+ [InlineData(KnownColor.MenuHighlight + 1)]
+ public void IsSystemColorOutOfRangeKnown(KnownColor known)
+ {
+ Color color = Color.FromKnownColor(known);
+ Assert.False(color.IsSystemColor);
+ }
+
+ [Theory, MemberData(nameof(AllKnownColors))]
+ public void IsKnownColorTrue(KnownColor known)
+ {
+ Assert.True(Color.FromKnownColor(known).IsKnownColor);
+ }
+
+ [Theory, MemberData(nameof(AllKnownColors))]
+ public void IsKnownColorMatchFalse(KnownColor known)
+ {
+ Color color = Color.FromKnownColor(known);
+ Color match = Color.FromArgb(color.A, color.R, color.G, color.B);
+ Assert.False(match.IsKnownColor);
+ }
+
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(0)]
+ [InlineData(KnownColor.MenuHighlight + 1)]
+ public void IsKnownColorOutOfRangeKnown(KnownColor known)
+ {
+ Color color = Color.FromKnownColor(known);
+ Assert.False(color.IsKnownColor);
+ }
+
+ [Fact]
+ public void GetHashCodeForUnknownNamed()
+ {
+ // NetFX gives all such colors the same hash code. CoreFX makes more effort with them.
+ Color c1 = Color.FromName("SomeUnknownColorName");
+ Color c2 = Color.FromName("AnotherUnknownColorName");
+ Assert.NotEqual(c2.GetHashCode(), c1.GetHashCode());
+ Assert.Equal(c1.GetHashCode(), c1.GetHashCode());
+ }
+ }
+}
diff --git a/src/System.Drawing.Primitives/tests/SerializationTests.cs b/src/System.Drawing.Primitives/tests/SerializationTests.cs
deleted file mode 100644
index 30cc4d5ec8..0000000000
--- a/src/System.Drawing.Primitives/tests/SerializationTests.cs
+++ /dev/null
@@ -1,55 +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.
-
-using System.Collections.Generic;
-using System.Runtime.Serialization.Formatters.Tests;
-using Xunit;
-
-namespace System.Drawing.Primitives.Tests
-{
- public class SerializationTests
- {
- public static IEnumerable<object[]> Color_Roundtrip_MemberData()
- {
- yield return new object[] { default(Color) };
- 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) };
- yield return new object[] { Color.FromArgb(1, 2, 3) };
- yield return new object[] { Color.FromName("SomeName") };
- }
-
- [Theory]
- [MemberData(nameof(Color_Roundtrip_MemberData))]
- public void Color_Roundtrip(Color c)
- {
- Assert.Equal(c, BinaryFormatterHelpers.Clone(c));
- }
-
- [Fact]
- public void Size_Roundtrip()
- {
- SizeF s = new SizeF(123.4f, 567.8f);
- Assert.Equal(s, BinaryFormatterHelpers.Clone(s));
- Assert.Equal(s.ToSize(), BinaryFormatterHelpers.Clone(s.ToSize()));
- }
-
- [Fact]
- public void Point_Roundtrip()
- {
- PointF p = new PointF(123.4f, 567.8f);
- Assert.Equal(p, BinaryFormatterHelpers.Clone(p));
- Assert.Equal(Point.Truncate(p), BinaryFormatterHelpers.Clone(Point.Truncate(p)));
- }
-
- [Fact]
- public void Rectangle_Roundtrip()
- {
- RectangleF r = new RectangleF(1.2f, 3.4f, 5.6f, 7.8f);
- Assert.Equal(r, BinaryFormatterHelpers.Clone(r));
- Assert.Equal(Rectangle.Truncate(r), BinaryFormatterHelpers.Clone(Rectangle.Truncate(r)));
- }
- }
-}
diff --git a/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj b/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj
index 29a26cc198..a5a99f01a4 100644
--- a/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj
+++ b/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj
@@ -19,22 +19,17 @@
<Compile Include="SizeFTests.cs" />
<Compile Include="SizeTests.cs" />
<Compile Include="ColorTests.cs" />
- <Compile Include="SerializationTests.cs" />
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>Common\System\PlatformDetection.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\Diagnostics\DebuggerAttributes.cs">
<Link>Common\System\Diagnostics\DebuggerAttributes.cs</Link>
</Compile>
- <Compile Include="$(CommonTestPath)\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs">
- <Link>Common\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs</Link>
- </Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)'=='netcoreapp'">
<Compile Include="SizeFTests.netcoreapp.cs" />
- </ItemGroup>
- <ItemGroup Condition="'$(TargetGroup)'=='netcoreapp'">
+ <Compile Include="ColorTests.netcoreapp.cs" />
<Compile Include="SizeTests.netcoreapp.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-</Project> \ No newline at end of file
+</Project>