Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,253 +0,0 @@
//
// System.Drawing.ColorConverter
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Ravindra (rkumar@novell.com)
//
// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004,2006,2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.Text;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace System.Drawing
{
public class ColorConverter : TypeConverter
{
static StandardValuesCollection cached;
static object creatingCached = new object ();
public ColorConverter () { }
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof (string))
return true;
return base.CanConvertFrom (context, sourceType);
}
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof (InstanceDescriptor))
return true;
return base.CanConvertTo (context, destinationType);
}
internal static Color StaticConvertFromString (ITypeDescriptorContext context, string s, CultureInfo culture)
{
if (culture == null)
culture = CultureInfo.InvariantCulture;
s = s.Trim ();
if (s.Length == 0)
return Color.Empty;
// Try to process both NamedColor and SystemColors from the KnownColor enumeration
if (Char.IsLetter (s [0])) {
KnownColor kc;
try {
kc = (KnownColor) Enum.Parse (typeof (KnownColor), s, true);
}
catch (Exception e) {
// whatever happens MS throws an basic Exception
string msg = Locale.GetText ("Invalid color name '{0}'.", s);
throw new Exception (msg, new FormatException (msg, e));
}
return KnownColors.FromKnownColor (kc);
}
String numSeparator = culture.TextInfo.ListSeparator;
Color result = Color.Empty;
if (s.IndexOf (numSeparator) == -1) {
bool sharp = (s[0] == '#');
int start = sharp ? 1 : 0;
bool hex = false;
// deal with #hex, 0xhex and #0xhex
if ((s.Length > start + 1) && (s[start] == '0')) {
hex = ((s[start + 1] == 'x') || (s[start + 1] == 'X'));
if (hex)
start += 2;
}
if (sharp || hex) {
s = s.Substring (start);
int argb;
try {
argb = Int32.Parse (s, NumberStyles.HexNumber);
}
catch (Exception e) {
// whatever happens MS throws an basic Exception
string msg = Locale.GetText ("Invalid Int32 value '{0}'.", s);
throw new Exception (msg, e);
}
// note that the default alpha value for a 6 hex digit (i.e. when none are present) is
// 0xFF while shorter string defaults to 0xFF - unless both # an 0x are specified
if ((s.Length < 6) || ((s.Length == 6) && sharp && hex))
argb &= 0x00FFFFFF;
else if ((argb >> 24) == 0)
argb |= unchecked((int)0xFF000000);
result = Color.FromArgb (argb);
}
}
if (result.IsEmpty) {
Int32Converter converter = new Int32Converter ();
String [] components = s.Split (numSeparator.ToCharArray ());
// MS seems to convert the indivual component to int before
// checking the number of components
int[] numComponents = new int[components.Length];
for (int i = 0; i < numComponents.Length; i++) {
numComponents[i] = (int) converter.ConvertFrom (context,
culture, components[i]);
}
switch (components.Length) {
case 1:
result = Color.FromArgb (numComponents[0]);
break;
case 3:
result = Color.FromArgb (numComponents[0], numComponents[1],
numComponents[2]);
break;
case 4:
result = Color.FromArgb (numComponents[0], numComponents[1],
numComponents[2], numComponents[3]);
break;
default:
throw new ArgumentException (s + " is not a valid color value.");
}
}
if (!result.IsEmpty) {
// Look for a named or system color with those values
Color known = KnownColors.FindColorMatch (result);
if (!known.IsEmpty)
return known;
}
return result;
}
public override object ConvertFrom (ITypeDescriptorContext context,
CultureInfo culture,
object value)
{
string s = value as string;
if (s == null)
return base.ConvertFrom (context, culture, value);
return StaticConvertFromString (context, s, culture);
}
public override object ConvertTo (ITypeDescriptorContext context,
CultureInfo culture,
object value,
Type destinationType)
{
if (value is Color) {
Color color = (Color) value;
if (destinationType == typeof (string)) {
if (color == Color.Empty)
return string.Empty;
if (color.IsKnownColor || color.IsNamedColor)
return color.Name;
String numSeparator = culture.TextInfo.ListSeparator;
StringBuilder sb = new StringBuilder ();
if (color.A != 255) {
sb.Append (color.A);
sb.Append (numSeparator);
sb.Append (" ");
}
sb.Append (color.R);
sb.Append (numSeparator);
sb.Append (" ");
sb.Append (color.G);
sb.Append (numSeparator);
sb.Append (" ");
sb.Append (color.B);
return sb.ToString ();
} else if (destinationType == typeof (InstanceDescriptor)) {
if (color.IsEmpty) {
return new InstanceDescriptor (typeof (Color).GetTypeInfo ().GetField ("Empty"), null);
} else if (color.IsSystemColor) {
return new InstanceDescriptor (typeof (SystemColors).GetTypeInfo ().GetProperty (color.Name), null);
} else if (color.IsKnownColor){
return new InstanceDescriptor (typeof (Color).GetTypeInfo ().GetProperty (color.Name), null);
} else {
MethodInfo met = typeof(Color).GetTypeInfo ().GetMethod ("FromArgb", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) } );
return new InstanceDescriptor (met, new object[] {color.A, color.R, color.G, color.B });
}
}
}
return base.ConvertTo (context, culture, value, destinationType);
}
public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
{
lock (creatingCached) {
if (cached != null)
return cached;
Array colors = Array.CreateInstance (typeof (Color), KnownColors.ArgbValues.Length - 1);
for (int i=1; i < KnownColors.ArgbValues.Length; i++) {
colors.SetValue (KnownColors.FromKnownColor ((KnownColor)i), i - 1);
}
Array.Sort (colors, 0, colors.Length, new CompareColors ());
cached = new StandardValuesCollection (colors);
}
return cached;
}
public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
{
return true;
}
sealed class CompareColors : IComparer {
public int Compare (object x, object y)
{
return String.Compare (((Color) x).Name, ((Color) y).Name);
}
}
}
}

View File

@ -1606,6 +1606,9 @@ namespace System.Drawing
{
if (brush == null)
throw new ArgumentNullException ("brush");
if (rect == null)
throw new ArgumentNullException ("rect");
FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
}

View File

@ -1,209 +0,0 @@
//
// System.Drawing.Color.cs
//
// Author:
// Dennis Hayes (dennish@raytek.com)
// Ben Houston (ben@exocortex.org)
//
// (C) 2002 Dennis Hayes
// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Drawing {
public enum KnownColor {
ActiveBorder = 1,
ActiveCaption = 2,
ActiveCaptionText = 3,
AppWorkspace = 4,
Control = 5,
ControlDark = 6,
ControlDarkDark = 7,
ControlLight = 8,
ControlLightLight = 9,
ControlText = 10,
Desktop = 11,
GrayText = 12,
Highlight = 13,
HighlightText = 14,
HotTrack = 15,
InactiveBorder = 16,
InactiveCaption = 17,
InactiveCaptionText = 18,
Info = 19,
InfoText = 20,
Menu = 21,
MenuText = 22,
ScrollBar = 23,
Window = 24,
WindowFrame = 25,
WindowText = 26,
Transparent = 27,
AliceBlue = 28,
AntiqueWhite = 29,
Aqua = 30,
Aquamarine = 31,
Azure = 32,
Beige = 33,
Bisque = 34,
Black = 35,
BlanchedAlmond = 36,
Blue = 37,
BlueViolet = 38,
Brown = 39,
BurlyWood = 40,
CadetBlue = 41,
Chartreuse = 42,
Chocolate = 43,
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,
DimGray = 68,
DodgerBlue = 69,
Firebrick = 70,
FloralWhite = 71,
ForestGreen = 72,
Fuchsia = 73,
Gainsboro = 74,
GhostWhite = 75,
Gold = 76,
Goldenrod = 77,
Gray = 78,
Green = 79,
GreenYellow = 80,
Honeydew = 81,
HotPink = 82,
IndianRed = 83,
Indigo = 84,
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,
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,
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,
Turquoise = 161,
Violet = 162,
Wheat = 163,
White = 164,
WhiteSmoke = 165,
Yellow = 166,
YellowGreen = 167,
ButtonFace = 168,
ButtonHighlight = 169,
ButtonShadow = 170,
GradientActiveCaption = 171,
GradientInactiveCaption = 172,
MenuBar = 173,
MenuHighlight = 174
}
}

View File

@ -210,7 +210,7 @@ namespace System.Drawing {
0xFF316AC5, /* 174 - MenuHighlight */
};
#if !MONOTOUCH && !MONOMAC && SUPPORTS_WINDOWS_COLORS
#if !MONOTOUCH && !XAMMAC && !XAMMAC_4_5 && SUPPORTS_WINDOWS_COLORS
static KnownColors ()
{
if (GDIPlus.RunningOnWindows ()) {

View File

@ -1,387 +0,0 @@
//
// System.Drawing.Point.cs
//
// Author:
// Mike Kestner (mkestner@speakeasy.net)
//
// Copyright (C) 2001 Mike Kestner
// Copyright (C) 2004 Novell, Inc. http://www.novell.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace System.Drawing
{
[Serializable]
[ComVisible (true)]
#if !MONOTOUCH && !MONOMAC && FEATURE_TYPECONVERTER
[TypeConverter (typeof (PointConverter))]
#endif
public struct Point
{
// Private x and y coordinate fields.
private int x, y;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized Point Structure.
/// </remarks>
public static readonly Point Empty;
/// <summary>
/// Ceiling Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Point structure from a PointF structure by
/// taking the ceiling of the X and Y properties.
/// </remarks>
public static Point Ceiling (PointF value)
{
int x, y;
checked {
x = (int) Math.Ceiling (value.X);
y = (int) Math.Ceiling (value.Y);
}
return new Point (x, y);
}
/// <summary>
/// Round Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Point structure from a PointF structure by
/// rounding the X and Y properties.
/// </remarks>
public static Point Round (PointF value)
{
int x, y;
checked {
x = (int) Math.Round (value.X);
y = (int) Math.Round (value.Y);
}
return new Point (x, y);
}
/// <summary>
/// Truncate Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Point structure from a PointF structure by
/// truncating the X and Y properties.
/// </remarks>
// LAMESPEC: Should this be floor, or a pure cast to int?
public static Point Truncate (PointF value)
{
int x, y;
checked {
x = (int) value.X;
y = (int) value.Y;
}
return new Point (x, y);
}
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Translates a Point using the Width and Height
/// properties of the given <typeref>Size</typeref>.
/// </remarks>
public static Point operator + (Point pt, Size sz)
{
return new Point (pt.X + sz.Width, pt.Y + sz.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two Point objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator == (Point left, Point right)
{
return ((left.X == right.X) && (left.Y == right.Y));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two Point objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator != (Point left, Point right)
{
return ((left.X != right.X) || (left.Y != right.Y));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Translates a Point using the negation of the Width
/// and Height properties of the given Size.
/// </remarks>
public static Point operator - (Point pt, Size sz)
{
return new Point (pt.X - sz.Width, pt.Y - sz.Height);
}
/// <summary>
/// Point to Size Conversion
/// </summary>
///
/// <remarks>
/// Returns a Size based on the Coordinates of a given
/// Point. Requires explicit cast.
/// </remarks>
public static explicit operator Size (Point p)
{
return new Size (p.X, p.Y);
}
/// <summary>
/// Point to PointF Conversion
/// </summary>
///
/// <remarks>
/// Creates a PointF based on the coordinates of a given
/// Point. No explicit cast is required.
/// </remarks>
public static implicit operator PointF (Point p)
{
return new PointF (p.X, p.Y);
}
// -----------------------
// Public Constructors
// -----------------------
/// <summary>
/// Point Constructor
/// </summary>
///
/// <remarks>
/// Creates a Point from an integer which holds the Y
/// coordinate in the high order 16 bits and the X
/// coordinate in the low order 16 bits.
/// </remarks>
public Point (int dw)
{
y = dw >> 16;
x = unchecked ((short) (dw & 0xffff));
}
/// <summary>
/// Point Constructor
/// </summary>
///
/// <remarks>
/// Creates a Point from a Size value.
/// </remarks>
public Point (Size sz)
{
x = sz.Width;
y = sz.Height;
}
/// <summary>
/// Point Constructor
/// </summary>
///
/// <remarks>
/// Creates a Point from a specified x,y coordinate pair.
/// </remarks>
public Point (int x, int y)
{
this.x = x;
this.y = y;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both X and Y are zero.
/// </remarks>
[Browsable (false)]
public bool IsEmpty {
get {
return ((x == 0) && (y == 0));
}
}
/// <summary>
/// X Property
/// </summary>
///
/// <remarks>
/// The X coordinate of the Point.
/// </remarks>
public int X {
get {
return x;
}
set {
x = value;
}
}
/// <summary>
/// Y Property
/// </summary>
///
/// <remarks>
/// The Y coordinate of the Point.
/// </remarks>
public int Y {
get {
return y;
}
set {
y = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this Point and another object.
/// </remarks>
public override bool Equals (object obj)
{
if (!(obj is Point))
return false;
return (this == (Point) obj);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return x^y;
}
/// <summary>
/// Offset Method
/// </summary>
///
/// <remarks>
/// Moves the Point a specified distance.
/// </remarks>
public void Offset (int dx, int dy)
{
x += dx;
y += dy;
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the Point as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return string.Format ("{{X={0},Y={1}}}", x.ToString (CultureInfo.InvariantCulture),
y.ToString (CultureInfo.InvariantCulture));
}
public static Point Add (Point pt, Size sz)
{
return new Point (pt.X + sz.Width, pt.Y + sz.Height);
}
public void Offset (Point p)
{
Offset (p.X, p.Y);
}
public static Point Subtract (Point pt, Size sz)
{
return new Point (pt.X - sz.Width, pt.Y - sz.Height);
}
}
}

View File

@ -1,148 +0,0 @@
//
// System.Drawing.PointConverter.cs
//
// Authors:
// Dennis Hayes (dennish@Raytek.com)
// Ravindra (rkumar@novell.com)
//
// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004, 2006, 2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace System.Drawing {
public class PointConverter : TypeConverter
{
public PointConverter() { }
public override bool CanConvertFrom (ITypeDescriptorContext context,
Type sourceType)
{
if (sourceType == typeof (string))
return true;
return base.CanConvertFrom (context, sourceType);
}
public override bool CanConvertTo (ITypeDescriptorContext context,
Type destinationType)
{
if (destinationType == typeof (string))
return true;
if (destinationType == typeof (InstanceDescriptor))
return true;
return base.CanConvertTo (context, destinationType);
}
public override object ConvertFrom (ITypeDescriptorContext context,
CultureInfo culture,
object value)
{
if (culture == null)
culture = CultureInfo.CurrentCulture;
string s = value as string;
if (s == null)
return base.ConvertFrom (context, culture, value);
string [] subs = s.Split (culture.TextInfo.ListSeparator.ToCharArray ());
Int32Converter converter = new Int32Converter ();
int[] numSubs = new int[subs.Length];
for (int i = 0; i < numSubs.Length; i++) {
numSubs[i] = (int) converter.ConvertFromString (context, culture, subs[i]);
}
if (subs.Length != 2)
throw new ArgumentException ("Failed to parse Text(" + s + ") expected text in the format \"x, y.\"");
return new Point (numSubs[0], numSubs[1]);
}
public override object ConvertTo (ITypeDescriptorContext context,
CultureInfo culture,
object value,
Type destinationType)
{
if (culture == null)
culture = CultureInfo.CurrentCulture;
// LAMESPEC: "The default implementation calls the object's
// ToString method if the object is valid and if the destination
// type is string." MS does not behave as per the specs.
// Oh well, we have to be compatible with MS.
if (value is Point) {
Point point = (Point) value;
if (destinationType == typeof (string)) {
return point.X.ToString (culture) + culture.TextInfo.ListSeparator
+ " " + point.Y.ToString (culture);
} else if (destinationType == typeof (InstanceDescriptor)) {
ConstructorInfo ctor = typeof(Point).GetConstructor (new Type[] {typeof(int), typeof(int)} );
return new InstanceDescriptor (ctor, new object[] {point.X, point.Y });
}
}
return base.ConvertTo (context, culture, value, destinationType);
}
public override object CreateInstance (ITypeDescriptorContext context,
IDictionary propertyValues)
{
object ox = propertyValues ["X"];
object oy = propertyValues ["Y"];
if ((ox == null) || (oy == null))
throw new ArgumentException ("propertyValues");
int x = (int) ox;
int y = (int) oy;
return new Point (x, y);
}
public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
{
return true;
}
public override PropertyDescriptorCollection GetProperties (
ITypeDescriptorContext context,
object value, Attribute[] attributes)
{
if (value is Point)
return TypeDescriptor.GetProperties (value, attributes);
return base.GetProperties (context, value, attributes);
}
public override bool GetPropertiesSupported (ITypeDescriptorContext context)
{
return true;
}
}
}

View File

@ -1,259 +0,0 @@
//
// System.Drawing.PointF.cs
//
// Author:
// Mike Kestner (mkestner@speakeasy.net)
//
// Copyright (C) 2001 Mike Kestner
// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace System.Drawing
{
[Serializable]
[ComVisible (true)]
public struct PointF
{
// Private x and y coordinate fields.
private float x, y;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized PointF Structure.
/// </remarks>
public static readonly PointF Empty;
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Translates a PointF using the Width and Height
/// properties of the given Size.
/// </remarks>
public static PointF operator + (PointF pt, Size sz)
{
return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
}
public static PointF operator + (PointF pt, SizeF sz)
{
return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two PointF objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator == (PointF left, PointF right)
{
return ((left.X == right.X) && (left.Y == right.Y));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two PointF objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator != (PointF left, PointF right)
{
return ((left.X != right.X) || (left.Y != right.Y));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Translates a PointF using the negation of the Width
/// and Height properties of the given Size.
/// </remarks>
public static PointF operator - (PointF pt, Size sz)
{
return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
}
public static PointF operator - (PointF pt, SizeF sz)
{
return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
}
// -----------------------
// Public Constructor
// -----------------------
/// <summary>
/// PointF Constructor
/// </summary>
///
/// <remarks>
/// Creates a PointF from a specified x,y coordinate pair.
/// </remarks>
public PointF (float x, float y)
{
this.x = x;
this.y = y;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both X and Y are zero.
/// </remarks>
[Browsable (false)]
public bool IsEmpty {
get {
return ((x == 0.0) && (y == 0.0));
}
}
/// <summary>
/// X Property
/// </summary>
///
/// <remarks>
/// The X coordinate of the PointF.
/// </remarks>
public float X {
get {
return x;
}
set {
x = value;
}
}
/// <summary>
/// Y Property
/// </summary>
///
/// <remarks>
/// The Y coordinate of the PointF.
/// </remarks>
public float Y {
get {
return y;
}
set {
y = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this PointF and another object.
/// </remarks>
public override bool Equals (object obj)
{
if (!(obj is PointF))
return false;
return (this == (PointF) obj);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return (int) x ^ (int) y;
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the PointF as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return String.Format ("{{X={0}, Y={1}}}", x.ToString (CultureInfo.CurrentCulture),
y.ToString (CultureInfo.CurrentCulture));
}
public static PointF Add (PointF pt, Size sz)
{
return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
}
public static PointF Add (PointF pt, SizeF sz)
{
return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
}
public static PointF Subtract (PointF pt, Size sz)
{
return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
}
public static PointF Subtract (PointF pt, SizeF sz)
{
return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,356 +0,0 @@
//
// System.Drawing.Size.cs
//
// Author:
// Mike Kestner (mkestner@speakeasy.net)
//
// Copyright (C) 2001 Mike Kestner
// Copyright (C) 2004 Novell, Inc. http://www.novell.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace System.Drawing
{
[Serializable]
[ComVisible (true)]
#if !MONOTOUCH && !MONOMAC && FEATURE_TYPECONVERTER
[TypeConverter (typeof (SizeConverter))]
#endif
public struct Size
{
// Private Height and width fields.
private int width, height;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized Size Structure.
/// </remarks>
public static readonly Size Empty;
/// <summary>
/// Ceiling Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Size structure from a SizeF structure by
/// taking the ceiling of the Width and Height properties.
/// </remarks>
public static Size Ceiling (SizeF value)
{
int w, h;
checked {
w = (int) Math.Ceiling (value.Width);
h = (int) Math.Ceiling (value.Height);
}
return new Size (w, h);
}
/// <summary>
/// Round Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Size structure from a SizeF structure by
/// rounding the Width and Height properties.
/// </remarks>
public static Size Round (SizeF value)
{
int w, h;
checked {
w = (int) Math.Round (value.Width);
h = (int) Math.Round (value.Height);
}
return new Size (w, h);
}
/// <summary>
/// Truncate Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Size structure from a SizeF structure by
/// truncating the Width and Height properties.
/// </remarks>
public static Size Truncate (SizeF value)
{
int w, h;
checked {
w = (int) value.Width;
h = (int) value.Height;
}
return new Size (w, h);
}
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Addition of two Size structures.
/// </remarks>
public static Size operator + (Size sz1, Size sz2)
{
return new Size (sz1.Width + sz2.Width,
sz1.Height + sz2.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two Size objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator == (Size sz1, Size sz2)
{
return ((sz1.Width == sz2.Width) &&
(sz1.Height == sz2.Height));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two Size objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator != (Size sz1, Size sz2)
{
return ((sz1.Width != sz2.Width) ||
(sz1.Height != sz2.Height));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Subtracts two Size structures.
/// </remarks>
public static Size operator - (Size sz1, Size sz2)
{
return new Size (sz1.Width - sz2.Width,
sz1.Height - sz2.Height);
}
/// <summary>
/// Size to Point Conversion
/// </summary>
///
/// <remarks>
/// Returns a Point based on the dimensions of a given
/// Size. Requires explicit cast.
/// </remarks>
public static explicit operator Point (Size size)
{
return new Point (size.Width, size.Height);
}
/// <summary>
/// Size to SizeF Conversion
/// </summary>
///
/// <remarks>
/// Creates a SizeF based on the dimensions of a given
/// Size. No explicit cast is required.
/// </remarks>
public static implicit operator SizeF (Size p)
{
return new SizeF (p.Width, p.Height);
}
// -----------------------
// Public Constructors
// -----------------------
/// <summary>
/// Size Constructor
/// </summary>
///
/// <remarks>
/// Creates a Size from a Point value.
/// </remarks>
public Size (Point pt)
{
width = pt.X;
height = pt.Y;
}
/// <summary>
/// Size Constructor
/// </summary>
///
/// <remarks>
/// Creates a Size from specified dimensions.
/// </remarks>
public Size (int width, int height)
{
this.width = width;
this.height = height;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both Width and Height are zero.
/// </remarks>
[Browsable (false)]
public bool IsEmpty {
get {
return ((width == 0) && (height == 0));
}
}
/// <summary>
/// Width Property
/// </summary>
///
/// <remarks>
/// The Width coordinate of the Size.
/// </remarks>
public int Width {
get {
return width;
}
set {
width = value;
}
}
/// <summary>
/// Height Property
/// </summary>
///
/// <remarks>
/// The Height coordinate of the Size.
/// </remarks>
public int Height {
get {
return height;
}
set {
height = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this Size and another object.
/// </remarks>
public override bool Equals (object obj)
{
if (!(obj is Size))
return false;
return (this == (Size) obj);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return width^height;
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the Size as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return String.Format ("{{Width={0}, Height={1}}}", width, height);
}
public static Size Add (Size sz1, Size sz2)
{
return new Size (sz1.Width + sz2.Width,
sz1.Height + sz2.Height);
}
public static Size Subtract (Size sz1, Size sz2)
{
return new Size (sz1.Width - sz2.Width,
sz1.Height - sz2.Height);
}
}
}

View File

@ -1,149 +0,0 @@
//
// System.Drawing.SizeConverter.cs
//
// Authors:
// Dennis Hayes (dennish@Raytek.com)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Ravindra (rkumar@novell.com)
//
// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2003,2004,2006,2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace System.Drawing {
public class SizeConverter : TypeConverter
{
public SizeConverter()
{
}
public override bool CanConvertFrom (ITypeDescriptorContext context,
Type sourceType)
{
if (sourceType == typeof (string))
return true;
return base.CanConvertFrom (context, sourceType);
}
public override bool CanConvertTo (ITypeDescriptorContext context,
Type destinationType)
{
if (destinationType == typeof (string))
return true;
if (destinationType == typeof (InstanceDescriptor))
return true;
return base.CanConvertTo (context, destinationType);
}
public override object ConvertFrom (ITypeDescriptorContext context,
CultureInfo culture,
object value)
{
if (culture == null)
culture = CultureInfo.CurrentCulture;
string s = value as string;
if (s == null)
return base.ConvertFrom (context, culture, value);
string[] subs = s.Split (culture.TextInfo.ListSeparator.ToCharArray ());
Int32Converter converter = new Int32Converter ();
int[] numSubs = new int[subs.Length];
for (int i = 0; i < numSubs.Length; i++) {
numSubs[i] = (int) converter.ConvertFromString (context, culture, subs[i]);
}
if (subs.Length != 2)
throw new ArgumentException ("Failed to parse Text(" + s + ") expected text in the format \"Width,Height.\"");
return new Size (numSubs[0], numSubs[1]);
}
public override object ConvertTo (ITypeDescriptorContext context,
CultureInfo culture,
object value,
Type destinationType)
{
if (culture == null)
culture = CultureInfo.CurrentCulture;
// LAMESPEC: "The default implementation calls the ToString method
// of the object if the object is valid and if the destination
// type is string." MS does not behave as per the specs.
// Oh well, we have to be compatible with MS.
if (value is Size) {
Size size = (Size) value;
if (destinationType == typeof (string)) {
return size.Width.ToString (culture) + culture.TextInfo.ListSeparator
+ " " + size.Height.ToString (culture);
} else if (destinationType == typeof (InstanceDescriptor)) {
ConstructorInfo ctor = typeof(Size).GetConstructor (new Type[] {typeof(int), typeof(int)});
return new InstanceDescriptor (ctor, new object[] { size.Width, size.Height });
}
}
return base.ConvertTo (context, culture, value, destinationType);
}
public override object CreateInstance (ITypeDescriptorContext context,
IDictionary propertyValues)
{
object ow = propertyValues ["Width"];
object oh = propertyValues ["Height"];
if ((ow == null) || (oh == null))
throw new ArgumentException ("propertyValues");
int width = (int) ow;
int height = (int) oh;
return new Size (width, height);
}
public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
{
return true;
}
public override PropertyDescriptorCollection GetProperties (
ITypeDescriptorContext context,
object value, Attribute[] attributes)
{
if (value is Size)
return TypeDescriptor.GetProperties (value, attributes);
return base.GetProperties (context, value, attributes);
}
public override bool GetPropertiesSupported (ITypeDescriptorContext context)
{
return true;
}
}
}

View File

@ -1,310 +0,0 @@
//
// System.Drawing.SizeF.cs
//
// Author:
// Mike Kestner (mkestner@speakeasy.net)
//
// Copyright (C) 2001 Mike Kestner
// Copyright (C) 2004 Novell, Inc. http://www.novell.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace System.Drawing
{
[Serializable]
[ComVisible (true)]
#if !MONOTOUCH && !MONOMAC && FEATURE_TYPECONVERTER
[TypeConverter (typeof (SizeFConverter))]
#endif
public struct SizeF
{
// Private height and width fields.
private float width, height;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized SizeF Structure.
/// </remarks>
public static readonly SizeF Empty;
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Addition of two SizeF structures.
/// </remarks>
public static SizeF operator + (SizeF sz1, SizeF sz2)
{
return new SizeF (sz1.Width + sz2.Width,
sz1.Height + sz2.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two SizeF objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator == (SizeF sz1, SizeF sz2)
{
return ((sz1.Width == sz2.Width) &&
(sz1.Height == sz2.Height));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two SizeF objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator != (SizeF sz1, SizeF sz2)
{
return ((sz1.Width != sz2.Width) ||
(sz1.Height != sz2.Height));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Subtracts two SizeF structures.
/// </remarks>
public static SizeF operator - (SizeF sz1, SizeF sz2)
{
return new SizeF (sz1.Width - sz2.Width,
sz1.Height - sz2.Height);
}
/// <summary>
/// SizeF to PointF Conversion
/// </summary>
///
/// <remarks>
/// Returns a PointF based on the dimensions of a given
/// SizeF. Requires explicit cast.
/// </remarks>
public static explicit operator PointF (SizeF size)
{
return new PointF (size.Width, size.Height);
}
// -----------------------
// Public Constructors
// -----------------------
/// <summary>
/// SizeF Constructor
/// </summary>
///
/// <remarks>
/// Creates a SizeF from a PointF value.
/// </remarks>
public SizeF (PointF pt)
{
width = pt.X;
height = pt.Y;
}
/// <summary>
/// SizeF Constructor
/// </summary>
///
/// <remarks>
/// Creates a SizeF from an existing SizeF value.
/// </remarks>
public SizeF (SizeF size)
{
width = size.Width;
height = size.Height;
}
/// <summary>
/// SizeF Constructor
/// </summary>
///
/// <remarks>
/// Creates a SizeF from specified dimensions.
/// </remarks>
public SizeF (float width, float height)
{
this.width = width;
this.height = height;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both Width and Height are zero.
/// </remarks>
[Browsable (false)]
public bool IsEmpty {
get {
return ((width == 0.0) && (height == 0.0));
}
}
/// <summary>
/// Width Property
/// </summary>
///
/// <remarks>
/// The Width coordinate of the SizeF.
/// </remarks>
public float Width {
get {
return width;
}
set {
width = value;
}
}
/// <summary>
/// Height Property
/// </summary>
///
/// <remarks>
/// The Height coordinate of the SizeF.
/// </remarks>
public float Height {
get {
return height;
}
set {
height = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this SizeF and another object.
/// </remarks>
public override bool Equals (object obj)
{
if (!(obj is SizeF))
return false;
return (this == (SizeF) obj);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return (int) width ^ (int) height;
}
public PointF ToPointF ()
{
return new PointF (width, height);
}
public Size ToSize ()
{
int w, h;
checked {
w = (int) width;
h = (int) height;
}
return new Size (w, h);
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the SizeF as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return string.Format ("{{Width={0}, Height={1}}}", width.ToString (CultureInfo.CurrentCulture),
height.ToString (CultureInfo.CurrentCulture));
}
public static SizeF Add (SizeF sz1, SizeF sz2)
{
return new SizeF (sz1.Width + sz2.Width,
sz1.Height + sz2.Height);
}
public static SizeF Subtract (SizeF sz1, SizeF sz2)
{
return new SizeF (sz1.Width - sz2.Width,
sz1.Height - sz2.Height);
}
}
}

View File

@ -1,134 +0,0 @@
//
// Copyright (C) 2005, 2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Authors:
//
// Dennis Hayes (dennish@Raytek.com)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Ravindra (rkumar@novell.com)
// Jordi Mas i Hernandez <jordimash@gmail.com>
//
//
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace System.Drawing
{
public class SizeFConverter : TypeConverter
{
public SizeFConverter ()
{
}
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof (string))
return true;
return base.CanConvertFrom (context, sourceType);
}
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof (string))
return true;
if (destinationType == typeof (InstanceDescriptor))
return true;
return base.CanConvertTo (context, destinationType);
}
public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
{
string s = value as string;
if (s == null)
return base.ConvertFrom (context, culture, value);
if (culture == null)
culture = CultureInfo.CurrentCulture;
string[] subs = s.Split (culture.TextInfo.ListSeparator.ToCharArray ());
SingleConverter converter = new SingleConverter ();
float[] numSubs = new float[subs.Length];
for (int i = 0; i < numSubs.Length; i++) {
numSubs[i] = (float) converter.ConvertFromString (context, culture, subs[i]);
}
if (subs.Length != 2)
throw new ArgumentException ("Failed to parse Text(" + s + ") expected text in the format \"Width,Height.\"");
return new SizeF (numSubs[0], numSubs[1]);
}
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is SizeF) {
SizeF size = (SizeF) value;
if (destinationType == typeof (string)) {
return size.Width.ToString (culture) + culture.TextInfo.ListSeparator
+ " " + size.Height.ToString (culture);
} else if (destinationType == typeof (InstanceDescriptor)) {
ConstructorInfo ctor = typeof(SizeF).GetConstructor (new Type[] {typeof(float), typeof(float)});
return new InstanceDescriptor (ctor, new object[] { size.Width, size.Height});
}
}
return base.ConvertTo (context, culture, value, destinationType);
}
public override object CreateInstance (ITypeDescriptorContext context, IDictionary propertyValues)
{
float w = (float) propertyValues ["Width"];
float h = (float) propertyValues ["Height"];
return new SizeF (w, h);
}
public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
{
return true;
}
public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context, object value, Attribute[] attributes)
{
if (value is SizeF)
return TypeDescriptor.GetProperties (value, attributes);
return base.GetProperties (context, value, attributes);
}
public override bool GetPropertiesSupported (ITypeDescriptorContext context)
{
return true;
}
}
}

View File

@ -1,171 +0,0 @@
//
// System.Drawing.SystemColors
//
// Copyright (C) 2002 Ximian, Inc (http://www.ximian.com)
// Copyright (C) 2004-2005, 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
// Peter Dennis Bartok (pbartok@novell.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
namespace System.Drawing {
public sealed class SystemColors {
private SystemColors ()
{
}
static public Color ActiveBorder {
get { return KnownColors.FromKnownColor (KnownColor.ActiveBorder); }
}
static public Color ActiveCaption {
get { return KnownColors.FromKnownColor (KnownColor.ActiveCaption); }
}
static public Color ActiveCaptionText {
get { return KnownColors.FromKnownColor (KnownColor.ActiveCaptionText); }
}
static public Color AppWorkspace {
get { return KnownColors.FromKnownColor (KnownColor.AppWorkspace); }
}
static public Color Control {
get { return KnownColors.FromKnownColor (KnownColor.Control); }
}
static public Color ControlDark {
get { return KnownColors.FromKnownColor (KnownColor.ControlDark); }
}
static public Color ControlDarkDark {
get { return KnownColors.FromKnownColor (KnownColor.ControlDarkDark); }
}
static public Color ControlLight {
get { return KnownColors.FromKnownColor (KnownColor.ControlLight); }
}
static public Color ControlLightLight {
get { return KnownColors.FromKnownColor (KnownColor.ControlLightLight); }
}
static public Color ControlText {
get { return KnownColors.FromKnownColor (KnownColor.ControlText); }
}
static public Color Desktop {
get { return KnownColors.FromKnownColor (KnownColor.Desktop); }
}
static public Color GrayText {
get { return KnownColors.FromKnownColor (KnownColor.GrayText); }
}
static public Color Highlight {
get { return KnownColors.FromKnownColor (KnownColor.Highlight); }
}
static public Color HighlightText {
get { return KnownColors.FromKnownColor (KnownColor.HighlightText); }
}
static public Color HotTrack {
get { return KnownColors.FromKnownColor (KnownColor.HotTrack); }
}
static public Color InactiveBorder {
get { return KnownColors.FromKnownColor (KnownColor.InactiveBorder); }
}
static public Color InactiveCaption {
get { return KnownColors.FromKnownColor (KnownColor.InactiveCaption); }
}
static public Color InactiveCaptionText {
get { return KnownColors.FromKnownColor (KnownColor.InactiveCaptionText); }
}
static public Color Info {
get { return KnownColors.FromKnownColor (KnownColor.Info); }
}
static public Color InfoText {
get { return KnownColors.FromKnownColor (KnownColor.InfoText); }
}
static public Color Menu {
get { return KnownColors.FromKnownColor (KnownColor.Menu); }
}
static public Color MenuText {
get { return KnownColors.FromKnownColor (KnownColor.MenuText); }
}
static public Color ScrollBar {
get { return KnownColors.FromKnownColor (KnownColor.ScrollBar); }
}
static public Color Window {
get { return KnownColors.FromKnownColor (KnownColor.Window); }
}
static public Color WindowFrame {
get { return KnownColors.FromKnownColor (KnownColor.WindowFrame); }
}
static public Color WindowText {
get { return KnownColors.FromKnownColor (KnownColor.WindowText); }
}
static public Color ButtonFace {
get { return KnownColors.FromKnownColor (KnownColor.ButtonFace); }
}
static public Color ButtonHighlight {
get { return KnownColors.FromKnownColor (KnownColor.ButtonHighlight); }
}
static public Color ButtonShadow {
get { return KnownColors.FromKnownColor (KnownColor.ButtonShadow); }
}
static public Color GradientActiveCaption {
get { return KnownColors.FromKnownColor (KnownColor.GradientActiveCaption); }
}
static public Color GradientInactiveCaption {
get { return KnownColors.FromKnownColor (KnownColor.GradientInactiveCaption); }
}
static public Color MenuBar {
get { return KnownColors.FromKnownColor (KnownColor.MenuBar); }
}
static public Color MenuHighlight {
get { return KnownColors.FromKnownColor (KnownColor.MenuHighlight); }
}
}
}