convert Vector2D into value type
This commit is contained in:
parent
545b3728f1
commit
c09ec3549d
@ -5,28 +5,54 @@ using System.Text;
|
|||||||
|
|
||||||
namespace MBS.Framework.Drawing
|
namespace MBS.Framework.Drawing
|
||||||
{
|
{
|
||||||
public abstract class Vector
|
public struct Vector2D : IEquatable<Vector2D>
|
||||||
{
|
{
|
||||||
}
|
private bool _IsNotEmpty;
|
||||||
public class Vector2D
|
public bool IsEmpty { get { return !_IsNotEmpty; } }
|
||||||
{
|
|
||||||
private double mvarX = 0.0;
|
public static Vector2D Empty = new Vector2D();
|
||||||
public double X { get { return mvarX; } set { mvarX = value; } }
|
|
||||||
private double mvarY = 0.0;
|
public double X { get; set; }
|
||||||
public double Y { get { return mvarY; } set { mvarY = value; } }
|
public double Y { get; set; }
|
||||||
|
|
||||||
public Vector2D()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
public Vector2D(double x, double y)
|
public Vector2D(double x, double y)
|
||||||
{
|
{
|
||||||
mvarX = x;
|
X = x;
|
||||||
mvarY = y;
|
Y = y;
|
||||||
|
_IsNotEmpty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format("({0}, {1})", X, Y);
|
return String.Format("({0}, {1})", X, Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region IEquatable implementation
|
||||||
|
|
||||||
|
public bool Equals(Vector2D other)
|
||||||
|
{
|
||||||
|
return (this.X.Equals(other.X) && this.Y.Equals(other.Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(Vector2D left, Vector2D right)
|
||||||
|
{
|
||||||
|
return left.Equals(right);
|
||||||
|
}
|
||||||
|
public static bool operator !=(Vector2D left, Vector2D right)
|
||||||
|
{
|
||||||
|
return !left.Equals(right);
|
||||||
|
}
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj is Vector2D)
|
||||||
|
{
|
||||||
|
Vector2D other = (Vector2D)obj;
|
||||||
|
return X.Equals(other.X) && Y.Equals(other.Y) && IsEmpty.Equals(other.IsEmpty);
|
||||||
|
}
|
||||||
|
return base.Equals(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user