CPF/CPF.ReoGrid/PaddingValue.cs

75 lines
1.6 KiB
C#
Raw Normal View History

2024-06-24 10:15:59 +08:00
using System;
namespace CPF.ReoGrid
{
[Serializable]
public struct PaddingValue
{
public float Top { readonly get; set; }
public float Bottom { readonly get; set; }
public float Left { readonly get; set; }
public float Right { readonly get; set; }
public PaddingValue(float all)
{
this = new PaddingValue(all, all, all, all);
}
public PaddingValue(float top, float bottom, float left, float right)
{
this = default(PaddingValue);
this.Top = top;
this.Bottom = bottom;
this.Left = left;
this.Right = right;
}
public static bool operator ==(PaddingValue p1, PaddingValue p2)
{
return p1.Left == p2.Left && p1.Top == p2.Top && p1.Right == p2.Right && p1.Bottom == p2.Bottom;
}
public static bool operator !=(PaddingValue p1, PaddingValue p2)
{
return p1.Left != p2.Left || p1.Top != p2.Top || p1.Right != p2.Right || p1.Bottom != p2.Bottom;
}
public override bool Equals(object obj)
{
bool flag = !(obj is PaddingValue);
bool result;
if (flag)
{
result = false;
}
else
{
PaddingValue paddingValue = (PaddingValue)obj;
result = (this.Top == paddingValue.Top && this.Left == paddingValue.Left && this.Right == paddingValue.Right && this.Bottom == paddingValue.Bottom);
}
return result;
}
public override int GetHashCode()
{
return (int)(this.Top + this.Left * 2f + this.Right * 3f + this.Bottom * 4f);
}
public override string ToString()
{
return string.Format("[{0}, {1}, {2}, {3}]", new object[]
{
this.Top,
this.Bottom,
this.Left,
this.Right
});
}
public static readonly PaddingValue Empty = new PaddingValue(0f);
}
}