BoxMath Class


Provides simple layout math.

public class BoxMath
System.Object → BoxMath




AlignWith(RectangleF, RectangleF, ContentAlignment) Aligns the specified System.Drawing.RectangleF with a container System.Drawing.RectangleF using the specified System.Drawing.ContentAlignment. The container can be smaller than rect.
CenterInside(SizeF, RectangleF) Creates a rectangle of size 'size' with a center matching that of bounds. No rounding is performed.
FitsInside(SizeF, SizeF) Returns true if 'inner' fits inside or equals 'outer'
RoundPoints(SizeF) Rounds a SizeF structure using System.Round
ScaleInside(SizeF, SizeF) Scales 'inner' to fit inside 'bounding' while maintaining aspect ratio. Upscales and downscales.
ToRectangle(RectangleF) Rounds a floating-point rectangle to an integer rectangle using System.Round

Extension Methods

IsNullOrDefault(T) Gets a value indicating if the specified value has the default value of the generic type.
Serialize(Object) Serializes an object, or graph of connected objects, to a byte array.
SerializeToJson(Object, Nullable, JsonSerializerSettings) Serializes an object, or graph of connected objects, to a json string.
IsValid(Object) Determines whether the specified object is valid by evaluating each ValidationAttribute instance that is attached to the object type.