diff --git a/Source/OpenTK/Minimal.cs b/Source/OpenTK/Minimal.cs index 4eef7fe8..3822148f 100644 --- a/Source/OpenTK/Minimal.cs +++ b/Source/OpenTK/Minimal.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Text; -#if IPHONE || MINIMAL +#if IPHONE || ANDROID || MINIMAL namespace OpenTK { @@ -117,165 +118,6 @@ namespace OpenTK #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 @@ -435,152 +277,6 @@ namespace OpenTK #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 @@ -727,253 +423,6 @@ namespace OpenTK #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 @@ -1227,13 +676,21 @@ namespace OpenTK IntPtr handle; public Icon(Icon icon, int width, int height) - { } + { + handle = icon.Handle; + Width = width; + Height = height; + } public IntPtr Handle { get { return handle; } set { handle = value; } } + public int Width { get; private set; } + + public int Height { get; private set; } + public Bitmap ToBitmap() { - return new Bitmap(); + return new Bitmap(Width, Height); } public void Dispose() @@ -1244,7 +701,10 @@ namespace OpenTK #region Image - public abstract class Image { } + public abstract class Image : IDisposable + { + public void Dispose() { } + } #endregion @@ -1274,12 +734,11 @@ namespace OpenTK internal void UnlockBits(BitmapData data) { - throw new NotImplementedException(); } internal BitmapData LockBits(Rectangle rectangle, ImageLockMode imageLockMode, PixelFormat pixelFormat) { - return new BitmapData(); + return new BitmapData(Width, Height, 0); } } @@ -2148,7 +1607,17 @@ namespace OpenTK sealed class BitmapData { + internal BitmapData(int width, int height, int stride) + { + Width = width; + Height = height; + stride = stride; + } + public IntPtr Scan0 { get { return IntPtr.Zero; } } + public int Width { get; private set; } + public int Height { get; private set; } + public int Stride { get; private set; } } #endregion