From 459313dca88c4abb18350523ef6449d0ae6ce49b Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Thu, 10 Oct 2013 00:18:59 +0200 Subject: [PATCH] Fixed line endings --- Source/OpenTK/Minimal.cs | 4422 ++++++++--------- Source/OpenTK/OpenTK.csproj | 1622 +++--- Source/OpenTK/OpenTK.dll.config | 30 +- Source/OpenTK/Platform/DisplayDeviceBase.cs | 106 +- Source/OpenTK/Platform/Windows/API.cs | 48 +- Source/OpenTK/Platform/Windows/WinFactory.cs | 24 +- .../OpenTK/Platform/Windows/WinInputBase.cs | 406 +- Source/OpenTK/Platform/X11/X11Keyboard.cs | 250 +- Source/OpenTK/Platform/X11/X11Mouse.cs | 304 +- Source/OpenTK/Platform/X11/XI2Mouse.cs | 526 +- Source/OpenTK/Properties/Resources.resx | 238 +- 11 files changed, 3988 insertions(+), 3988 deletions(-) diff --git a/Source/OpenTK/Minimal.cs b/Source/OpenTK/Minimal.cs index 8c13934f..4eef7fe8 100644 --- a/Source/OpenTK/Minimal.cs +++ b/Source/OpenTK/Minimal.cs @@ -1,2211 +1,2211 @@ -using System; -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! - - // System.Diagnostics.Debug - static class Debug - { - public static void Write(string message) { } - public static void Write(object obj) { } - public static void WriteLine(string message) { } - public static void WriteLine(object obj) { } - public static void Print(string message) { } - public static void Print(string format, params object[] args) { } - public static void Indent() { } - public static void Unindent() { } - public static void Flush() { } - } - - // System.Diagnostics.Trace - static class Trace - { - public static void Write(string message) { } - public static void Write(object obj) { } - public static void WriteLine(string message) { } - public static void WriteLine(object obj) { } - public static void Indent() { } - public static void Unindent() { } - public static void Flush() { } - } - - // System.Diagnostics.Stopwatch - sealed class Stopwatch - { - DateTime start, stop; - bool running; - - public void Reset() - { - start = stop = DateTime.MinValue; - running = false; - } - - public void Start() - { - start = DateTime.Now; - running = true; - } - - public void Stop() - { - stop = DateTime.Now; - running = false; - } - - public TimeSpan Elapsed - { - get - { - if (running) - return TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks); - else - return TimeSpan.FromTicks(stop.Ticks - start.Ticks); - } - } - } - - // System.Xml.XmlIgnoreAttribute - class XmlIgnoreAttribute : Attribute - { - } - - // System.ComponentModel.EditorBrowrableAttribute - class EditorBrowsableAttribute : Attribute - { - public EditorBrowsableAttribute(EditorBrowsableState state) { } - } - - // System.ComponentModel.EditorBrowsableState - enum EditorBrowsableState - { - Always = 0, - Never = 1, - Advanced = 2, - } - - #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 SystemEvents - - sealed class SystemEvents - { - public static event EventHandler DisplaySettingsChanged; - } - - #endregion -} - -// Need a different namespace to avoid clash with OpenTK.Graphics. -namespace OpenTK.Minimal -{ - #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 +using System; +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! + + // System.Diagnostics.Debug + static class Debug + { + public static void Write(string message) { } + public static void Write(object obj) { } + public static void WriteLine(string message) { } + public static void WriteLine(object obj) { } + public static void Print(string message) { } + public static void Print(string format, params object[] args) { } + public static void Indent() { } + public static void Unindent() { } + public static void Flush() { } + } + + // System.Diagnostics.Trace + static class Trace + { + public static void Write(string message) { } + public static void Write(object obj) { } + public static void WriteLine(string message) { } + public static void WriteLine(object obj) { } + public static void Indent() { } + public static void Unindent() { } + public static void Flush() { } + } + + // System.Diagnostics.Stopwatch + sealed class Stopwatch + { + DateTime start, stop; + bool running; + + public void Reset() + { + start = stop = DateTime.MinValue; + running = false; + } + + public void Start() + { + start = DateTime.Now; + running = true; + } + + public void Stop() + { + stop = DateTime.Now; + running = false; + } + + public TimeSpan Elapsed + { + get + { + if (running) + return TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks); + else + return TimeSpan.FromTicks(stop.Ticks - start.Ticks); + } + } + } + + // System.Xml.XmlIgnoreAttribute + class XmlIgnoreAttribute : Attribute + { + } + + // System.ComponentModel.EditorBrowrableAttribute + class EditorBrowsableAttribute : Attribute + { + public EditorBrowsableAttribute(EditorBrowsableState state) { } + } + + // System.ComponentModel.EditorBrowsableState + enum EditorBrowsableState + { + Always = 0, + Never = 1, + Advanced = 2, + } + + #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 SystemEvents + + sealed class SystemEvents + { + public static event EventHandler DisplaySettingsChanged; + } + + #endregion +} + +// Need a different namespace to avoid clash with OpenTK.Graphics. +namespace OpenTK.Minimal +{ + #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/OpenTK.csproj b/Source/OpenTK/OpenTK.csproj index d5473991..a9538e40 100644 --- a/Source/OpenTK/OpenTK.csproj +++ b/Source/OpenTK/OpenTK.csproj @@ -1,812 +1,812 @@ - - - - Local - 8.0.50727 - 2.0 - {A37A7E14-0000-0000-0000-000000000000} - Debug - AnyCPU - - - OpenTK - JScript - Grid - IE50 - false - v2.0 - Library - - - OpenTK - - - - - 2.0 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - True - 285212672 - - - DEBUG;TRACE; - OpenTK.xml - True - 4096 - False - ..\..\Binaries\OpenTK\Debug\ - False - False - 4 - AllRules.ruleset - full - True - - - True - 285212672 - - - TRACE; - OpenTK.xml - 4096 - True - ..\..\Binaries\OpenTK\Release\ - False - False - 4 - AllRules.ruleset - none - - - ..\..\Binaries\OpenTK\Release\ - none - 4 - True - TRACE; - True - - - True - 285212672 - - - TRACE; - OpenTK.xml - 4096 - True - ..\..\Binaries\OpenTK\Release\ - False - False - 4 - AllRules.ruleset - none - - - True - - - ..\..\OpenTK.snk - - - - System - - - System.Data - - - System.Drawing - - - System.Xml - - - - - Properties\GlobalAssemblyInfo.cs - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - OpenTK.snk - - - - - - - Always - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Local + 8.0.50727 + 2.0 + {A37A7E14-0000-0000-0000-000000000000} + Debug + AnyCPU + + + OpenTK + JScript + Grid + IE50 + false + v2.0 + Library + + + OpenTK + + + + + 2.0 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + True + 285212672 + + + DEBUG;TRACE; + OpenTK.xml + True + 4096 + False + ..\..\Binaries\OpenTK\Debug\ + False + False + 4 + AllRules.ruleset + full + True + + + True + 285212672 + + + TRACE; + OpenTK.xml + 4096 + True + ..\..\Binaries\OpenTK\Release\ + False + False + 4 + AllRules.ruleset + none + + + ..\..\Binaries\OpenTK\Release\ + none + 4 + True + TRACE; + True + + + True + 285212672 + + + TRACE; + OpenTK.xml + 4096 + True + ..\..\Binaries\OpenTK\Release\ + False + False + 4 + AllRules.ruleset + none + + + True + + + ..\..\OpenTK.snk + + + + System + + + System.Data + + + System.Drawing + + + System.Xml + + + + + Properties\GlobalAssemblyInfo.cs + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + OpenTK.snk + + + + + + + Always + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/OpenTK/OpenTK.dll.config b/Source/OpenTK/OpenTK.dll.config index 9cd13b2e..a404f98c 100644 --- a/Source/OpenTK/OpenTK.dll.config +++ b/Source/OpenTK/OpenTK.dll.config @@ -1,15 +1,15 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/Source/OpenTK/Platform/DisplayDeviceBase.cs b/Source/OpenTK/Platform/DisplayDeviceBase.cs index 723d8221..740e7804 100644 --- a/Source/OpenTK/Platform/DisplayDeviceBase.cs +++ b/Source/OpenTK/Platform/DisplayDeviceBase.cs @@ -1,53 +1,53 @@ -#region License -// -// The Open Toolkit Library License -// -// Copyright (c) 2006 - 2010 the Open Toolkit library. -// -// 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. -// -#endregion - -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenTK.Platform -{ - abstract class DisplayDeviceBase : IDisplayDeviceDriver - { - protected readonly List AvailableDevices = new List(); - protected DisplayDevice Primary; - - public abstract bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution); - public abstract bool TryRestoreResolution(DisplayDevice device); - - // Gets the DisplayDevice that corresponds to the specified index. - public virtual DisplayDevice GetDisplay(DisplayIndex index) - { - if (index == DisplayIndex.Primary) - return Primary; - else if ((int)index >= 0 && (int)index < AvailableDevices.Count) - return AvailableDevices[(int)index]; - else - return null; - } - } -} +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2010 the Open Toolkit library. +// +// 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. +// +#endregion + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenTK.Platform +{ + abstract class DisplayDeviceBase : IDisplayDeviceDriver + { + protected readonly List AvailableDevices = new List(); + protected DisplayDevice Primary; + + public abstract bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution); + public abstract bool TryRestoreResolution(DisplayDevice device); + + // Gets the DisplayDevice that corresponds to the specified index. + public virtual DisplayDevice GetDisplay(DisplayIndex index) + { + if (index == DisplayIndex.Primary) + return Primary; + else if ((int)index >= 0 && (int)index < AvailableDevices.Count) + return AvailableDevices[(int)index]; + else + return null; + } + } +} diff --git a/Source/OpenTK/Platform/Windows/API.cs b/Source/OpenTK/Platform/Windows/API.cs index 87f2695f..b6a74f4a 100644 --- a/Source/OpenTK/Platform/Windows/API.cs +++ b/Source/OpenTK/Platform/Windows/API.cs @@ -943,30 +943,30 @@ namespace OpenTK.Platform.Windows [DllImport("user32.dll", SetLastError = true)] public static extern HMONITOR MonitorFromWindow(HWND hwnd, MonitorFrom dwFlags); - #endregion - - #region SetProcessDPIAware - - /// - /// Sets the current process as dots per inch (dpi) aware. - /// Note: SetProcessDPIAware is subject to a possible race condition - /// if a DLL caches dpi settings during initialization. - /// For this reason, it is recommended that dpi-aware be set through - /// the application (.exe) manifest rather than by calling SetProcessDPIAware. - /// - /// - /// If the function succeeds, the return value is true. - /// Otherwise, the return value is false. - /// - /// - /// DLLs should accept the dpi setting of the host process - /// rather than call SetProcessDPIAware themselves. - /// To be set properly, dpiAware should be specified as part - /// of the application (.exe) manifest. - /// - [DllImport("user32.dll")] - internal static extern BOOL SetProcessDPIAware(); - + #endregion + + #region SetProcessDPIAware + + /// + /// Sets the current process as dots per inch (dpi) aware. + /// Note: SetProcessDPIAware is subject to a possible race condition + /// if a DLL caches dpi settings during initialization. + /// For this reason, it is recommended that dpi-aware be set through + /// the application (.exe) manifest rather than by calling SetProcessDPIAware. + /// + /// + /// If the function succeeds, the return value is true. + /// Otherwise, the return value is false. + /// + /// + /// DLLs should accept the dpi setting of the host process + /// rather than call SetProcessDPIAware themselves. + /// To be set properly, dpiAware should be specified as part + /// of the application (.exe) manifest. + /// + [DllImport("user32.dll")] + internal static extern BOOL SetProcessDPIAware(); + #endregion #endregion diff --git a/Source/OpenTK/Platform/Windows/WinFactory.cs b/Source/OpenTK/Platform/Windows/WinFactory.cs index 58f78ec6..cc628929 100644 --- a/Source/OpenTK/Platform/Windows/WinFactory.cs +++ b/Source/OpenTK/Platform/Windows/WinFactory.cs @@ -26,7 +26,7 @@ #endregion using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics; using System.Text; @@ -39,17 +39,17 @@ namespace OpenTK.Platform.Windows { bool disposed; readonly object SyncRoot = new object(); - IInputDriver2 inputDriver; - - public WinFactory() - { - if (System.Environment.OSVersion.Version.Major >= 6) - { - // Enable high-dpi support - // Only available on Windows Vista and higher - bool result = Functions.SetProcessDPIAware(); - Debug.Print("SetProcessDPIAware() returned {0}", result); - } + IInputDriver2 inputDriver; + + public WinFactory() + { + if (System.Environment.OSVersion.Version.Major >= 6) + { + // Enable high-dpi support + // Only available on Windows Vista and higher + bool result = Functions.SetProcessDPIAware(); + Debug.Print("SetProcessDPIAware() returned {0}", result); + } } #region IPlatformFactory Members diff --git a/Source/OpenTK/Platform/Windows/WinInputBase.cs b/Source/OpenTK/Platform/Windows/WinInputBase.cs index f51460ef..44d82ee7 100644 --- a/Source/OpenTK/Platform/Windows/WinInputBase.cs +++ b/Source/OpenTK/Platform/Windows/WinInputBase.cs @@ -1,203 +1,203 @@ -#region License -// -// The Open Toolkit Library License -// -// Copyright (c) 2006 - 2010 the Open Toolkit library. -// -// 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. -// -#endregion - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Threading; -using OpenTK.Input; - -namespace OpenTK.Platform.Windows -{ - abstract class WinInputBase : IInputDriver2 - { - #region Fields - - readonly WindowProcedure WndProc; - readonly Thread InputThread; - readonly AutoResetEvent InputReady = new AutoResetEvent(false); - - IntPtr OldWndProc; - INativeWindow native; - - protected INativeWindow Native { get { return native; } private set { native = value; } } - protected WinWindowInfo Parent { get { return (WinWindowInfo)Native.WindowInfo; } } - - static readonly IntPtr Unhandled = new IntPtr(-1); - - #endregion - - #region Constructors - - public WinInputBase() - { - WndProc = WindowProcedure; - - InputThread = new Thread(ProcessEvents); - InputThread.IsBackground = true; - InputThread.Start(); - - InputReady.WaitOne(); - } - - #endregion - - #region Private Members - - #region ConstructMessageWindow - - INativeWindow ConstructMessageWindow() - { - Debug.WriteLine("Initializing input driver."); - Debug.Indent(); - - // Create a new message-only window to retrieve WM_INPUT messages. - INativeWindow native = new NativeWindow(); - native.ProcessEvents(); - WinWindowInfo parent = native.WindowInfo as WinWindowInfo; - Functions.SetParent(parent.Handle, Constants.MESSAGE_ONLY); - native.ProcessEvents(); - - Debug.Unindent(); - return native; - } - - - #endregion - - #region ProcessEvents - - void ProcessEvents() - { - Native = ConstructMessageWindow(); - CreateDrivers(); - - // Subclass the window to retrieve the events we are interested in. - OldWndProc = Functions.SetWindowLong(Parent.Handle, WndProc); - Debug.Print("Input window attached to {0}", Parent); - - InputReady.Set(); - - MSG msg = new MSG(); - while (Native.Exists) - { - int ret = Functions.GetMessage(ref msg, Parent.Handle, 0, 0); - if (ret == -1) - { - throw new PlatformException(String.Format( - "An error happened while processing the message queue. Windows error: {0}", - Marshal.GetLastWin32Error())); - } - - Functions.TranslateMessage(ref msg); - Functions.DispatchMessage(ref msg); - } - } - - #endregion - - #region WndProcHandler - - IntPtr WndProcHandler( - IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) - { - IntPtr ret = WindowProcedure(handle, message, wParam, lParam); - if (ret == Unhandled) - return Functions.CallWindowProc(OldWndProc, handle, message, wParam, lParam); - else - return ret; - } - - #endregion - - #endregion - - #region Protected Members - - #region WindowProcedure - - protected virtual IntPtr WindowProcedure( - IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) - { - return Unhandled; - } - - #endregion - - #region CreateDrivers - - // Note: this method is called through the input thread. - protected abstract void CreateDrivers(); - - #endregion - - #endregion - - #region IInputDriver2 Members - - public abstract IMouseDriver2 MouseDriver { get; } - public abstract IKeyboardDriver2 KeyboardDriver { get; } - public abstract IGamePadDriver GamePadDriver { get; } - - #endregion - - #region IDisposable Members - - protected bool Disposed; - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool manual) - { - if (!Disposed) - { - if (manual) - { - if (Native != null) - { - Native.Close(); - Native.Dispose(); - } - } - - Disposed = true; - } - } - - ~WinInputBase() - { - Debug.Print("[Warning] Resource leaked: {0}.", this); - Dispose(false); - } - - #endregion - } -} +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2010 the Open Toolkit library. +// +// 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. +// +#endregion + +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Threading; +using OpenTK.Input; + +namespace OpenTK.Platform.Windows +{ + abstract class WinInputBase : IInputDriver2 + { + #region Fields + + readonly WindowProcedure WndProc; + readonly Thread InputThread; + readonly AutoResetEvent InputReady = new AutoResetEvent(false); + + IntPtr OldWndProc; + INativeWindow native; + + protected INativeWindow Native { get { return native; } private set { native = value; } } + protected WinWindowInfo Parent { get { return (WinWindowInfo)Native.WindowInfo; } } + + static readonly IntPtr Unhandled = new IntPtr(-1); + + #endregion + + #region Constructors + + public WinInputBase() + { + WndProc = WindowProcedure; + + InputThread = new Thread(ProcessEvents); + InputThread.IsBackground = true; + InputThread.Start(); + + InputReady.WaitOne(); + } + + #endregion + + #region Private Members + + #region ConstructMessageWindow + + INativeWindow ConstructMessageWindow() + { + Debug.WriteLine("Initializing input driver."); + Debug.Indent(); + + // Create a new message-only window to retrieve WM_INPUT messages. + INativeWindow native = new NativeWindow(); + native.ProcessEvents(); + WinWindowInfo parent = native.WindowInfo as WinWindowInfo; + Functions.SetParent(parent.Handle, Constants.MESSAGE_ONLY); + native.ProcessEvents(); + + Debug.Unindent(); + return native; + } + + + #endregion + + #region ProcessEvents + + void ProcessEvents() + { + Native = ConstructMessageWindow(); + CreateDrivers(); + + // Subclass the window to retrieve the events we are interested in. + OldWndProc = Functions.SetWindowLong(Parent.Handle, WndProc); + Debug.Print("Input window attached to {0}", Parent); + + InputReady.Set(); + + MSG msg = new MSG(); + while (Native.Exists) + { + int ret = Functions.GetMessage(ref msg, Parent.Handle, 0, 0); + if (ret == -1) + { + throw new PlatformException(String.Format( + "An error happened while processing the message queue. Windows error: {0}", + Marshal.GetLastWin32Error())); + } + + Functions.TranslateMessage(ref msg); + Functions.DispatchMessage(ref msg); + } + } + + #endregion + + #region WndProcHandler + + IntPtr WndProcHandler( + IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) + { + IntPtr ret = WindowProcedure(handle, message, wParam, lParam); + if (ret == Unhandled) + return Functions.CallWindowProc(OldWndProc, handle, message, wParam, lParam); + else + return ret; + } + + #endregion + + #endregion + + #region Protected Members + + #region WindowProcedure + + protected virtual IntPtr WindowProcedure( + IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) + { + return Unhandled; + } + + #endregion + + #region CreateDrivers + + // Note: this method is called through the input thread. + protected abstract void CreateDrivers(); + + #endregion + + #endregion + + #region IInputDriver2 Members + + public abstract IMouseDriver2 MouseDriver { get; } + public abstract IKeyboardDriver2 KeyboardDriver { get; } + public abstract IGamePadDriver GamePadDriver { get; } + + #endregion + + #region IDisposable Members + + protected bool Disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool manual) + { + if (!Disposed) + { + if (manual) + { + if (Native != null) + { + Native.Close(); + Native.Dispose(); + } + } + + Disposed = true; + } + } + + ~WinInputBase() + { + Debug.Print("[Warning] Resource leaked: {0}.", this); + Dispose(false); + } + + #endregion + } +} diff --git a/Source/OpenTK/Platform/X11/X11Keyboard.cs b/Source/OpenTK/Platform/X11/X11Keyboard.cs index ef1f0a0b..37772246 100644 --- a/Source/OpenTK/Platform/X11/X11Keyboard.cs +++ b/Source/OpenTK/Platform/X11/X11Keyboard.cs @@ -1,125 +1,125 @@ - #region License - // - // The Open Toolkit Library License - // - // Copyright (c) 2006 - 2010 the Open Toolkit library. - // - // 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. - // - #endregion - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using OpenTK.Input; - -namespace OpenTK.Platform.X11 -{ - // Standard keyboard driver that relies on xlib input events. - // Only one keyboard supported. - sealed class X11Keyboard : IKeyboardDriver2 - { - readonly static X11KeyMap keymap = new X11KeyMap(); - readonly static string name = "Core X11 keyboard"; - readonly byte[] keys = new byte[32]; - readonly int KeysymsPerKeycode; - KeyboardState state = new KeyboardState(); - - public X11Keyboard() - { - Debug.WriteLine("Using X11Keyboard."); - state.IsConnected = true; - - IntPtr display = API.DefaultDisplay; - using (new XLock(display)) - { - // Find the number of keysyms per keycode. - int first = 0, last = 0; - API.DisplayKeycodes(display, ref first, ref last); - IntPtr keysym_ptr = API.GetKeyboardMapping(display, (byte)first, last - first + 1, - ref KeysymsPerKeycode); - Functions.XFree(keysym_ptr); - - try - { - // Request that auto-repeat is only set on devices that support it physically. - // This typically means that it's turned off for keyboards what we want). - // We prefer this method over XAutoRepeatOff/On, because the latter needs to - // be reset before the program exits. - bool supported; - Functions.XkbSetDetectableAutoRepeat(display, true, out supported); - } - catch { } - } - } - - public KeyboardState GetState() - { - ProcessEvents(); - return state; - } - - public KeyboardState GetState(int index) - { - // X11Keyboard supports a single keyboard only - ProcessEvents(); - if (index == 0) - return state; - else - return new KeyboardState(); - } - - public string GetDeviceName(int index) - { - if (index == 0) - return name; - else - return String.Empty; - } - - void ProcessEvents() - { - IntPtr display = API.DefaultDisplay; - using (new XLock(display)) - { - Functions.XQueryKeymap(display, keys); - for (int keycode = 8; keycode < 256; keycode++) - { - bool pressed = (keys[keycode >> 3] >> (keycode & 0x07) & 0x01) != 0; - Key key; - - for (int mod = 0; mod < KeysymsPerKeycode; mod++) - { - IntPtr keysym = Functions.XKeycodeToKeysym(display, (byte)keycode, mod); - if (keysym != IntPtr.Zero && keymap.TryGetValue((XKey)keysym, out key)) - { - if (pressed) - state.EnableBit((int)key); - else - state.DisableBit((int)key); - break; - } - } - } - } - } - } -} - + #region License + // + // The Open Toolkit Library License + // + // Copyright (c) 2006 - 2010 the Open Toolkit library. + // + // 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. + // + #endregion + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using OpenTK.Input; + +namespace OpenTK.Platform.X11 +{ + // Standard keyboard driver that relies on xlib input events. + // Only one keyboard supported. + sealed class X11Keyboard : IKeyboardDriver2 + { + readonly static X11KeyMap keymap = new X11KeyMap(); + readonly static string name = "Core X11 keyboard"; + readonly byte[] keys = new byte[32]; + readonly int KeysymsPerKeycode; + KeyboardState state = new KeyboardState(); + + public X11Keyboard() + { + Debug.WriteLine("Using X11Keyboard."); + state.IsConnected = true; + + IntPtr display = API.DefaultDisplay; + using (new XLock(display)) + { + // Find the number of keysyms per keycode. + int first = 0, last = 0; + API.DisplayKeycodes(display, ref first, ref last); + IntPtr keysym_ptr = API.GetKeyboardMapping(display, (byte)first, last - first + 1, + ref KeysymsPerKeycode); + Functions.XFree(keysym_ptr); + + try + { + // Request that auto-repeat is only set on devices that support it physically. + // This typically means that it's turned off for keyboards what we want). + // We prefer this method over XAutoRepeatOff/On, because the latter needs to + // be reset before the program exits. + bool supported; + Functions.XkbSetDetectableAutoRepeat(display, true, out supported); + } + catch { } + } + } + + public KeyboardState GetState() + { + ProcessEvents(); + return state; + } + + public KeyboardState GetState(int index) + { + // X11Keyboard supports a single keyboard only + ProcessEvents(); + if (index == 0) + return state; + else + return new KeyboardState(); + } + + public string GetDeviceName(int index) + { + if (index == 0) + return name; + else + return String.Empty; + } + + void ProcessEvents() + { + IntPtr display = API.DefaultDisplay; + using (new XLock(display)) + { + Functions.XQueryKeymap(display, keys); + for (int keycode = 8; keycode < 256; keycode++) + { + bool pressed = (keys[keycode >> 3] >> (keycode & 0x07) & 0x01) != 0; + Key key; + + for (int mod = 0; mod < KeysymsPerKeycode; mod++) + { + IntPtr keysym = Functions.XKeycodeToKeysym(display, (byte)keycode, mod); + if (keysym != IntPtr.Zero && keymap.TryGetValue((XKey)keysym, out key)) + { + if (pressed) + state.EnableBit((int)key); + else + state.DisableBit((int)key); + break; + } + } + } + } + } + } +} + diff --git a/Source/OpenTK/Platform/X11/X11Mouse.cs b/Source/OpenTK/Platform/X11/X11Mouse.cs index 7c96545d..0dc5879d 100644 --- a/Source/OpenTK/Platform/X11/X11Mouse.cs +++ b/Source/OpenTK/Platform/X11/X11Mouse.cs @@ -1,152 +1,152 @@ - #region License - // - // The Open Toolkit Library License - // - // Copyright (c) 2006 - 2010 the Open Toolkit library. - // - // 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. - // - #endregion - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using OpenTK.Input; - -namespace OpenTK.Platform.X11 -{ - // Note: we cannot create a background window to retrieve events, - // because X11 doesn't deliver core pointer events to background - // windows (unless we grab, which will break *everything*). - // The only solution is to poll. - // Note 2: this driver only supports absolute positions. Relative motion - // is faked through SetPosition. This is called automatically when - // NativeWindow.CursorVisible = false, otherwise it must be called - // by the user. - // Note 3: this driver cannot drive the mouse wheel reliably. - // See comments in ProcessEvents() for more information. - // (If someone knows of a solution, please tell!) - sealed class X11Mouse : IMouseDriver2 - { - readonly IntPtr display; - readonly IntPtr root_window; - MouseState mouse = new MouseState(); - - // When the mouse warps, "detach" the current location - // from the pointer. - bool mouse_detached; - int mouse_detached_x, mouse_detached_y; - - public X11Mouse() - { - Debug.WriteLine("Using X11Mouse."); - mouse.IsConnected = true; - display = API.DefaultDisplay; - root_window = Functions.XRootWindow(display, Functions.XDefaultScreen(display)); - } - - public MouseState GetState() - { - ProcessEvents(); - return mouse; - } - - public MouseState GetState(int index) - { - ProcessEvents(); - // X11Mouse supports only one device - if (index == 0) - return mouse; - else - return new MouseState(); - } - - public void SetPosition(double x, double y) - { - // Update the current location, otherwise the pointer - // may become locked (for instance, if we call - // SetPosition too often, like X11GLNative does). - ProcessEvents(); - - using (new XLock(display)) - { - // Mark the expected warp-event so it can be ignored. - mouse_detached = true; - mouse_detached_x = (int)x; - mouse_detached_y = (int)y; - - Functions.XWarpPointer(display, - IntPtr.Zero, root_window, 0, 0, 0, 0, (int)x, (int)y); - } - } - - void WriteBit(MouseButton offset, int enabled) - { - if (enabled != 0) - mouse.EnableBit((int)offset); - else - mouse.DisableBit((int)offset); - } - - void ProcessEvents() - { - IntPtr root, child; - int root_x, root_y, win_x, win_y; - int buttons; - - using (new XLock(display)) - { - IntPtr window = root_window; - Functions.XQueryPointer(display, window, out root, out child, - out root_x, out root_y, out win_x, out win_y, out buttons); - - if (!mouse_detached) - { - mouse.X = root_x; - mouse.Y = root_y; - } - else - { - mouse.X += (int)root_x - mouse_detached_x; - mouse.Y += (int)root_y - mouse_detached_y; - mouse_detached_x = root_x; - mouse_detached_y = root_y; - } - WriteBit(MouseButton.Left, buttons & (int)MouseMask.Button1Mask); - WriteBit(MouseButton.Middle, buttons & (int)MouseMask.Button2Mask); - WriteBit(MouseButton.Right, buttons & (int)MouseMask.Button3Mask); - // Note: this will never work right, wheel events have a duration of 0 - // (yes, zero). They are impposible to catch via polling. - // After spending a week on this, I simply don't care anymore. - // If someone can fix it, please do. - // Note 2: I have tried passively grabbing those buttons - no go (BadAccess). - // Maybe I am doing something wrong with the grab. - //if ((buttons & (int)MouseMask.Button4Mask) != 0) - // mouse.WheelPrecise++; - //if ((buttons & (int)MouseMask.Button5Mask) != 0) - // mouse.WheelPrecise--; - WriteBit(MouseButton.Button1, buttons & (int)MouseMask.Button6Mask); - WriteBit(MouseButton.Button2, buttons & (int)MouseMask.Button7Mask); - WriteBit(MouseButton.Button3, buttons & (int)MouseMask.Button8Mask); - } - } - } -} - + #region License + // + // The Open Toolkit Library License + // + // Copyright (c) 2006 - 2010 the Open Toolkit library. + // + // 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. + // + #endregion + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using OpenTK.Input; + +namespace OpenTK.Platform.X11 +{ + // Note: we cannot create a background window to retrieve events, + // because X11 doesn't deliver core pointer events to background + // windows (unless we grab, which will break *everything*). + // The only solution is to poll. + // Note 2: this driver only supports absolute positions. Relative motion + // is faked through SetPosition. This is called automatically when + // NativeWindow.CursorVisible = false, otherwise it must be called + // by the user. + // Note 3: this driver cannot drive the mouse wheel reliably. + // See comments in ProcessEvents() for more information. + // (If someone knows of a solution, please tell!) + sealed class X11Mouse : IMouseDriver2 + { + readonly IntPtr display; + readonly IntPtr root_window; + MouseState mouse = new MouseState(); + + // When the mouse warps, "detach" the current location + // from the pointer. + bool mouse_detached; + int mouse_detached_x, mouse_detached_y; + + public X11Mouse() + { + Debug.WriteLine("Using X11Mouse."); + mouse.IsConnected = true; + display = API.DefaultDisplay; + root_window = Functions.XRootWindow(display, Functions.XDefaultScreen(display)); + } + + public MouseState GetState() + { + ProcessEvents(); + return mouse; + } + + public MouseState GetState(int index) + { + ProcessEvents(); + // X11Mouse supports only one device + if (index == 0) + return mouse; + else + return new MouseState(); + } + + public void SetPosition(double x, double y) + { + // Update the current location, otherwise the pointer + // may become locked (for instance, if we call + // SetPosition too often, like X11GLNative does). + ProcessEvents(); + + using (new XLock(display)) + { + // Mark the expected warp-event so it can be ignored. + mouse_detached = true; + mouse_detached_x = (int)x; + mouse_detached_y = (int)y; + + Functions.XWarpPointer(display, + IntPtr.Zero, root_window, 0, 0, 0, 0, (int)x, (int)y); + } + } + + void WriteBit(MouseButton offset, int enabled) + { + if (enabled != 0) + mouse.EnableBit((int)offset); + else + mouse.DisableBit((int)offset); + } + + void ProcessEvents() + { + IntPtr root, child; + int root_x, root_y, win_x, win_y; + int buttons; + + using (new XLock(display)) + { + IntPtr window = root_window; + Functions.XQueryPointer(display, window, out root, out child, + out root_x, out root_y, out win_x, out win_y, out buttons); + + if (!mouse_detached) + { + mouse.X = root_x; + mouse.Y = root_y; + } + else + { + mouse.X += (int)root_x - mouse_detached_x; + mouse.Y += (int)root_y - mouse_detached_y; + mouse_detached_x = root_x; + mouse_detached_y = root_y; + } + WriteBit(MouseButton.Left, buttons & (int)MouseMask.Button1Mask); + WriteBit(MouseButton.Middle, buttons & (int)MouseMask.Button2Mask); + WriteBit(MouseButton.Right, buttons & (int)MouseMask.Button3Mask); + // Note: this will never work right, wheel events have a duration of 0 + // (yes, zero). They are impposible to catch via polling. + // After spending a week on this, I simply don't care anymore. + // If someone can fix it, please do. + // Note 2: I have tried passively grabbing those buttons - no go (BadAccess). + // Maybe I am doing something wrong with the grab. + //if ((buttons & (int)MouseMask.Button4Mask) != 0) + // mouse.WheelPrecise++; + //if ((buttons & (int)MouseMask.Button5Mask) != 0) + // mouse.WheelPrecise--; + WriteBit(MouseButton.Button1, buttons & (int)MouseMask.Button6Mask); + WriteBit(MouseButton.Button2, buttons & (int)MouseMask.Button7Mask); + WriteBit(MouseButton.Button3, buttons & (int)MouseMask.Button8Mask); + } + } + } +} + diff --git a/Source/OpenTK/Platform/X11/XI2Mouse.cs b/Source/OpenTK/Platform/X11/XI2Mouse.cs index bd697060..bb93c754 100644 --- a/Source/OpenTK/Platform/X11/XI2Mouse.cs +++ b/Source/OpenTK/Platform/X11/XI2Mouse.cs @@ -1,263 +1,263 @@ - #region License - // - // The Open Toolkit Library License - // - // Copyright (c) 2006 - 2010 the Open Toolkit library. - // - // 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. - // - #endregion - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; -using OpenTK.Input; - -namespace OpenTK.Platform.X11 -{ - // Todo: multi-mouse support. Right now we aggregate all data into a single mouse device. - // This should be easy: just read the device id and route the data to the correct device. - sealed class XI2Mouse : IMouseDriver2 - { - List mice = new List(); - Dictionary rawids = new Dictionary(); // maps raw ids to mouse ids - internal readonly X11WindowInfo window; - static int XIOpCode; - - static readonly Functions.EventPredicate PredicateImpl = IsEventValid; - readonly IntPtr Predicate = Marshal.GetFunctionPointerForDelegate(PredicateImpl); - - // Store information on a mouse warp event, so it can be ignored. - struct MouseWarp : IEquatable - { - public MouseWarp(double x, double y) { X = x; Y = y; } - double X, Y; - public bool Equals(MouseWarp warp) { return X == warp.X && Y == warp.Y; } - } - MouseWarp? mouse_warp_event; - int mouse_warp_event_count; - - public XI2Mouse() - { - Debug.WriteLine("Using XI2Mouse."); - - using (new XLock(API.DefaultDisplay)) - { - window = new X11WindowInfo(); - window.Display = API.DefaultDisplay; - window.Screen = Functions.XDefaultScreen(window.Display); - window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); - window.Handle = window.RootWindow; - } - - if (!IsSupported(window.Display)) - throw new NotSupportedException("XInput2 not supported."); - - using (XIEventMask mask = new XIEventMask(1, XIEventMasks.RawButtonPressMask | - XIEventMasks.RawButtonReleaseMask | XIEventMasks.RawMotionMask)) - { - Functions.XISelectEvents(window.Display, window.Handle, mask); - Functions.XISelectEvents(window.Display, window.RootWindow, mask); - } - } - - // Checks whether XInput2 is supported on the specified display. - // If a display is not specified, the default display is used. - internal static bool IsSupported(IntPtr display) - { - if (display == IntPtr.Zero) - display = API.DefaultDisplay; - - using (new XLock(display)) - { - int major, ev, error; - if (Functions.XQueryExtension(display, "XInputExtension", out major, out ev, out error) == 0) - { - return false; - } - XIOpCode = major; - } - - return true; - } - - #region IMouseDriver2 Members - - public MouseState GetState() - { - ProcessEvents(); - MouseState master = new MouseState(); - foreach (MouseState ms in mice) - { - master.MergeBits(ms); - } - return master; - } - - public MouseState GetState(int index) - { - ProcessEvents(); - if (mice.Count > index) - return mice[index]; - else - return new MouseState(); - } - - public void SetPosition(double x, double y) - { - using (new XLock(window.Display)) - { - Functions.XWarpPointer(window.Display, - IntPtr.Zero, window.RootWindow, 0, 0, 0, 0, (int)x, (int)y); - - // Mark the expected warp-event so it can be ignored. - if (mouse_warp_event == null) - mouse_warp_event_count = 0; - mouse_warp_event_count++; - mouse_warp_event = new MouseWarp((int)x, (int)y); - } - - ProcessEvents(); - } - - #endregion - - bool CheckMouseWarp(double x, double y) - { - // Check if a mouse warp with the specified destination exists. - bool is_warp = - mouse_warp_event.HasValue && - mouse_warp_event.Value.Equals(new MouseWarp((int)x, (int)y)); - - if (is_warp && --mouse_warp_event_count <= 0) - mouse_warp_event = null; - - return is_warp; - } - - void ProcessEvents() - { - while (true) - { - XEvent e = new XEvent(); - XGenericEventCookie cookie; - - using (new XLock(window.Display)) - { - if (!Functions.XCheckIfEvent(window.Display, ref e, Predicate, new IntPtr(XIOpCode))) - return; - - cookie = e.GenericEventCookie; - if (Functions.XGetEventData(window.Display, ref cookie) != 0) - { - XIRawEvent raw = (XIRawEvent) - Marshal.PtrToStructure(cookie.data, typeof(XIRawEvent)); - - if (!rawids.ContainsKey(raw.deviceid)) - { - mice.Add(new MouseState()); - rawids.Add(raw.deviceid, mice.Count - 1); - } - MouseState state = mice[rawids[raw.deviceid]]; - - switch (raw.evtype) - { - case XIEventType.RawMotion: - double x = 0, y = 0; - if (IsBitSet(raw.valuators.mask, 0)) - { - x = BitConverter.Int64BitsToDouble(Marshal.ReadInt64(raw.raw_values, 0)); - } - if (IsBitSet(raw.valuators.mask, 1)) - { - y = BitConverter.Int64BitsToDouble(Marshal.ReadInt64(raw.raw_values, 8)); - } - - if (!CheckMouseWarp(x, y)) - { - state.X += (int)x; - state.Y += (int)y; - } - break; - - case XIEventType.RawButtonPress: - switch (raw.detail) - { - case 1: state.EnableBit((int)MouseButton.Left); break; - case 2: state.EnableBit((int)MouseButton.Middle); break; - case 3: state.EnableBit((int)MouseButton.Right); break; - case 4: state.WheelPrecise++; break; - case 5: state.WheelPrecise--; break; - case 6: state.EnableBit((int)MouseButton.Button1); break; - case 7: state.EnableBit((int)MouseButton.Button2); break; - case 8: state.EnableBit((int)MouseButton.Button3); break; - case 9: state.EnableBit((int)MouseButton.Button4); break; - case 10: state.EnableBit((int)MouseButton.Button5); break; - case 11: state.EnableBit((int)MouseButton.Button6); break; - case 12: state.EnableBit((int)MouseButton.Button7); break; - case 13: state.EnableBit((int)MouseButton.Button8); break; - case 14: state.EnableBit((int)MouseButton.Button9); break; - } - break; - - case XIEventType.RawButtonRelease: - switch (raw.detail) - { - case 1: state.DisableBit((int)MouseButton.Left); break; - case 2: state.DisableBit((int)MouseButton.Middle); break; - case 3: state.DisableBit((int)MouseButton.Right); break; - case 6: state.DisableBit((int)MouseButton.Button1); break; - case 7: state.DisableBit((int)MouseButton.Button2); break; - case 8: state.DisableBit((int)MouseButton.Button3); break; - case 9: state.DisableBit((int)MouseButton.Button4); break; - case 10: state.DisableBit((int)MouseButton.Button5); break; - case 11: state.DisableBit((int)MouseButton.Button6); break; - case 12: state.DisableBit((int)MouseButton.Button7); break; - case 13: state.DisableBit((int)MouseButton.Button8); break; - case 14: state.DisableBit((int)MouseButton.Button9); break; - } - break; - } - mice[rawids[raw.deviceid]] = state; - } - Functions.XFreeEventData(window.Display, ref cookie); - } - } - } - - static bool IsEventValid(IntPtr display, ref XEvent e, IntPtr arg) - { - return e.GenericEventCookie.extension == arg.ToInt32() && - (e.GenericEventCookie.evtype == (int)XIEventType.RawMotion || - e.GenericEventCookie.evtype == (int)XIEventType.RawButtonPress || - e.GenericEventCookie.evtype == (int)XIEventType.RawButtonRelease); - } - - static bool IsBitSet(IntPtr mask, int bit) - { - unsafe - { - return (*((byte*)mask + (bit >> 3)) & (1 << (bit & 7))) != 0; - } - } - } -} - + #region License + // + // The Open Toolkit Library License + // + // Copyright (c) 2006 - 2010 the Open Toolkit library. + // + // 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. + // + #endregion + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; +using OpenTK.Input; + +namespace OpenTK.Platform.X11 +{ + // Todo: multi-mouse support. Right now we aggregate all data into a single mouse device. + // This should be easy: just read the device id and route the data to the correct device. + sealed class XI2Mouse : IMouseDriver2 + { + List mice = new List(); + Dictionary rawids = new Dictionary(); // maps raw ids to mouse ids + internal readonly X11WindowInfo window; + static int XIOpCode; + + static readonly Functions.EventPredicate PredicateImpl = IsEventValid; + readonly IntPtr Predicate = Marshal.GetFunctionPointerForDelegate(PredicateImpl); + + // Store information on a mouse warp event, so it can be ignored. + struct MouseWarp : IEquatable + { + public MouseWarp(double x, double y) { X = x; Y = y; } + double X, Y; + public bool Equals(MouseWarp warp) { return X == warp.X && Y == warp.Y; } + } + MouseWarp? mouse_warp_event; + int mouse_warp_event_count; + + public XI2Mouse() + { + Debug.WriteLine("Using XI2Mouse."); + + using (new XLock(API.DefaultDisplay)) + { + window = new X11WindowInfo(); + window.Display = API.DefaultDisplay; + window.Screen = Functions.XDefaultScreen(window.Display); + window.RootWindow = Functions.XRootWindow(window.Display, window.Screen); + window.Handle = window.RootWindow; + } + + if (!IsSupported(window.Display)) + throw new NotSupportedException("XInput2 not supported."); + + using (XIEventMask mask = new XIEventMask(1, XIEventMasks.RawButtonPressMask | + XIEventMasks.RawButtonReleaseMask | XIEventMasks.RawMotionMask)) + { + Functions.XISelectEvents(window.Display, window.Handle, mask); + Functions.XISelectEvents(window.Display, window.RootWindow, mask); + } + } + + // Checks whether XInput2 is supported on the specified display. + // If a display is not specified, the default display is used. + internal static bool IsSupported(IntPtr display) + { + if (display == IntPtr.Zero) + display = API.DefaultDisplay; + + using (new XLock(display)) + { + int major, ev, error; + if (Functions.XQueryExtension(display, "XInputExtension", out major, out ev, out error) == 0) + { + return false; + } + XIOpCode = major; + } + + return true; + } + + #region IMouseDriver2 Members + + public MouseState GetState() + { + ProcessEvents(); + MouseState master = new MouseState(); + foreach (MouseState ms in mice) + { + master.MergeBits(ms); + } + return master; + } + + public MouseState GetState(int index) + { + ProcessEvents(); + if (mice.Count > index) + return mice[index]; + else + return new MouseState(); + } + + public void SetPosition(double x, double y) + { + using (new XLock(window.Display)) + { + Functions.XWarpPointer(window.Display, + IntPtr.Zero, window.RootWindow, 0, 0, 0, 0, (int)x, (int)y); + + // Mark the expected warp-event so it can be ignored. + if (mouse_warp_event == null) + mouse_warp_event_count = 0; + mouse_warp_event_count++; + mouse_warp_event = new MouseWarp((int)x, (int)y); + } + + ProcessEvents(); + } + + #endregion + + bool CheckMouseWarp(double x, double y) + { + // Check if a mouse warp with the specified destination exists. + bool is_warp = + mouse_warp_event.HasValue && + mouse_warp_event.Value.Equals(new MouseWarp((int)x, (int)y)); + + if (is_warp && --mouse_warp_event_count <= 0) + mouse_warp_event = null; + + return is_warp; + } + + void ProcessEvents() + { + while (true) + { + XEvent e = new XEvent(); + XGenericEventCookie cookie; + + using (new XLock(window.Display)) + { + if (!Functions.XCheckIfEvent(window.Display, ref e, Predicate, new IntPtr(XIOpCode))) + return; + + cookie = e.GenericEventCookie; + if (Functions.XGetEventData(window.Display, ref cookie) != 0) + { + XIRawEvent raw = (XIRawEvent) + Marshal.PtrToStructure(cookie.data, typeof(XIRawEvent)); + + if (!rawids.ContainsKey(raw.deviceid)) + { + mice.Add(new MouseState()); + rawids.Add(raw.deviceid, mice.Count - 1); + } + MouseState state = mice[rawids[raw.deviceid]]; + + switch (raw.evtype) + { + case XIEventType.RawMotion: + double x = 0, y = 0; + if (IsBitSet(raw.valuators.mask, 0)) + { + x = BitConverter.Int64BitsToDouble(Marshal.ReadInt64(raw.raw_values, 0)); + } + if (IsBitSet(raw.valuators.mask, 1)) + { + y = BitConverter.Int64BitsToDouble(Marshal.ReadInt64(raw.raw_values, 8)); + } + + if (!CheckMouseWarp(x, y)) + { + state.X += (int)x; + state.Y += (int)y; + } + break; + + case XIEventType.RawButtonPress: + switch (raw.detail) + { + case 1: state.EnableBit((int)MouseButton.Left); break; + case 2: state.EnableBit((int)MouseButton.Middle); break; + case 3: state.EnableBit((int)MouseButton.Right); break; + case 4: state.WheelPrecise++; break; + case 5: state.WheelPrecise--; break; + case 6: state.EnableBit((int)MouseButton.Button1); break; + case 7: state.EnableBit((int)MouseButton.Button2); break; + case 8: state.EnableBit((int)MouseButton.Button3); break; + case 9: state.EnableBit((int)MouseButton.Button4); break; + case 10: state.EnableBit((int)MouseButton.Button5); break; + case 11: state.EnableBit((int)MouseButton.Button6); break; + case 12: state.EnableBit((int)MouseButton.Button7); break; + case 13: state.EnableBit((int)MouseButton.Button8); break; + case 14: state.EnableBit((int)MouseButton.Button9); break; + } + break; + + case XIEventType.RawButtonRelease: + switch (raw.detail) + { + case 1: state.DisableBit((int)MouseButton.Left); break; + case 2: state.DisableBit((int)MouseButton.Middle); break; + case 3: state.DisableBit((int)MouseButton.Right); break; + case 6: state.DisableBit((int)MouseButton.Button1); break; + case 7: state.DisableBit((int)MouseButton.Button2); break; + case 8: state.DisableBit((int)MouseButton.Button3); break; + case 9: state.DisableBit((int)MouseButton.Button4); break; + case 10: state.DisableBit((int)MouseButton.Button5); break; + case 11: state.DisableBit((int)MouseButton.Button6); break; + case 12: state.DisableBit((int)MouseButton.Button7); break; + case 13: state.DisableBit((int)MouseButton.Button8); break; + case 14: state.DisableBit((int)MouseButton.Button9); break; + } + break; + } + mice[rawids[raw.deviceid]] = state; + } + Functions.XFreeEventData(window.Display, ref cookie); + } + } + } + + static bool IsEventValid(IntPtr display, ref XEvent e, IntPtr arg) + { + return e.GenericEventCookie.extension == arg.ToInt32() && + (e.GenericEventCookie.evtype == (int)XIEventType.RawMotion || + e.GenericEventCookie.evtype == (int)XIEventType.RawButtonPress || + e.GenericEventCookie.evtype == (int)XIEventType.RawButtonRelease); + } + + static bool IsBitSet(IntPtr mask, int bit) + { + unsafe + { + return (*((byte*)mask + (bit >> 3)) & (1 << (bit & 7))) != 0; + } + } + } +} + diff --git a/Source/OpenTK/Properties/Resources.resx b/Source/OpenTK/Properties/Resources.resx index 5ea0895e..7080a7d1 100644 --- a/Source/OpenTK/Properties/Resources.resx +++ b/Source/OpenTK/Properties/Resources.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file