diff --git a/MBS.Framework/Drawing/Dimension2D.cs b/MBS.Framework/Drawing/Dimension2D.cs index 6ed22d1..7d520e1 100644 --- a/MBS.Framework/Drawing/Dimension2D.cs +++ b/MBS.Framework/Drawing/Dimension2D.cs @@ -1,6 +1,8 @@ +using System; + namespace MBS.Framework.Drawing { - public class Dimension2D : Dimension + public class Dimension2D : Dimension, IEquatable { private double mvarWidth = 0.0; public double Width { get { return mvarWidth; } set { mvarWidth = value; } } @@ -31,5 +33,36 @@ namespace MBS.Framework.Drawing { return Width.ToString() + "x" + Height.ToString(); } + + public override bool Equals(object obj) + { + if (obj is Dimension2D) + { + return ((Dimension2D)obj).Width.Equals(Width) && ((Dimension2D)obj).Height.Equals(Height); + } + return base.Equals(obj); + } + public bool Equals(Dimension2D other) + { + if ((object)other == null) return (object)this == null; + return Width.Equals(other.Width) && Height.Equals(other.Height); + } + + public static bool operator ==(Dimension2D left, Dimension2D right) + { + if ((left is null) && (right is null)) + return true; + if ((left is null) || (right is null)) + return false; + return left.Equals(right); + } + public static bool operator !=(Dimension2D left, Dimension2D right) + { + if ((left is null) && (right is null)) + return false; + if ((left is null) || (right is null)) + return true; + return !left.Equals(right); + } } }