2011-10-31 05:36:24 +00:00
|
|
|
using System;
|
2012-08-09 09:45:04 +00:00
|
|
|
using System.Globalization;
|
2011-10-31 05:36:24 +00:00
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-10-31 05:36:24 +00:00
|
|
|
|
|
|
|
namespace ANX.Framework
|
|
|
|
{
|
2012-08-09 09:45:04 +00:00
|
|
|
[ANX.Framework.NonXNA.Development.PercentageComplete(100)]
|
2011-10-31 05:36:24 +00:00
|
|
|
public struct Point : IEquatable<Point>
|
|
|
|
{
|
|
|
|
#region fields
|
|
|
|
public int X;
|
|
|
|
public int Y;
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region properties
|
|
|
|
public static Point Zero
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return new Point(0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region constructors
|
|
|
|
public Point(int x, int y)
|
|
|
|
{
|
|
|
|
this.X = x;
|
|
|
|
this.Y = y;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region public methods
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
2011-11-16 22:35:53 +00:00
|
|
|
return this.X + this.Y;
|
2011-10-31 05:36:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
2012-08-09 09:45:04 +00:00
|
|
|
{
|
|
|
|
var culture = CultureInfo.CurrentCulture;
|
|
|
|
// This may look a bit more ugly, but String.Format should
|
|
|
|
// be avoided cause of it's bad performance!
|
|
|
|
return "{X:" + X.ToString(culture) +
|
|
|
|
" Y:" + Y.ToString(culture) + "}";
|
|
|
|
|
|
|
|
//return string.Format(culture, "{{X:{0} Y:{1}}}", new object[]
|
|
|
|
//{
|
|
|
|
// this.X.ToString(culture),
|
|
|
|
// this.Y.ToString(culture)
|
|
|
|
//});
|
2011-10-31 05:36:24 +00:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region IEquatable implementation
|
|
|
|
public override bool Equals(Object obj)
|
|
|
|
{
|
|
|
|
return (obj is Point) ? this.Equals((Point)obj) : false;
|
|
|
|
}
|
|
|
|
public bool Equals(Point other)
|
|
|
|
{
|
|
|
|
return this.X == other.X && this.Y == other.Y;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region operator overloading
|
|
|
|
public static bool operator ==(Point first, Point second)
|
|
|
|
{
|
|
|
|
return first.X == second.X && first.Y == second.Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool operator !=(Point first, Point second)
|
|
|
|
{
|
|
|
|
return first.X != second.X || first.Y != second.Y;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|