00001 #region License
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #endregion
00027
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031
00032 namespace OpenTK
00033 {
00034 #if NO_SYSDRAWING
00038 public struct Size : IEquatable<Size>
00039 {
00040 #region Fields
00041
00042 int width, height;
00043
00044 #endregion
00045
00046 #region Constructors
00047
00053 public Size(int width, int height)
00054 : this()
00055 {
00056 Width = width;
00057 Height = height;
00058 }
00059
00060 #endregion
00061
00062 #region Public Members
00063
00067 public int Width
00068 {
00069 get { return width; }
00070 set
00071 {
00072 if (width < 0)
00073 throw new ArgumentOutOfRangeException();
00074 width = value;
00075 }
00076 }
00077
00081 public int Height
00082 {
00083 get { return height; }
00084 set
00085 {
00086 if (height < 0)
00087 throw new ArgumentOutOfRangeException();
00088 height = value;
00089 }
00090 }
00091
00095 public bool IsEmpty
00096 {
00097 get { return Width == 0 && Height == 0; }
00098 }
00099
00103 public static readonly Size Empty = new Size();
00104
00108 public static readonly Size Zero = new Size();
00109
00116 public static bool operator ==(Size left, Size right)
00117 {
00118 return left.Equals(right);
00119 }
00120
00127 public static bool operator !=(Size left, Size right)
00128 {
00129 return !left.Equals(right);
00130 }
00131
00141 public static implicit operator System.Drawing.Size(Size size)
00142 {
00143 return new System.Drawing.Size(size.Width, size.Height);
00144 }
00145
00155 public static implicit operator Size(System.Drawing.Size size)
00156 {
00157 return new Size(size.Width, size.Height);
00158 }
00159
00169 public static implicit operator System.Drawing.SizeF(Size size)
00170 {
00171 return new System.Drawing.SizeF(size.Width, size.Height);
00172 }
00173
00179 public override bool Equals(object obj)
00180 {
00181 if (obj is Size)
00182 return Equals((Size)obj);
00183
00184 return false;
00185 }
00186
00191 public override int GetHashCode()
00192 {
00193 return Width.GetHashCode() ^ Height.GetHashCode();
00194 }
00195
00200 public override string ToString()
00201 {
00202 return String.Format("{{{0}, {1}}}", Width, Height);
00203 }
00204
00205 #endregion
00206
00207 #region IEquatable<Size> Members
00208
00214 public bool Equals(Size other)
00215 {
00216 return Width == other.Width && Height == other.Height;
00217 }
00218
00219 #endregion
00220 }
00221 #endif
00222 }