86 lines
2.2 KiB
C#
Raw Permalink Normal View History

2011-10-31 05:36:24 +00:00
using System;
using System.Globalization;
using ANX.Framework.NonXNA.Development;
using System.ComponentModel;
using ANX.Framework.Design;
2011-10-31 05:36:24 +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
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Tested)]
#if !WINDOWSMETRO
[Serializable]
[TypeConverter(typeof(PointConverter))]
#endif
public struct Point : IEquatable<Point>
{
#region Constants
public static Point Zero
{
get
{
return new Point(0, 0);
}
}
#endregion
2011-10-31 05:36:24 +00:00
#region Public
public int X;
public int Y;
#endregion
2011-10-31 05:36:24 +00:00
#region Constructor
public Point(int x, int y)
{
this.X = x;
this.Y = y;
}
#endregion
2011-10-31 05:36:24 +00:00
#region GetHashCode
public override int GetHashCode()
{
return this.X + this.Y;
}
#endregion
2011-10-31 05:36:24 +00:00
#region ToString
public override string ToString()
{
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) + "}";
}
#endregion
#region Equals
public override bool Equals(Object obj)
{
return obj is Point && this.Equals((Point)obj);
}
2011-10-31 05:36:24 +00:00
public bool Equals(Point other)
{
return this.X == other.X && this.Y == other.Y;
}
#endregion
2011-10-31 05:36:24 +00:00
#region operator overloading
public static bool operator ==(Point first, Point second)
{
return first.X == second.X && first.Y == second.Y;
}
2011-10-31 05:36:24 +00:00
public static bool operator !=(Point first, Point second)
{
return first.X != second.X || first.Y != second.Y;
}
#endregion
}
2011-10-31 05:36:24 +00:00
}