mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 02:25:28 +00:00
Implemented minimal System.Drawing stubs for Xamarin.Android targets.
This commit is contained in:
parent
b64c9d84e7
commit
bb3156d185
|
@ -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<Point>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
int x, y;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new Point instance.
|
||||
/// </summary>
|
||||
/// <param name="x">The X coordinate of this instance.</param>
|
||||
/// <param name="y">The Y coordinate of this instance.</param>
|
||||
public Point(int x, int y)
|
||||
: this()
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="System.Boolean"/> that indicates whether this instance is empty or zero.
|
||||
/// </summary>
|
||||
public bool IsEmpty { get { return X == 0 && Y == 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the X coordinate of this instance.
|
||||
/// </summary>
|
||||
public int X { get { return x; } set { x = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Y coordinate of this instance.
|
||||
/// </summary>
|
||||
public int Y { get { return y; } set { y = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Point (0, 0).
|
||||
/// </summary>
|
||||
public static readonly Point Zero = new Point();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Point (0, 0).
|
||||
/// </summary>
|
||||
public static readonly Point Empty = new Point();
|
||||
|
||||
/// <summary>
|
||||
/// Translates the specified Point by the specified Size.
|
||||
/// </summary>
|
||||
/// <param name="point">
|
||||
/// The <see cref="Point"/> instance to translate.
|
||||
/// </param>
|
||||
/// <param name="size">
|
||||
/// The <see cref="Size"/> instance to translate point with.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A new <see cref="Point"/> instance translated by size.
|
||||
/// </returns>
|
||||
public static Point operator +(Point point, Size size)
|
||||
{
|
||||
return new Point(point.X + size.Width, point.Y + size.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates the specified Point by the negative of the specified Size.
|
||||
/// </summary>
|
||||
/// <param name="point">
|
||||
/// The <see cref="Point"/> instance to translate.
|
||||
/// </param>
|
||||
/// <param name="size">
|
||||
/// The <see cref="Size"/> instance to translate point with.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A new <see cref="Point"/> instance translated by size.
|
||||
/// </returns>
|
||||
public static Point operator -(Point point, Size size)
|
||||
{
|
||||
return new Point(point.X - size.Width, point.Y - size.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The first instance.</param>
|
||||
/// <param name="right">The second instance.</param>
|
||||
/// <returns>True, if left is equal to right; false otherwise.</returns>
|
||||
public static bool operator ==(Point left, Point right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances for inequality.
|
||||
/// </summary>
|
||||
/// <param name="left">The first instance.</param>
|
||||
/// <param name="right">The second instance.</param>
|
||||
/// <returns>True, if left is not equal to right; false otherwise.</returns>
|
||||
public static bool operator !=(Point left, Point right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance is equal to the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object instance to compare to.</param>
|
||||
/// <returns>True, if both instances are equal; false otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Point)
|
||||
return Equals((Point)obj);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.Int32"/> that represents the hash code for this instance./></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return X.GetHashCode() ^ Y.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that describes this instance.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that describes this instance.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{{{0}, {1}}}", X, Y);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Point> Members
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance is equal to the specified Point.
|
||||
/// </summary>
|
||||
/// <param name="other">The instance to compare to.</param>
|
||||
/// <returns>True, if both instances are equal; false otherwise.</returns>
|
||||
public bool Equals(Point other)
|
||||
{
|
||||
return X == other.X && Y == other.Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PointF
|
||||
|
||||
public struct PointF : IEquatable<PointF>
|
||||
|
@ -435,152 +277,6 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region Size
|
||||
|
||||
public struct Size : IEquatable<Size>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
int width, height;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new Size instance.
|
||||
/// </summary>
|
||||
/// <param name="width">The width of this instance.</param>
|
||||
/// <param name="height">The height of this instance.</param>
|
||||
public Size(int width, int height)
|
||||
: this()
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of this instance.
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
get { return width; }
|
||||
set
|
||||
{
|
||||
if (width < 0)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
width = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height of this instance.
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
get { return height; }
|
||||
set
|
||||
{
|
||||
if (height < 0)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
height = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="System.Boolean"/> that indicates whether this instance is empty or zero.
|
||||
/// </summary>
|
||||
public bool IsEmpty
|
||||
{
|
||||
get { return Width == 0 && Height == 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a Size instance equal to (0, 0).
|
||||
/// </summary>
|
||||
public static readonly Size Empty = new Size();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a Size instance equal to (0, 0).
|
||||
/// </summary>
|
||||
public static readonly Size Zero = new Size();
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The first instance.</param>
|
||||
/// <param name="right">The second instance.</param>
|
||||
/// <returns>True, if left is equal to right; false otherwise.</returns>
|
||||
public static bool operator ==(Size left, Size right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances for inequality.
|
||||
/// </summary>
|
||||
/// <param name="left">The first instance.</param>
|
||||
/// <param name="right">The second instance.</param>
|
||||
/// <returns>True, if left is not equal to right; false otherwise.</returns>
|
||||
public static bool operator !=(Size left, Size right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance is equal to the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object instance to compare to.</param>
|
||||
/// <returns>True, if both instances are equal; false otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Size)
|
||||
return Equals((Size)obj);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.Int32"/> that represents the hash code for this instance./></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Width.GetHashCode() ^ Height.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that describes this instance.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that describes this instance.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{{{0}, {1}}}", Width, Height);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Size> Members
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance is equal to the specified Size.
|
||||
/// </summary>
|
||||
/// <param name="other">The instance to compare to.</param>
|
||||
/// <returns>True, if both instances are equal; false otherwise.</returns>
|
||||
public bool Equals(Size other)
|
||||
{
|
||||
return Width == other.Width && Height == other.Height;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SizeF
|
||||
|
||||
public struct SizeF : IEquatable<SizeF>
|
||||
|
@ -727,253 +423,6 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region Rectangle
|
||||
|
||||
public struct Rectangle : IEquatable<Rectangle>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
Point location;
|
||||
Size size;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new Rectangle instance.
|
||||
/// </summary>
|
||||
/// <param name="location">The top-left corner of the Rectangle.</param>
|
||||
/// <param name="size">The width and height of the Rectangle.</param>
|
||||
public Rectangle(Point location, Size size)
|
||||
: this()
|
||||
{
|
||||
Location = location;
|
||||
Size = size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new Rectangle instance.
|
||||
/// </summary>
|
||||
/// <param name="x">The x coordinate of the Rectangle.</param>
|
||||
/// <param name="y">The y coordinate of the Rectangle.</param>
|
||||
/// <param name="width">The width coordinate of the Rectangle.</param>
|
||||
/// <param name="height">The height coordinate of the Rectangle.</param>
|
||||
public Rectangle(int x, int y, int width, int height)
|
||||
: this(new Point(x, y), new Size(width, height))
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the x coordinate of the Rectangle.
|
||||
/// </summary>
|
||||
public int X
|
||||
{
|
||||
get { return Location.X; }
|
||||
set { Location = new Point(value, Y); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the y coordinate of the Rectangle.
|
||||
/// </summary>
|
||||
public int Y
|
||||
{
|
||||
get { return Location.Y; }
|
||||
set { Location = new Point(X, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the Rectangle.
|
||||
/// </summary>
|
||||
public int Width
|
||||
{
|
||||
get { return Size.Width; }
|
||||
set { Size = new Size(value, Height); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height of the Rectangle.
|
||||
/// </summary>
|
||||
public int Height
|
||||
{
|
||||
get { return Size.Height; }
|
||||
set { Size = new Size(Width, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="Point"/> representing the x and y coordinates
|
||||
/// of the Rectangle.
|
||||
/// </summary>
|
||||
public Point Location
|
||||
{
|
||||
get { return location; }
|
||||
set { location = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="Size"/> representing the width and height
|
||||
/// of the Rectangle.
|
||||
/// </summary>
|
||||
public Size Size
|
||||
{
|
||||
get { return size; }
|
||||
set { size = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the y coordinate of the top edge of this Rectangle.
|
||||
/// </summary>
|
||||
public int Top { get { return Y; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the x coordinate of the right edge of this Rectangle.
|
||||
/// </summary>
|
||||
public int Right { get { return X + Width; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the y coordinate of the bottom edge of this Rectangle.
|
||||
/// </summary>
|
||||
public int Bottom { get { return Y + Height; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the x coordinate of the left edge of this Rectangle.
|
||||
/// </summary>
|
||||
public int Left { get { return X; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="System.Boolean"/> that indicates whether this
|
||||
/// Rectangle is equal to the empty Rectangle.
|
||||
/// </summary>
|
||||
public bool IsEmpty
|
||||
{
|
||||
get { return Location.IsEmpty && Size.IsEmpty; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the empty Rectangle.
|
||||
/// </summary>
|
||||
public static readonly Rectangle Zero = new Rectangle();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the empty Rectangle.
|
||||
/// </summary>
|
||||
public static readonly Rectangle Empty = new Rectangle();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance with the specified edges.
|
||||
/// </summary>
|
||||
/// <param name="left">The left edge of the Rectangle.</param>
|
||||
/// <param name="top">The top edge of the Rectangle.</param>
|
||||
/// <param name="right">The right edge of the Rectangle.</param>
|
||||
/// <param name="bottom">The bottom edge of the Rectangle.</param>
|
||||
/// <returns>A new Rectangle instance with the specified edges.</returns>
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether this instance contains the specified Point.
|
||||
/// </summary>
|
||||
/// <param name="point">The <see cref="Point"/> to test.</param>
|
||||
/// <returns>True if this instance contains point; false otherwise.</returns>
|
||||
/// <remarks>The left and top edges are inclusive. The right and bottom edges
|
||||
/// are exclusive.</remarks>
|
||||
public bool Contains(Point point)
|
||||
{
|
||||
return point.X >= Left && point.X < Right &&
|
||||
point.Y >= Top && point.Y < Bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether this instance contains the specified Rectangle.
|
||||
/// </summary>
|
||||
/// <param name="rect">The <see cref="Rectangle"/> to test.</param>
|
||||
/// <returns>True if this instance contains rect; false otherwise.</returns>
|
||||
/// <remarks>The left and top edges are inclusive. The right and bottom edges
|
||||
/// are exclusive.</remarks>
|
||||
public bool Contains(Rectangle rect)
|
||||
{
|
||||
return Contains(rect.Location) && Contains(rect.Location + rect.Size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The first instance.</param>
|
||||
/// <param name="right">The second instance.</param>
|
||||
/// <returns>True, if left is equal to right; false otherwise.</returns>
|
||||
public static bool operator ==(Rectangle left, Rectangle right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two instances for inequality.
|
||||
/// </summary>
|
||||
/// <param name="left">The first instance.</param>
|
||||
/// <param name="right">The second instance.</param>
|
||||
/// <returns>True, if left is not equal to right; false otherwise.</returns>
|
||||
public static bool operator !=(Rectangle left, Rectangle right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance is equal to the specified object.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object instance to compare to.</param>
|
||||
/// <returns>True, if both instances are equal; false otherwise.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Rectangle)
|
||||
return Equals((Rectangle)obj);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hash code for this instance.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.Int32"/> that represents the hash code for this instance./></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Location.GetHashCode() & Size.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String"/> that describes this instance.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="System.String"/> that describes this instance.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{{{0}-{1}}}", Location, Location + Size);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Rectangle> Members
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this instance is equal to the specified Rectangle.
|
||||
/// </summary>
|
||||
/// <param name="other">The instance to compare to.</param>
|
||||
/// <returns>True, if both instances are equal; false otherwise.</returns>
|
||||
public bool Equals(Rectangle other)
|
||||
{
|
||||
return Location.Equals(other.Location) &&
|
||||
Size.Equals(other.Size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RectangleF
|
||||
|
||||
public struct RectangleF : IEquatable<RectangleF>
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue