diff options
| author | jpbruyere <jp_bruyere@hotmail.com> | 2013-11-16 09:16:43 +0100 |
|---|---|---|
| committer | jpbruyere <jp_bruyere@hotmail.com> | 2013-11-16 09:16:43 +0100 |
| commit | dab0f2befeda33bd1c8e59ec41a2e1768712086b (patch) | |
| tree | e1dc606a3d8eeccd221e8adc03edc8639c3daa17 /src/Size.cs | |
first commit
Diffstat (limited to 'src/Size.cs')
| -rw-r--r-- | src/Size.cs | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/Size.cs b/src/Size.cs new file mode 100644 index 00000000..5dadfc33 --- /dev/null +++ b/src/Size.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace go +{ + public struct Size + { + public static Size Zero + { get { return new Size(0, 0); } } + int _width; + int _height; + + //public Size() + //{ } + public Size(int width, int height) + { + _width = width; + _height = height; + } + public int Width + { + get { return _width; } + set { _width = value; } + } + public int Height + { + get { return _height; } + set { _height = value; } + } + public override string ToString() + { + return string.Format("({0},{1})", Width, Height); + } + public static implicit operator Size(int i) + { + return new Size(i, i); + } + public static bool operator ==(Size s1, Size s2) + { + if (s1.Width == s2.Width && s1.Height == s2.Height) + return true; + else + return false; + } + public static bool operator !=(Size s1, Size s2) + { + if (s1.Width == s2.Width && s1.Height == s2.Height) + return false; + else + return true; + } + public static bool operator >(Size s1, Size s2) + { + if (s1.Width > s2.Width && s1.Height > s2.Height) + return true; + else + return false; + } + public static bool operator >=(Size s1, Size s2) + { + if (s1.Width >= s2.Width && s1.Height >= s2.Height) + return true; + else + return false; + } + public static bool operator <(Size s1, Size s2) + { + if (s1.Width < s2.Width) + if (s1.Height <= s2.Height) + return true; + else + return false; + else if (s1.Width == s2.Width && s1.Height < s2.Height) + return true; + + return false; + } + public static bool operator <=(Size s1, Size s2) + { + if (s1.Width <= s2.Width && s1.Height <= s2.Height) + return true; + else + return false; + } + public static bool operator ==(Size s, int i) + { + if (s.Width == i && s.Height == i) + return true; + else + return false; + } + public static bool operator !=(Size s, int i) + { + if (s.Width == i && s.Height == i) + return false; + else + return true; + } + public static Size operator +(Size s, int i) + { + return new Size(s.Width + i, s.Height + i); + } + } + +} |