From 05888e5ec9dee23ce0fb1beecfc866a19fa0a2e8 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 2 Sep 2020 12:32:49 -0400 Subject: [PATCH] add IsEmpty, Equals, ==, and != operators to Padding --- MBS.Framework/Drawing/Padding.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/MBS.Framework/Drawing/Padding.cs b/MBS.Framework/Drawing/Padding.cs index 56e6689..7cb70e0 100644 --- a/MBS.Framework/Drawing/Padding.cs +++ b/MBS.Framework/Drawing/Padding.cs @@ -7,6 +7,11 @@ namespace MBS.Framework.Drawing { public struct Padding { + public static Padding Empty; + + private bool _IsNotEmpty; + public bool IsEmpty { get { return !_IsNotEmpty; } } + private int mvarLeft; public int Left { get { return mvarLeft; } set { mvarLeft = value; } } private int mvarTop; @@ -16,6 +21,31 @@ namespace MBS.Framework.Drawing private int mvarBottom; public int Bottom { get { return mvarBottom; } set { mvarBottom = value; } } + public override bool Equals(object obj) + { + if (obj is Padding) + { + return (Padding)obj == this; + } + return false; + } + public static bool operator==(Padding left, Padding right) + { + return ((left.IsEmpty == right.IsEmpty) + && (left.Left == right.Left) + && (left.Right == right.Right) + && (left.Top == right.Top) + && (left.Bottom == right.Bottom)); + } + public static bool operator !=(Padding left, Padding right) + { + return (!((left.IsEmpty == right.IsEmpty) + && (left.Left == right.Left) + && (left.Right == right.Right) + && (left.Top == right.Top) + && (left.Bottom == right.Bottom))); + } + public int All { get @@ -38,6 +68,7 @@ namespace MBS.Framework.Drawing mvarLeft = all; mvarRight = all; mvarTop = all; + _IsNotEmpty = true; } public Padding(int top, int bottom, int left, int right) { @@ -45,6 +76,7 @@ namespace MBS.Framework.Drawing mvarLeft = left; mvarRight = right; mvarTop = top; + _IsNotEmpty = true; } } }