using System; using System.Runtime.CompilerServices; namespace OpenMacroBoard.SDK { /// /// Stores an ordered pair of integers, which specify a height and width. /// public readonly struct OmbSize : IEquatable { /// /// Represents a that has Width and Height values set to zero. /// public static readonly OmbSize Empty = default; /// /// Initializes a new instance of the struct. /// /// The width and height of the size. public OmbSize(int value) : this() { Width = value; Height = value; } /// /// Initializes a new instance of the struct. /// /// The width of the size. /// The height of the size. public OmbSize(int width, int height) { Width = width; Height = height; } /// /// Initializes a new instance of the struct. /// /// The size. public OmbSize(OmbSize size) : this() { Width = size.Width; Height = size.Height; } /// /// Initializes a new instance of the struct from the given . /// /// The point. public OmbSize(OmbPoint point) { Width = point.X; Height = point.Y; } /// /// Gets or sets the width of this . /// public int Width { get; } /// /// Gets or sets the height of this . /// public int Height { get; } /// /// Gets a value indicating whether this is empty. /// public bool IsEmpty => Equals(Empty); /// /// Converts the given into a . /// /// The size. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator OmbPoint(OmbSize size) { return new OmbPoint(size.Width, size.Height); } /// /// Compares two objects for equality. /// /// /// The on the left side of the operand. /// /// /// The on the right side of the operand. /// /// /// True if the current left is equal to the parameter; otherwise, false. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(OmbSize left, OmbSize right) { return left.Equals(right); } /// /// Compares two objects for inequality. /// /// /// The on the left side of the operand. /// /// /// The on the right side of the operand. /// /// /// True if the current left is unequal to the parameter; otherwise, false. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(OmbSize left, OmbSize right) { return !left.Equals(right); } /// /// Deconstructs this size into two integers. /// /// The out value for the width. /// The out value for the height. public void Deconstruct(out int width, out int height) { width = Width; height = Height; } /// public override int GetHashCode() { return HashCode.Combine(Width, Height); } /// public override string ToString() { return $"Size [ Width={Width}, Height={Height} ]"; } /// public override bool Equals(object obj) { return obj is OmbSize other && Equals(other); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(OmbSize other) { return Width.Equals(other.Width) && Height.Equals(other.Height); } } }