This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
gwen-dotnet/Gwen/Padding.cs
Gered 10e057953e initial commit
Contains changes from "gwen-dotnet" removing dependancies on Windows,
which ultimately means certain features (e.g. file load/save dialogs)
do not work. Those classes still exist, but the code has been commented
out.
2013-03-28 18:47:01 -04:00

66 lines
1.8 KiB
C#

using System;
namespace Gwen
{
/// <summary>
/// Represents inner spacing.
/// </summary>
public struct Padding : IEquatable<Padding>
{
public readonly int Top;
public readonly int Bottom;
public readonly int Left;
public readonly int Right;
// common values
public static Padding Zero = new Padding(0, 0, 0, 0);
public static Padding One = new Padding(1, 1, 1, 1);
public static Padding Two = new Padding(2, 2, 2, 2);
public static Padding Three = new Padding(3, 3, 3, 3);
public static Padding Four = new Padding(4, 4, 4, 4);
public static Padding Five = new Padding(5, 5, 5, 5);
public Padding(int left, int top, int right, int bottom)
{
Top = top;
Bottom = bottom;
Left = left;
Right = right;
}
public bool Equals(Padding other)
{
return other.Top == Top && other.Bottom == Bottom && other.Left == Left && other.Right == Right;
}
public static bool operator ==(Padding lhs, Padding rhs)
{
return lhs.Equals(rhs);
}
public static bool operator !=(Padding lhs, Padding rhs)
{
return !lhs.Equals(rhs);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (obj.GetType() != typeof (Padding)) return false;
return Equals((Padding) obj);
}
public override int GetHashCode()
{
unchecked
{
int result = Top;
result = (result*397) ^ Bottom;
result = (result*397) ^ Left;
result = (result*397) ^ Right;
return result;
}
}
}
}