From 7bcbfc7072d119a2b950040f95d40d8441e8857c Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Thu, 8 Dec 2011 00:03:14 +0000 Subject: [PATCH] Added conditional compilation and the necessary classes to compile OpenTK without referencing System.Drawing.dll. To build without System.Drawing, add "MINIMAL" to the conditional compilation symbols. Note that this is an experimental feature that will result in a source- and binary-incompatible dll. --- Source/OpenTK/DisplayDevice.cs | 2 + Source/OpenTK/DisplayResolution.cs | 2 + Source/OpenTK/GameWindow.cs | 2 + Source/OpenTK/Graphics/Color4.cs | 11 +- Source/OpenTK/Graphics/ES20/Helper.cs | 13 +- Source/OpenTK/Graphics/OpenGL/GLHelper.cs | 27 +- Source/OpenTK/INativeWindow.cs | 8 +- Source/OpenTK/Input/MouseDevice.cs | 7 +- Source/OpenTK/Minimal.cs | 2108 ++++++++++++++++- Source/OpenTK/NativeWindow.cs | 2 + Source/OpenTK/Platform/INativeGLWindow.cs | 4 +- .../MacOS/CarbonBindings/CarbonAPI.cs | 3 + .../OpenTK/Platform/MacOS/CarbonGLNative.cs | 6 + .../MacOS/QuartzDisplayDeviceDriver.cs | 2 + Source/OpenTK/Platform/Windows/API.cs | 2 + Source/OpenTK/Platform/Windows/WMInput.cs | 2 + Source/OpenTK/Platform/Windows/WinGLNative.cs | 2 + Source/OpenTK/Platform/X11/Functions.cs | 14 +- Source/OpenTK/Platform/X11/Structs.cs | 2 + .../OpenTK/Platform/X11/X11DisplayDevice.cs | 2 + Source/OpenTK/Platform/X11/X11GLNative.cs | 6 +- Source/OpenTK/Platform/X11/X11Input.cs | 4 +- 22 files changed, 2194 insertions(+), 37 deletions(-) diff --git a/Source/OpenTK/DisplayDevice.cs b/Source/OpenTK/DisplayDevice.cs index a95cb19a..13380180 100644 --- a/Source/OpenTK/DisplayDevice.cs +++ b/Source/OpenTK/DisplayDevice.cs @@ -28,7 +28,9 @@ using System; using System.Collections.Generic; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif namespace OpenTK { diff --git a/Source/OpenTK/DisplayResolution.cs b/Source/OpenTK/DisplayResolution.cs index 703a203b..02fd04fa 100644 --- a/Source/OpenTK/DisplayResolution.cs +++ b/Source/OpenTK/DisplayResolution.cs @@ -10,7 +10,9 @@ using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif namespace OpenTK { diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index c6261c3c..96b2b06d 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -29,7 +29,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif using System.Threading; using OpenTK.Graphics; using OpenTK.Input; diff --git a/Source/OpenTK/Graphics/Color4.cs b/Source/OpenTK/Graphics/Color4.cs index 56bc3533..972747ac 100644 --- a/Source/OpenTK/Graphics/Color4.cs +++ b/Source/OpenTK/Graphics/Color4.cs @@ -27,6 +27,9 @@ using System; using System.Collections.Generic; +#if !MINIMAL +using System.Drawing; +#endif using System.Text; using System.Xml.Serialization; @@ -99,7 +102,7 @@ namespace OpenTK.Graphics /// /// The System.Drawing.Color containing the component values. [Obsolete("Use new Color4(r, g, b, a) instead.")] - public Color4(System.Drawing.Color color) + public Color4(Color color) : this(color.R, color.G, color.B, color.A) { } @@ -150,7 +153,7 @@ namespace OpenTK.Graphics /// /// The System.Drawing.Color to convert. /// A new Color4 structure containing the converted components. - public static implicit operator Color4(System.Drawing.Color color) + public static implicit operator Color4(Color color) { return new Color4(color.R, color.G, color.B, color.A); } @@ -160,9 +163,9 @@ namespace OpenTK.Graphics /// /// The Color4 to convert. /// A new System.Drawing.Color structure containing the converted components. - public static explicit operator System.Drawing.Color(Color4 color) + public static explicit operator Color(Color4 color) { - return System.Drawing.Color.FromArgb( + return Color.FromArgb( (int)(color.A * Byte.MaxValue), (int)(color.R * Byte.MaxValue), (int)(color.G * Byte.MaxValue), diff --git a/Source/OpenTK/Graphics/ES20/Helper.cs b/Source/OpenTK/Graphics/ES20/Helper.cs index 28d2e883..f0046f36 100644 --- a/Source/OpenTK/Graphics/ES20/Helper.cs +++ b/Source/OpenTK/Graphics/ES20/Helper.cs @@ -27,6 +27,9 @@ using System; using System.Collections.Generic; +#if !MINIMAL +using System.Drawing; +#endif using System.Text; namespace OpenTK.Graphics.ES20 @@ -63,7 +66,7 @@ namespace OpenTK.Graphics.ES20 #region public static void ClearColor() overloads - public static void ClearColor(System.Drawing.Color color) + public static void ClearColor(Color color) { GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); } @@ -77,7 +80,7 @@ namespace OpenTK.Graphics.ES20 #region public static void BlendColor() overloads - public static void BlendColor(System.Drawing.Color color) + public static void BlendColor(Color color) { GL.BlendColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); } @@ -399,17 +402,17 @@ namespace OpenTK.Graphics.ES20 #region Viewport - public static void Viewport(System.Drawing.Size size) + public static void Viewport(Size size) { GL.Viewport(0, 0, size.Width, size.Height); } - public static void Viewport(System.Drawing.Point location, System.Drawing.Size size) + public static void Viewport(Point location, Size size) { GL.Viewport(location.X, location.Y, size.Width, size.Height); } - public static void Viewport(System.Drawing.Rectangle rectangle) + public static void Viewport(Rectangle rectangle) { GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); } diff --git a/Source/OpenTK/Graphics/OpenGL/GLHelper.cs b/Source/OpenTK/Graphics/OpenGL/GLHelper.cs index eca8ff49..0dc550fa 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLHelper.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLHelper.cs @@ -10,6 +10,9 @@ using System; using System.Collections.Generic; +#if !MINIMAL +using System.Drawing; +#endif using System.Text; using System.Runtime.InteropServices; using System.Reflection; @@ -103,12 +106,12 @@ namespace OpenTK.Graphics.OpenGL #region public static void Color[34]() overloads - public static void Color3(System.Drawing.Color color) + public static void Color3(Color color) { GL.Color3(color.R, color.G, color.B); } - public static void Color4(System.Drawing.Color color) + public static void Color4(Color color) { GL.Color4(color.R, color.G, color.B, color.A); } @@ -132,7 +135,7 @@ namespace OpenTK.Graphics.OpenGL #region public static void ClearColor() overloads - public static void ClearColor(System.Drawing.Color color) + public static void ClearColor(Color color) { GL.ClearColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); } @@ -146,7 +149,7 @@ namespace OpenTK.Graphics.OpenGL #region public static void BlendColor() overloads - public static void BlendColor(System.Drawing.Color color) + public static void BlendColor(Color color) { GL.BlendColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); } @@ -720,24 +723,24 @@ namespace OpenTK.Graphics.OpenGL #region Rect - public static void Rect(System.Drawing.RectangleF rect) + public static void Rect(RectangleF rect) { GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); } - public static void Rect(System.Drawing.Rectangle rect) + public static void Rect(Rectangle rect) { GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); } [CLSCompliant(false)] - public static void Rect(ref System.Drawing.RectangleF rect) + public static void Rect(ref RectangleF rect) { GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); } [CLSCompliant(false)] - public static void Rect(ref System.Drawing.Rectangle rect) + public static void Rect(ref Rectangle rect) { GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); } @@ -901,17 +904,17 @@ namespace OpenTK.Graphics.OpenGL #region Viewport - public static void Viewport(System.Drawing.Size size) + public static void Viewport(Size size) { GL.Viewport(0, 0, size.Width, size.Height); } - public static void Viewport(System.Drawing.Point location, System.Drawing.Size size) + public static void Viewport(Point location, Size size) { GL.Viewport(location.X, location.Y, size.Width, size.Height); } - public static void Viewport(System.Drawing.Rectangle rectangle) + public static void Viewport(Rectangle rectangle) { GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); } @@ -930,7 +933,7 @@ namespace OpenTK.Graphics.OpenGL #region TexEnv - public static void TexEnv(TextureEnvTarget target, TextureEnvParameter pname, System.Drawing.Color color) + public static void TexEnv(TextureEnvTarget target, TextureEnvParameter pname, Color color) { Color4 c = new Color4(color.R, color.G, color.B, color.A); unsafe diff --git a/Source/OpenTK/INativeWindow.cs b/Source/OpenTK/INativeWindow.cs index 137a4a8d..bb8016cc 100644 --- a/Source/OpenTK/INativeWindow.cs +++ b/Source/OpenTK/INativeWindow.cs @@ -27,10 +27,12 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Drawing; -using OpenTK.Platform; using System.ComponentModel; +#if !MINIMAL +using System.Drawing; +#endif +using System.Text; +using OpenTK.Platform; namespace OpenTK { diff --git a/Source/OpenTK/Input/MouseDevice.cs b/Source/OpenTK/Input/MouseDevice.cs index d0b92b22..79e1caa0 100644 --- a/Source/OpenTK/Input/MouseDevice.cs +++ b/Source/OpenTK/Input/MouseDevice.cs @@ -29,9 +29,12 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Drawing; using System.ComponentModel; +#if !MINIMAL +using System.Drawing; +#endif +using System.Text; + namespace OpenTK.Input { diff --git a/Source/OpenTK/Minimal.cs b/Source/OpenTK/Minimal.cs index c57692ac..af7b9b1e 100644 --- a/Source/OpenTK/Minimal.cs +++ b/Source/OpenTK/Minimal.cs @@ -2,13 +2,14 @@ using System.Collections.Generic; using System.Text; +#if IPHONE || MINIMAL + namespace OpenTK { // Override a number of System.* classes when compiling for // minimal targets (e.g. MonoTouch). // Note: the "overriden" classes must not be fully qualified for this to work! -#if IPHONE // System.Diagnostics.Debug static class Debug { @@ -89,5 +90,2108 @@ namespace OpenTK Never = 1, Advanced = 2, } -#endif + + #region RegistryKey + + class RegistryKey + { + public RegistryKey OpenSubKey(string name) + { + return new RegistryKey(); + } + + public object GetValue(string name) + { + return ""; + } + } + + #endregion + + #region Registry + + class Registry + { + public static readonly RegistryKey LocalMachine = new RegistryKey(); + } + + #endregion + + #region Point + + public struct Point : IEquatable + { + #region Fields + + int x, y; + + #endregion + + #region Constructors + + /// + /// Constructs a new Point instance. + /// + /// The X coordinate of this instance. + /// The Y coordinate of this instance. + public Point(int x, int y) + : this() + { + X = x; + Y = y; + } + + #endregion + + #region Public Members + + /// + /// Gets a that indicates whether this instance is empty or zero. + /// + public bool IsEmpty { get { return X == 0 && Y == 0; } } + + /// + /// Gets or sets the X coordinate of this instance. + /// + public int X { get { return x; } set { x = value; } } + + /// + /// Gets or sets the Y coordinate of this instance. + /// + public int Y { get { return y; } set { y = value; } } + + /// + /// Returns the Point (0, 0). + /// + public static readonly Point Zero = new Point(); + + /// + /// Returns the Point (0, 0). + /// + public static readonly Point Empty = new Point(); + + /// + /// Translates the specified Point by the specified Size. + /// + /// + /// The instance to translate. + /// + /// + /// The instance to translate point with. + /// + /// + /// A new instance translated by size. + /// + public static Point operator +(Point point, Size size) + { + return new Point(point.X + size.Width, point.Y + size.Height); + } + + /// + /// Translates the specified Point by the negative of the specified Size. + /// + /// + /// The instance to translate. + /// + /// + /// The instance to translate point with. + /// + /// + /// A new instance translated by size. + /// + public static Point operator -(Point point, Size size) + { + return new Point(point.X - size.Width, point.Y - size.Height); + } + + /// + /// Compares two instances for equality. + /// + /// The first instance. + /// The second instance. + /// True, if left is equal to right; false otherwise. + public static bool operator ==(Point left, Point right) + { + return left.Equals(right); + } + + /// + /// Compares two instances for inequality. + /// + /// The first instance. + /// The second instance. + /// True, if left is not equal to right; false otherwise. + public static bool operator !=(Point left, Point right) + { + return !left.Equals(right); + } + + /// + /// Indicates whether this instance is equal to the specified object. + /// + /// The object instance to compare to. + /// True, if both instances are equal; false otherwise. + public override bool Equals(object obj) + { + if (obj is Point) + return Equals((Point)obj); + + return false; + } + + /// + /// Returns the hash code for this instance. + /// + /// A that represents the hash code for this instance./> + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode(); + } + + /// + /// Returns a that describes this instance. + /// + /// A that describes this instance. + public override string ToString() + { + return String.Format("{{{0}, {1}}}", X, Y); + } + + #endregion + + #region IEquatable Members + + /// + /// Indicates whether this instance is equal to the specified Point. + /// + /// The instance to compare to. + /// True, if both instances are equal; false otherwise. + public bool Equals(Point other) + { + return X == other.X && Y == other.Y; + } + + #endregion + } + + #endregion + + #region PointF + + public struct PointF : IEquatable + { + #region Fields + + float x, y; + + #endregion + + #region Constructors + + /// + /// Constructs a new PointF instance. + /// + /// The X coordinate of this instance. + /// The Y coordinate of this instance. + public PointF(float x, float y) + : this() + { + X = x; + Y = y; + } + + #endregion + + #region Public Members + + /// + /// Gets a that indicates whether this instance is empty or zero. + /// + public bool IsEmpty { get { return X == 0 && Y == 0; } } + + /// + /// Gets or sets the X coordinate of this instance. + /// + public float X { get { return x; } set { x = value; } } + + /// + /// Gets or sets the Y coordinate of this instance. + /// + public float Y { get { return y; } set { y = value; } } + + /// + /// Returns the PointF (0, 0). + /// + public static readonly PointF Zero = new PointF(); + + /// + /// Returns the PointF (0, 0). + /// + public static readonly PointF Empty = new PointF(); + + /// + /// Translates the specified PointF by the specified Size. + /// + /// + /// The instance to translate. + /// + /// + /// The instance to translate point with. + /// + /// + /// A new instance translated by size. + /// + public static PointF operator +(PointF point, SizeF size) + { + return new PointF(point.X + size.Width, point.Y + size.Height); + } + + /// + /// Translates the specified PointF by the negative of the specified Size. + /// + /// + /// The instance to translate. + /// + /// + /// The instance to translate point with. + /// + /// + /// A new instance translated by size. + /// + public static PointF operator -(PointF point, SizeF size) + { + return new PointF(point.X - size.Width, point.Y - size.Height); + } + + /// + /// Compares two instances for equality. + /// + /// The first instance. + /// The second instance. + /// True, if left is equal to right; false otherwise. + public static bool operator ==(PointF left, PointF right) + { + return left.Equals(right); + } + + /// + /// Compares two instances for inequality. + /// + /// The first instance. + /// The second instance. + /// True, if left is not equal to right; false otherwise. + public static bool operator !=(PointF left, PointF right) + { + return !left.Equals(right); + } + + /// + /// Indicates whether this instance is equal to the specified object. + /// + /// The object instance to compare to. + /// True, if both instances are equal; false otherwise. + public override bool Equals(object obj) + { + if (obj is PointF) + return Equals((PointF)obj); + + return false; + } + + /// + /// Returns the hash code for this instance. + /// + /// A that represents the hash code for this instance./> + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode(); + } + + /// + /// Returns a that describes this instance. + /// + /// A that describes this instance. + public override string ToString() + { + return String.Format("{{{0}, {1}}}", X, Y); + } + + #endregion + + #region IEquatable Members + + /// + /// Indicates whether this instance is equal to the specified PointF. + /// + /// The instance to compare to. + /// True, if both instances are equal; false otherwise. + public bool Equals(PointF other) + { + return X == other.X && Y == other.Y; + } + + #endregion + } + + #endregion + + #region Size + + public struct Size : IEquatable + { + #region Fields + + int width, height; + + #endregion + + #region Constructors + + /// + /// Constructs a new Size instance. + /// + /// The width of this instance. + /// The height of this instance. + public Size(int width, int height) + : this() + { + Width = width; + Height = height; + } + + #endregion + + #region Public Members + + /// + /// Gets or sets the width of this instance. + /// + public int Width + { + get { return width; } + set + { + if (width < 0) + throw new ArgumentOutOfRangeException(); + width = value; + } + } + + /// + /// Gets or sets the height of this instance. + /// + public int Height + { + get { return height; } + set + { + if (height < 0) + throw new ArgumentOutOfRangeException(); + height = value; + } + } + + /// + /// Gets a that indicates whether this instance is empty or zero. + /// + public bool IsEmpty + { + get { return Width == 0 && Height == 0; } + } + + /// + /// Returns a Size instance equal to (0, 0). + /// + public static readonly Size Empty = new Size(); + + /// + /// Returns a Size instance equal to (0, 0). + /// + public static readonly Size Zero = new Size(); + + /// + /// Compares two instances for equality. + /// + /// The first instance. + /// The second instance. + /// True, if left is equal to right; false otherwise. + public static bool operator ==(Size left, Size right) + { + return left.Equals(right); + } + + /// + /// Compares two instances for inequality. + /// + /// The first instance. + /// The second instance. + /// True, if left is not equal to right; false otherwise. + public static bool operator !=(Size left, Size right) + { + return !left.Equals(right); + } + + /// + /// Indicates whether this instance is equal to the specified object. + /// + /// The object instance to compare to. + /// True, if both instances are equal; false otherwise. + public override bool Equals(object obj) + { + if (obj is Size) + return Equals((Size)obj); + + return false; + } + + /// + /// Returns the hash code for this instance. + /// + /// A that represents the hash code for this instance./> + public override int GetHashCode() + { + return Width.GetHashCode() ^ Height.GetHashCode(); + } + + /// + /// Returns a that describes this instance. + /// + /// A that describes this instance. + public override string ToString() + { + return String.Format("{{{0}, {1}}}", Width, Height); + } + + #endregion + + #region IEquatable Members + + /// + /// Indicates whether this instance is equal to the specified Size. + /// + /// The instance to compare to. + /// True, if both instances are equal; false otherwise. + public bool Equals(Size other) + { + return Width == other.Width && Height == other.Height; + } + + #endregion + } + + #endregion + + #region SizeF + + public struct SizeF : IEquatable + { + #region Fields + + float width, height; + + #endregion + + #region Constructors + + /// + /// Constructs a new SizeF instance. + /// + /// The width of this instance. + /// The height of this instance. + public SizeF(float width, float height) + : this() + { + Width = width; + Height = height; + } + + #endregion + + #region Public Members + + /// + /// Gets or sets the width of this instance. + /// + public float Width + { + get { return width; } + set + { + if (width < 0) + throw new ArgumentOutOfRangeException(); + width = value; + } + } + + /// + /// Gets or sets the height of this instance. + /// + public float Height + { + get { return height; } + set + { + if (height < 0) + throw new ArgumentOutOfRangeException(); + height = value; + } + } + + /// + /// Gets a that indicates whether this instance is empty or zero. + /// + public bool IsEmpty + { + get { return Width == 0 && Height == 0; } + } + + /// + /// Returns a SizeF instance equal to (0, 0). + /// + public static readonly SizeF Empty = new SizeF(); + + /// + /// Returns a SizeF instance equal to (0, 0). + /// + public static readonly SizeF Zero = new SizeF(); + + /// + /// Compares two instances for equality. + /// + /// The first instance. + /// The second instance. + /// True, if left is equal to right; false otherwise. + public static bool operator ==(SizeF left, SizeF right) + { + return left.Equals(right); + } + + /// + /// Compares two instances for inequality. + /// + /// The first instance. + /// The second instance. + /// True, if left is not equal to right; false otherwise. + public static bool operator !=(SizeF left, SizeF right) + { + return !left.Equals(right); + } + + /// + /// Indicates whether this instance is equal to the specified object. + /// + /// The object instance to compare to. + /// True, if both instances are equal; false otherwise. + public override bool Equals(object obj) + { + if (obj is SizeF) + return Equals((SizeF)obj); + + return false; + } + + /// + /// Returns the hash code for this instance. + /// + /// A that represents the hash code for this instance./> + public override int GetHashCode() + { + return Width.GetHashCode() ^ Height.GetHashCode(); + } + + /// + /// Returns a that describes this instance. + /// + /// A that describes this instance. + public override string ToString() + { + return String.Format("{{{0}, {1}}}", Width, Height); + } + + #endregion + + #region IEquatable Members + + /// + /// Indicates whether this instance is equal to the specified SizeF. + /// + /// The instance to compare to. + /// True, if both instances are equal; false otherwise. + public bool Equals(SizeF other) + { + return Width == other.Width && Height == other.Height; + } + + #endregion + } + + #endregion + + #region Rectangle + + public struct Rectangle : IEquatable + { + #region Fields + + Point location; + Size size; + + #endregion + + #region Constructors + + /// + /// Constructs a new Rectangle instance. + /// + /// The top-left corner of the Rectangle. + /// The width and height of the Rectangle. + public Rectangle(Point location, Size size) + : this() + { + Location = location; + Size = size; + } + + /// + /// Constructs a new Rectangle instance. + /// + /// The x coordinate of the Rectangle. + /// The y coordinate of the Rectangle. + /// The width coordinate of the Rectangle. + /// The height coordinate of the Rectangle. + public Rectangle(int x, int y, int width, int height) + : this(new Point(x, y), new Size(width, height)) + { } + + #endregion + + #region Public Members + + /// + /// Gets or sets the x coordinate of the Rectangle. + /// + public int X + { + get { return Location.X; } + set { Location = new Point(value, Y); } + } + + /// + /// Gets or sets the y coordinate of the Rectangle. + /// + public int Y + { + get { return Location.Y; } + set { Location = new Point(X, value); } + } + + /// + /// Gets or sets the width of the Rectangle. + /// + public int Width + { + get { return Size.Width; } + set { Size = new Size(value, Height); } + } + + /// + /// Gets or sets the height of the Rectangle. + /// + public int Height + { + get { return Size.Height; } + set { Size = new Size(Width, value); } + } + + /// + /// Gets or sets a representing the x and y coordinates + /// of the Rectangle. + /// + public Point Location + { + get { return location; } + set { location = value; } + } + + /// + /// Gets or sets a representing the width and height + /// of the Rectangle. + /// + public Size Size + { + get { return size; } + set { size = value; } + } + + /// + /// Gets the y coordinate of the top edge of this Rectangle. + /// + public int Top { get { return Y; } } + + /// + /// Gets the x coordinate of the right edge of this Rectangle. + /// + public int Right { get { return X + Width; } } + + /// + /// Gets the y coordinate of the bottom edge of this Rectangle. + /// + public int Bottom { get { return Y + Height; } } + + /// + /// Gets the x coordinate of the left edge of this Rectangle. + /// + public int Left { get { return X; } } + + /// + /// Gets a that indicates whether this + /// Rectangle is equal to the empty Rectangle. + /// + public bool IsEmpty + { + get { return Location.IsEmpty && Size.IsEmpty; } + } + + /// + /// Defines the empty Rectangle. + /// + public static readonly Rectangle Zero = new Rectangle(); + + /// + /// Defines the empty Rectangle. + /// + public static readonly Rectangle Empty = new Rectangle(); + + /// + /// Constructs a new instance with the specified edges. + /// + /// The left edge of the Rectangle. + /// The top edge of the Rectangle. + /// The right edge of the Rectangle. + /// The bottom edge of the Rectangle. + /// A new Rectangle instance with the specified edges. + public static Rectangle FromLTRB(int left, int top, int right, int bottom) + { + return new Rectangle(new Point(left, top), new Size(right - left, bottom - top)); + } + + /// + /// Tests whether this instance contains the specified Point. + /// + /// The to test. + /// True if this instance contains point; false otherwise. + /// The left and top edges are inclusive. The right and bottom edges + /// are exclusive. + public bool Contains(Point point) + { + return point.X >= Left && point.X < Right && + point.Y >= Top && point.Y < Bottom; + } + + /// + /// Tests whether this instance contains the specified Rectangle. + /// + /// The to test. + /// True if this instance contains rect; false otherwise. + /// The left and top edges are inclusive. The right and bottom edges + /// are exclusive. + public bool Contains(Rectangle rect) + { + return Contains(rect.Location) && Contains(rect.Location + rect.Size); + } + + /// + /// Compares two instances for equality. + /// + /// The first instance. + /// The second instance. + /// True, if left is equal to right; false otherwise. + public static bool operator ==(Rectangle left, Rectangle right) + { + return left.Equals(right); + } + + /// + /// Compares two instances for inequality. + /// + /// The first instance. + /// The second instance. + /// True, if left is not equal to right; false otherwise. + public static bool operator !=(Rectangle left, Rectangle right) + { + return !left.Equals(right); + } + + /// + /// Indicates whether this instance is equal to the specified object. + /// + /// The object instance to compare to. + /// True, if both instances are equal; false otherwise. + public override bool Equals(object obj) + { + if (obj is Rectangle) + return Equals((Rectangle)obj); + + return false; + } + + /// + /// Returns the hash code for this instance. + /// + /// A that represents the hash code for this instance./> + public override int GetHashCode() + { + return Location.GetHashCode() & Size.GetHashCode(); + } + + /// + /// Returns a that describes this instance. + /// + /// A that describes this instance. + public override string ToString() + { + return String.Format("{{{0}-{1}}}", Location, Location + Size); + } + + + #endregion + + #region IEquatable Members + + /// + /// Indicates whether this instance is equal to the specified Rectangle. + /// + /// The instance to compare to. + /// True, if both instances are equal; false otherwise. + public bool Equals(Rectangle other) + { + return Location.Equals(other.Location) && + Size.Equals(other.Size); + } + + #endregion + } + + #endregion + + #region RectangleF + + public struct RectangleF : IEquatable + { + #region Fields + + PointF location; + SizeF size; + + #endregion + + #region Constructors + + /// + /// Constructs a new RectangleF instance. + /// + /// The top-left corner of the RectangleF. + /// The width and height of the RectangleF. + public RectangleF(PointF location, SizeF SizeF) + : this() + { + Location = location; + SizeF = SizeF; + } + + /// + /// Constructs a new RectangleF instance. + /// + /// The x coordinate of the RectangleF. + /// The y coordinate of the RectangleF. + /// The width coordinate of the RectangleF. + /// The height coordinate of the RectangleF. + public RectangleF(float x, float y, float width, float height) + : this(new PointF(x, y), new SizeF(width, height)) + { } + + #endregion + + #region Public Members + + /// + /// Gets or sets the x coordinate of the RectangleF. + /// + public float X + { + get { return Location.X; } + set { Location = new PointF(value, Y); } + } + + /// + /// Gets or sets the y coordinate of the RectangleF. + /// + public float Y + { + get { return Location.Y; } + set { Location = new PointF(X, value); } + } + + /// + /// Gets or sets the width of the RectangleF. + /// + public float Width + { + get { return Size.Width; } + set { Size = new SizeF(value, Height); } + } + + /// + /// Gets or sets the height of the RectangleF. + /// + public float Height + { + get { return Size.Height; } + set { Size = new SizeF(Width, value); } + } + + /// + /// Gets or sets a representing the x and y coordinates + /// of the RectangleF. + /// + public PointF Location + { + get { return location; } + set { location = value; } + } + + /// + /// Gets or sets a representing the width and height + /// of the RectangleF. + /// + public SizeF Size + { + get { return size; } + set { size = value; } + } + + /// + /// Gets the y coordinate of the top edge of this RectangleF. + /// + public float Top { get { return Y; } } + + /// + /// Gets the x coordinate of the right edge of this RectangleF. + /// + public float Right { get { return X + Width; } } + + /// + /// Gets the y coordinate of the bottom edge of this RectangleF. + /// + public float Bottom { get { return Y + Height; } } + + /// + /// Gets the x coordinate of the left edge of this RectangleF. + /// + public float Left { get { return X; } } + + /// + /// Gets a that indicates whether this + /// RectangleF is equal to the empty RectangleF. + /// + public bool IsEmpty + { + get { return Location.IsEmpty && Size.IsEmpty; } + } + + /// + /// Defines the empty RectangleF. + /// + public static readonly RectangleF Zero = new RectangleF(); + + /// + /// Defines the empty RectangleF. + /// + public static readonly RectangleF Empty = new RectangleF(); + + /// + /// Constructs a new instance with the specified edges. + /// + /// The left edge of the RectangleF. + /// The top edge of the RectangleF. + /// The right edge of the RectangleF. + /// The bottom edge of the RectangleF. + /// A new RectangleF instance with the specified edges. + public static RectangleF FromLTRB(float left, float top, float right, float bottom) + { + return new RectangleF(new PointF(left, top), new SizeF(right - left, bottom - top)); + } + + /// + /// Tests whether this instance contains the specified PointF. + /// + /// The to test. + /// True if this instance contains pofloat; false otherwise. + /// The left and top edges are inclusive. The right and bottom edges + /// are exclusive. + public bool Contains(PointF pofloat) + { + return pofloat.X >= Left && pofloat.X < Right && + pofloat.Y >= Top && pofloat.Y < Bottom; + } + + /// + /// Tests whether this instance contains the specified RectangleF. + /// + /// The to test. + /// True if this instance contains rect; false otherwise. + /// The left and top edges are inclusive. The right and bottom edges + /// are exclusive. + public bool Contains(RectangleF rect) + { + return Contains(rect.Location) && Contains(rect.Location + rect.Size); + } + + /// + /// Compares two instances for equality. + /// + /// The first instance. + /// The second instance. + /// True, if left is equal to right; false otherwise. + public static bool operator ==(RectangleF left, RectangleF right) + { + return left.Equals(right); + } + + /// + /// Compares two instances for inequality. + /// + /// The first instance. + /// The second instance. + /// True, if left is not equal to right; false otherwise. + public static bool operator !=(RectangleF left, RectangleF right) + { + return !left.Equals(right); + } + + /// + /// Indicates whether this instance is equal to the specified object. + /// + /// The object instance to compare to. + /// True, if both instances are equal; false otherwise. + public override bool Equals(object obj) + { + if (obj is RectangleF) + return Equals((RectangleF)obj); + + return false; + } + + /// + /// Returns the hash code for this instance. + /// + /// A that represents the hash code for this instance./> + public override int GetHashCode() + { + return Location.GetHashCode() & Size.GetHashCode(); + } + + /// + /// Returns a that describes this instance. + /// + /// A that describes this instance. + public override string ToString() + { + return String.Format("{{{0}-{1}}}", Location, Location + Size); + } + + #endregion + + #region IEquatable Members + + /// + /// Indicates whether this instance is equal to the specified RectangleF. + /// + /// The instance to compare to. + /// True, if both instances are equal; false otherwise. + public bool Equals(RectangleF other) + { + return Location.Equals(other.Location) && + Size.Equals(other.Size); + } + + #endregion + } + + #endregion + + #region Icon + + public sealed class Icon : IDisposable + { + IntPtr handle; + + public Icon(Icon icon, int width, int height) + { } + + public IntPtr Handle { get { return handle; } set { handle = value; } } + + public Bitmap ToBitmap() + { + return new Bitmap(); + } + + public void Dispose() + { } + } + + #endregion + + #region Image + + public abstract class Image { } + + #endregion + + #region Bitmap + + public sealed class Bitmap : Image + { + int width; + int height; + + public Bitmap() { } + + public Bitmap(int width, int height) + { + // TODO: Complete member initialization + this.width = width; + this.height = height; + } + + public int Width { get { return width; } } + public int Height { get { return height; } } + + public Color GetPixel(int x, int y) + { + return new Color(); + } + + internal void UnlockBits(BitmapData data) + { + throw new NotImplementedException(); + } + + internal BitmapData LockBits(Rectangle rectangle, ImageLockMode imageLockMode, PixelFormat pixelFormat) + { + return new BitmapData(); + } + } + + #endregion + + #region Color + + /// + /// Represents a color with 4 8bit components (R, G, B, A). + /// + [Serializable] + public struct Color : IEquatable + { + #region Fields + + /// + /// The red component of this Color structure. + /// + public byte R; + + /// + /// The green component of this Color structure. + /// + public byte G; + + /// + /// The blue component of this Color structure. + /// + public byte B; + + /// + /// The alpha component of this Color structure. + /// + public byte A; + + #endregion + + #region Constructors + + /// + /// Constructs a new Color structure from the specified components. + /// + /// The red component of the new Color structure. + /// The green component of the new Color structure. + /// The blue component of the new Color structure. + /// The alpha component of the new Color structure. + public Color(int r, int g, int b, int a) + { + R = (byte)r; + G = (byte)g; + B = (byte)b; + A = (byte)a; + } + + #endregion + + #region Public Members + + /// + /// Converts this color to an integer representation with 8 bits per channel. + /// + /// A that represents this instance. + /// This method is intended only for compatibility with System.Drawing. It compresses the color into 8 bits per channel, which means color information is lost. + public int ToArgb() + { + uint value = + (uint)(A * Byte.MaxValue) << 24 | + (uint)(R * Byte.MaxValue) << 16 | + (uint)(G * Byte.MaxValue) << 8 | + (uint)(B * Byte.MaxValue); + + return unchecked((int)value); + } + + /// + /// Compares the specified Color structures for equality. + /// + /// The left-hand side of the comparison. + /// The right-hand side of the comparison. + /// True if left is equal to right; false otherwise. + public static bool operator ==(Color left, Color right) + { + return left.Equals(right); + } + + /// + /// Compares the specified Color structures for inequality. + /// + /// The left-hand side of the comparison. + /// The right-hand side of the comparison. + /// True if left is not equal to right; false otherwise. + public static bool operator !=(Color left, Color right) + { + return !left.Equals(right); + } + + /// + /// Compares whether this Color structure is equal to the specified object. + /// + /// An object to compare to. + /// True obj is a Color structure with the same components as this Color; false otherwise. + public override bool Equals(object obj) + { + if (!(obj is Color)) + return false; + + return Equals((Color)obj); + } + + /// + /// Calculates the hash code for this Color structure. + /// + /// A System.Int32 containing the hashcode of this Color structure. + public override int GetHashCode() + { + return ToArgb(); + } + + /// + /// Creates a System.String that describes this Color structure. + /// + /// A System.String that describes this Color structure. + public override string ToString() + { + return String.Format("{{(R, G, B, A) = ({0}, {1}, {2}, {3})}}", R.ToString(), G.ToString(), B.ToString(), A.ToString()); + } + +#region System colors + + /// + /// Gets the system color with (R, G, B, A) = (255, 255, 255, 0). + /// + public static Color Transparent { get { return new Color(255, 255, 255, 0); } } + + /// + /// Gets the system color with (R, G, B, A) = (240, 248, 255, 255). + /// + public static Color AliceBlue { get { return new Color(240, 248, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (250, 235, 215, 255). + /// + public static Color AntiqueWhite { get { return new Color(250, 235, 215, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 255, 255, 255). + /// + public static Color Aqua { get { return new Color(0, 255, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (127, 255, 212, 255). + /// + public static Color Aquamarine { get { return new Color(127, 255, 212, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (240, 255, 255, 255). + /// + public static Color Azure { get { return new Color(240, 255, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (245, 245, 220, 255). + /// + public static Color Beige { get { return new Color(245, 245, 220, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 228, 196, 255). + /// + public static Color Bisque { get { return new Color(255, 228, 196, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 0, 0, 255). + /// + public static Color Black { get { return new Color(0, 0, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 235, 205, 255). + /// + public static Color BlanchedAlmond { get { return new Color(255, 235, 205, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 0, 255, 255). + /// + public static Color Blue { get { return new Color(0, 0, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (138, 43, 226, 255). + /// + public static Color BlueViolet { get { return new Color(138, 43, 226, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (165, 42, 42, 255). + /// + public static Color Brown { get { return new Color(165, 42, 42, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (222, 184, 135, 255). + /// + public static Color BurlyWood { get { return new Color(222, 184, 135, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (95, 158, 160, 255). + /// + public static Color CadetBlue { get { return new Color(95, 158, 160, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (127, 255, 0, 255). + /// + public static Color Chartreuse { get { return new Color(127, 255, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (210, 105, 30, 255). + /// + public static Color Chocolate { get { return new Color(210, 105, 30, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 127, 80, 255). + /// + public static Color Coral { get { return new Color(255, 127, 80, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (100, 149, 237, 255). + /// + public static Color CornflowerBlue { get { return new Color(100, 149, 237, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 248, 220, 255). + /// + public static Color Cornsilk { get { return new Color(255, 248, 220, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (220, 20, 60, 255). + /// + public static Color Crimson { get { return new Color(220, 20, 60, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 255, 255, 255). + /// + public static Color Cyan { get { return new Color(0, 255, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 0, 139, 255). + /// + public static Color DarkBlue { get { return new Color(0, 0, 139, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 139, 139, 255). + /// + public static Color DarkCyan { get { return new Color(0, 139, 139, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (184, 134, 11, 255). + /// + public static Color DarkGoldenrod { get { return new Color(184, 134, 11, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (169, 169, 169, 255). + /// + public static Color DarkGray { get { return new Color(169, 169, 169, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 100, 0, 255). + /// + public static Color DarkGreen { get { return new Color(0, 100, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (189, 183, 107, 255). + /// + public static Color DarkKhaki { get { return new Color(189, 183, 107, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (139, 0, 139, 255). + /// + public static Color DarkMagenta { get { return new Color(139, 0, 139, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (85, 107, 47, 255). + /// + public static Color DarkOliveGreen { get { return new Color(85, 107, 47, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 140, 0, 255). + /// + public static Color DarkOrange { get { return new Color(255, 140, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (153, 50, 204, 255). + /// + public static Color DarkOrchid { get { return new Color(153, 50, 204, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (139, 0, 0, 255). + /// + public static Color DarkRed { get { return new Color(139, 0, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (233, 150, 122, 255). + /// + public static Color DarkSalmon { get { return new Color(233, 150, 122, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (143, 188, 139, 255). + /// + public static Color DarkSeaGreen { get { return new Color(143, 188, 139, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (72, 61, 139, 255). + /// + public static Color DarkSlateBlue { get { return new Color(72, 61, 139, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (47, 79, 79, 255). + /// + public static Color DarkSlateGray { get { return new Color(47, 79, 79, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 206, 209, 255). + /// + public static Color DarkTurquoise { get { return new Color(0, 206, 209, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (148, 0, 211, 255). + /// + public static Color DarkViolet { get { return new Color(148, 0, 211, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 20, 147, 255). + /// + public static Color DeepPink { get { return new Color(255, 20, 147, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 191, 255, 255). + /// + public static Color DeepSkyBlue { get { return new Color(0, 191, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (105, 105, 105, 255). + /// + public static Color DimGray { get { return new Color(105, 105, 105, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (30, 144, 255, 255). + /// + public static Color DodgerBlue { get { return new Color(30, 144, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (178, 34, 34, 255). + /// + public static Color Firebrick { get { return new Color(178, 34, 34, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 250, 240, 255). + /// + public static Color FloralWhite { get { return new Color(255, 250, 240, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (34, 139, 34, 255). + /// + public static Color ForestGreen { get { return new Color(34, 139, 34, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 0, 255, 255). + /// + public static Color Fuchsia { get { return new Color(255, 0, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (220, 220, 220, 255). + /// + public static Color Gainsboro { get { return new Color(220, 220, 220, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (248, 248, 255, 255). + /// + public static Color GhostWhite { get { return new Color(248, 248, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 215, 0, 255). + /// + public static Color Gold { get { return new Color(255, 215, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (218, 165, 32, 255). + /// + public static Color Goldenrod { get { return new Color(218, 165, 32, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (128, 128, 128, 255). + /// + public static Color Gray { get { return new Color(128, 128, 128, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 128, 0, 255). + /// + public static Color Green { get { return new Color(0, 128, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (173, 255, 47, 255). + /// + public static Color GreenYellow { get { return new Color(173, 255, 47, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (240, 255, 240, 255). + /// + public static Color Honeydew { get { return new Color(240, 255, 240, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 105, 180, 255). + /// + public static Color HotPink { get { return new Color(255, 105, 180, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (205, 92, 92, 255). + /// + public static Color IndianRed { get { return new Color(205, 92, 92, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (75, 0, 130, 255). + /// + public static Color Indigo { get { return new Color(75, 0, 130, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 255, 240, 255). + /// + public static Color Ivory { get { return new Color(255, 255, 240, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (240, 230, 140, 255). + /// + public static Color Khaki { get { return new Color(240, 230, 140, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (230, 230, 250, 255). + /// + public static Color Lavender { get { return new Color(230, 230, 250, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 240, 245, 255). + /// + public static Color LavenderBlush { get { return new Color(255, 240, 245, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (124, 252, 0, 255). + /// + public static Color LawnGreen { get { return new Color(124, 252, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 250, 205, 255). + /// + public static Color LemonChiffon { get { return new Color(255, 250, 205, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (173, 216, 230, 255). + /// + public static Color LightBlue { get { return new Color(173, 216, 230, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (240, 128, 128, 255). + /// + public static Color LightCoral { get { return new Color(240, 128, 128, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (224, 255, 255, 255). + /// + public static Color LightCyan { get { return new Color(224, 255, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (250, 250, 210, 255). + /// + public static Color LightGoldenrodYellow { get { return new Color(250, 250, 210, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (144, 238, 144, 255). + /// + public static Color LightGreen { get { return new Color(144, 238, 144, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (211, 211, 211, 255). + /// + public static Color LightGray { get { return new Color(211, 211, 211, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 182, 193, 255). + /// + public static Color LightPink { get { return new Color(255, 182, 193, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 160, 122, 255). + /// + public static Color LightSalmon { get { return new Color(255, 160, 122, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (32, 178, 170, 255). + /// + public static Color LightSeaGreen { get { return new Color(32, 178, 170, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (135, 206, 250, 255). + /// + public static Color LightSkyBlue { get { return new Color(135, 206, 250, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (119, 136, 153, 255). + /// + public static Color LightSlateGray { get { return new Color(119, 136, 153, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (176, 196, 222, 255). + /// + public static Color LightSteelBlue { get { return new Color(176, 196, 222, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 255, 224, 255). + /// + public static Color LightYellow { get { return new Color(255, 255, 224, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 255, 0, 255). + /// + public static Color Lime { get { return new Color(0, 255, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (50, 205, 50, 255). + /// + public static Color LimeGreen { get { return new Color(50, 205, 50, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (250, 240, 230, 255). + /// + public static Color Linen { get { return new Color(250, 240, 230, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 0, 255, 255). + /// + public static Color Magenta { get { return new Color(255, 0, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (128, 0, 0, 255). + /// + public static Color Maroon { get { return new Color(128, 0, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (102, 205, 170, 255). + /// + public static Color MediumAquamarine { get { return new Color(102, 205, 170, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 0, 205, 255). + /// + public static Color MediumBlue { get { return new Color(0, 0, 205, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (186, 85, 211, 255). + /// + public static Color MediumOrchid { get { return new Color(186, 85, 211, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (147, 112, 219, 255). + /// + public static Color MediumPurple { get { return new Color(147, 112, 219, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (60, 179, 113, 255). + /// + public static Color MediumSeaGreen { get { return new Color(60, 179, 113, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (123, 104, 238, 255). + /// + public static Color MediumSlateBlue { get { return new Color(123, 104, 238, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 250, 154, 255). + /// + public static Color MediumSpringGreen { get { return new Color(0, 250, 154, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (72, 209, 204, 255). + /// + public static Color MediumTurquoise { get { return new Color(72, 209, 204, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (199, 21, 133, 255). + /// + public static Color MediumVioletRed { get { return new Color(199, 21, 133, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (25, 25, 112, 255). + /// + public static Color MidnightBlue { get { return new Color(25, 25, 112, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (245, 255, 250, 255). + /// + public static Color MintCream { get { return new Color(245, 255, 250, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 228, 225, 255). + /// + public static Color MistyRose { get { return new Color(255, 228, 225, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 228, 181, 255). + /// + public static Color Moccasin { get { return new Color(255, 228, 181, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 222, 173, 255). + /// + public static Color NavajoWhite { get { return new Color(255, 222, 173, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 0, 128, 255). + /// + public static Color Navy { get { return new Color(0, 0, 128, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (253, 245, 230, 255). + /// + public static Color OldLace { get { return new Color(253, 245, 230, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (128, 128, 0, 255). + /// + public static Color Olive { get { return new Color(128, 128, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (107, 142, 35, 255). + /// + public static Color OliveDrab { get { return new Color(107, 142, 35, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 165, 0, 255). + /// + public static Color Orange { get { return new Color(255, 165, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 69, 0, 255). + /// + public static Color OrangeRed { get { return new Color(255, 69, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (218, 112, 214, 255). + /// + public static Color Orchid { get { return new Color(218, 112, 214, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (238, 232, 170, 255). + /// + public static Color PaleGoldenrod { get { return new Color(238, 232, 170, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (152, 251, 152, 255). + /// + public static Color PaleGreen { get { return new Color(152, 251, 152, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (175, 238, 238, 255). + /// + public static Color PaleTurquoise { get { return new Color(175, 238, 238, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (219, 112, 147, 255). + /// + public static Color PaleVioletRed { get { return new Color(219, 112, 147, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 239, 213, 255). + /// + public static Color PapayaWhip { get { return new Color(255, 239, 213, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 218, 185, 255). + /// + public static Color PeachPuff { get { return new Color(255, 218, 185, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (205, 133, 63, 255). + /// + public static Color Peru { get { return new Color(205, 133, 63, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 192, 203, 255). + /// + public static Color Pink { get { return new Color(255, 192, 203, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (221, 160, 221, 255). + /// + public static Color Plum { get { return new Color(221, 160, 221, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (176, 224, 230, 255). + /// + public static Color PowderBlue { get { return new Color(176, 224, 230, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (128, 0, 128, 255). + /// + public static Color Purple { get { return new Color(128, 0, 128, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 0, 0, 255). + /// + public static Color Red { get { return new Color(255, 0, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (188, 143, 143, 255). + /// + public static Color RosyBrown { get { return new Color(188, 143, 143, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (65, 105, 225, 255). + /// + public static Color RoyalBlue { get { return new Color(65, 105, 225, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (139, 69, 19, 255). + /// + public static Color SaddleBrown { get { return new Color(139, 69, 19, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (250, 128, 114, 255). + /// + public static Color Salmon { get { return new Color(250, 128, 114, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (244, 164, 96, 255). + /// + public static Color SandyBrown { get { return new Color(244, 164, 96, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (46, 139, 87, 255). + /// + public static Color SeaGreen { get { return new Color(46, 139, 87, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 245, 238, 255). + /// + public static Color SeaShell { get { return new Color(255, 245, 238, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (160, 82, 45, 255). + /// + public static Color Sienna { get { return new Color(160, 82, 45, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (192, 192, 192, 255). + /// + public static Color Silver { get { return new Color(192, 192, 192, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (135, 206, 235, 255). + /// + public static Color SkyBlue { get { return new Color(135, 206, 235, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (106, 90, 205, 255). + /// + public static Color SlateBlue { get { return new Color(106, 90, 205, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (112, 128, 144, 255). + /// + public static Color SlateGray { get { return new Color(112, 128, 144, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 250, 250, 255). + /// + public static Color Snow { get { return new Color(255, 250, 250, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 255, 127, 255). + /// + public static Color SpringGreen { get { return new Color(0, 255, 127, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (70, 130, 180, 255). + /// + public static Color SteelBlue { get { return new Color(70, 130, 180, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (210, 180, 140, 255). + /// + public static Color Tan { get { return new Color(210, 180, 140, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (0, 128, 128, 255). + /// + public static Color Teal { get { return new Color(0, 128, 128, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (216, 191, 216, 255). + /// + public static Color Thistle { get { return new Color(216, 191, 216, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 99, 71, 255). + /// + public static Color Tomato { get { return new Color(255, 99, 71, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (64, 224, 208, 255). + /// + public static Color Turquoise { get { return new Color(64, 224, 208, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (238, 130, 238, 255). + /// + public static Color Violet { get { return new Color(238, 130, 238, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (245, 222, 179, 255). + /// + public static Color Wheat { get { return new Color(245, 222, 179, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 255, 255, 255). + /// + public static Color White { get { return new Color(255, 255, 255, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (245, 245, 245, 255). + /// + public static Color WhiteSmoke { get { return new Color(245, 245, 245, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (255, 255, 0, 255). + /// + public static Color Yellow { get { return new Color(255, 255, 0, 255); } } + + /// + /// Gets the system color with (R, G, B, A) = (154, 205, 50, 255). + /// + public static Color YellowGreen { get { return new Color(154, 205, 50, 255); } } + + #endregion + + #endregion + + #region IEquatable Members + + /// + /// Compares whether this Color structure is equal to the specified Color. + /// + /// The Color structure to compare to. + /// True if both Color structures contain the same components; false otherwise. + public bool Equals(Color other) + { + return + this.R == other.R && + this.G == other.G && + this.B == other.B && + this.A == other.A; + } + + #endregion + + public static Color FromArgb(int a, int r, int g, int b) + { + return new Color(r, g, b, a); + } + } + + #endregion + + #region BitmapData + + sealed class BitmapData + { + public IntPtr Scan0 { get { return IntPtr.Zero; } } + } + + #endregion + + #region ImageLockMode + + enum ImageLockMode + { + ReadOnly, + WriteOnly, + ReadWrite, + UserInputBuffer + } + + #endregion + + #region PixelFormat + + enum PixelFormat + { + Format32bppArgb + } + + #endregion } + +#region Graphics + +sealed class Graphics : IDisposable +{ + public static Graphics FromImage(OpenTK.Image img) + { + return new Graphics(); + } + + public void Dispose() + { } + + internal void DrawImage(OpenTK.Bitmap bitmap, int p, int p_2, int p_3, int p_4) + { + } +} + +#endregion + +#endif diff --git a/Source/OpenTK/NativeWindow.cs b/Source/OpenTK/NativeWindow.cs index 5fc2f418..3d67c4bb 100644 --- a/Source/OpenTK/NativeWindow.cs +++ b/Source/OpenTK/NativeWindow.cs @@ -27,7 +27,9 @@ using System; using System.ComponentModel; +#if !MINIMAL using System.Drawing; +#endif using OpenTK.Graphics; using OpenTK.Input; using OpenTK.Platform; diff --git a/Source/OpenTK/Platform/INativeGLWindow.cs b/Source/OpenTK/Platform/INativeGLWindow.cs index 77a130a8..83f2ea0f 100644 --- a/Source/OpenTK/Platform/INativeGLWindow.cs +++ b/Source/OpenTK/Platform/INativeGLWindow.cs @@ -8,11 +8,13 @@ using System; using System.Collections.Generic; +#if !MINIMAL +using System.Drawing; +#endif using System.Text; using OpenTK.Input; using OpenTK.Graphics; -using System.Drawing; namespace OpenTK.Platform { diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs index 0cf7847e..3b96ae07 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs @@ -31,7 +31,10 @@ using System; using System.Runtime.InteropServices; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif + using EventTime = System.Double; diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index c1c8eaa5..8dab99c8 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -31,7 +31,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif using System.Text; namespace OpenTK.Platform.MacOS @@ -752,7 +754,11 @@ namespace OpenTK.Platform.MacOS int index; bitmap = new Bitmap(128, 128); +#if MINIMAL + using (global::Graphics g = global::Graphics.FromImage(bitmap)) +#else using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) +#endif { g.DrawImage(icon.ToBitmap(), 0, 0, 128, 128); } diff --git a/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs b/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs index b7da1bc1..0982fb25 100644 --- a/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs +++ b/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs @@ -28,7 +28,9 @@ using System; using System.Collections.Generic; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif using OpenTK.Platform.MacOS.Carbon; namespace OpenTK.Platform.MacOS diff --git a/Source/OpenTK/Platform/Windows/API.cs b/Source/OpenTK/Platform/Windows/API.cs index e831d1f2..ccd77bc5 100644 --- a/Source/OpenTK/Platform/Windows/API.cs +++ b/Source/OpenTK/Platform/Windows/API.cs @@ -8,7 +8,9 @@ #region --- Using Directives --- using System; +#if !MINIMAL using System.Drawing; +#endif using System.Runtime.InteropServices; using System.Text; using System.Security; diff --git a/Source/OpenTK/Platform/Windows/WMInput.cs b/Source/OpenTK/Platform/Windows/WMInput.cs index e512204f..5d3d2ee3 100644 --- a/Source/OpenTK/Platform/Windows/WMInput.cs +++ b/Source/OpenTK/Platform/Windows/WMInput.cs @@ -28,7 +28,9 @@ using System; using System.Collections.Generic; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif using System.Threading; using System.Text; diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs index b433cb8f..261cfacf 100644 --- a/Source/OpenTK/Platform/Windows/WinGLNative.cs +++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs @@ -33,7 +33,9 @@ using OpenTK.Graphics; using OpenTK.Input; using System.Collections.Generic; using System.IO; +#if !MINIMAL using System.Drawing; +#endif namespace OpenTK.Platform.Windows { diff --git a/Source/OpenTK/Platform/X11/Functions.cs b/Source/OpenTK/Platform/X11/Functions.cs index 7d138d92..61e601f7 100644 --- a/Source/OpenTK/Platform/X11/Functions.cs +++ b/Source/OpenTK/Platform/X11/Functions.cs @@ -8,6 +8,10 @@ using System; using System.Collections.Generic; +#if !MINIMAL +using System.Drawing; +using System.Drawing.Imaging; +#endif using System.Text; using System.Runtime.InteropServices; @@ -594,15 +598,15 @@ namespace OpenTK.Platform.X11 (byte)(argb & 0xFF)); } } - public static IntPtr CreatePixmapFromImage(Display display, System.Drawing.Bitmap image) + public static IntPtr CreatePixmapFromImage(Display display, Bitmap image) { int width = image.Width; int height = image.Height; int size = width * height; - System.Drawing.Imaging.BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, width, height), - System.Drawing.Imaging.ImageLockMode.ReadOnly, - System.Drawing.Imaging.PixelFormat.Format32bppArgb); + BitmapData data = image.LockBits(new Rectangle(0, 0, width, height), + ImageLockMode.ReadOnly, + PixelFormat.Format32bppArgb); IntPtr ximage = XCreateImage(display, CopyFromParent, 24, ImageFormat.ZPixmap, 0, data.Scan0, (uint)width, (uint)height, 32, 0); @@ -618,7 +622,7 @@ namespace OpenTK.Platform.X11 return pixmap; } - public static IntPtr CreateMaskFromImage(Display display, System.Drawing.Bitmap image) + public static IntPtr CreateMaskFromImage(Display display, Bitmap image) { int width = image.Width; int height = image.Height; diff --git a/Source/OpenTK/Platform/X11/Structs.cs b/Source/OpenTK/Platform/X11/Structs.cs index ac20cfe4..f105d57b 100644 --- a/Source/OpenTK/Platform/X11/Structs.cs +++ b/Source/OpenTK/Platform/X11/Structs.cs @@ -29,7 +29,9 @@ using System; using System.ComponentModel; using System.Collections; +#if !MINIMAL using System.Drawing; +#endif using System.Diagnostics; using System.Runtime.InteropServices; diff --git a/Source/OpenTK/Platform/X11/X11DisplayDevice.cs b/Source/OpenTK/Platform/X11/X11DisplayDevice.cs index 3262ce1b..86c28ab4 100644 --- a/Source/OpenTK/Platform/X11/X11DisplayDevice.cs +++ b/Source/OpenTK/Platform/X11/X11DisplayDevice.cs @@ -28,7 +28,9 @@ using System; using System.Collections.Generic; using System.Diagnostics; +#if !MINIMAL using System.Drawing; +#endif using System.Runtime.InteropServices; namespace OpenTK.Platform.X11 diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs index 4be53acd..c64ea7c6 100644 --- a/Source/OpenTK/Platform/X11/X11GLNative.cs +++ b/Source/OpenTK/Platform/X11/X11GLNative.cs @@ -29,12 +29,14 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +#if !MINIMAL +using System.Drawing; +#endif using System.Reflection; using System.Runtime.InteropServices; using System.Text; using OpenTK.Graphics; using OpenTK.Input; -using System.Drawing; namespace OpenTK.Platform.X11 { @@ -1083,7 +1085,7 @@ namespace OpenTK.Platform.X11 else { // Set _NET_WM_ICON - System.Drawing.Bitmap bitmap = value.ToBitmap(); + Bitmap bitmap = value.ToBitmap(); int size = bitmap.Width * bitmap.Height + 2; IntPtr[] data = new IntPtr[size]; int index = 0; diff --git a/Source/OpenTK/Platform/X11/X11Input.cs b/Source/OpenTK/Platform/X11/X11Input.cs index ae4473b1..10978019 100644 --- a/Source/OpenTK/Platform/X11/X11Input.cs +++ b/Source/OpenTK/Platform/X11/X11Input.cs @@ -6,12 +6,14 @@ using System; using System.Collections.Generic; +#if !MINIMAL +using System.Drawing; +#endif using System.Text; using System.Diagnostics; using System.Runtime.InteropServices; using OpenTK.Input; -using System.Drawing; namespace OpenTK.Platform.X11 {