Class Size
A size (width and height).
Inheritance
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class Size : IComparable
Constructors
Size()
Initializes a new instance of the Size class.
Declaration
public Size()
Size(Int32, Int32)
Initializes a new instance of the Size class.
Declaration
public Size(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | width | The width. |
System.Int32 | height | The height. |
Properties
Empty
Gets the empty size (0x0).
Declaration
public static Size Empty { get; }
Property Value
Type | Description |
---|---|
Size |
Height
Gets or sets the height.
Declaration
public int Height { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Width
Gets or sets the width.
Declaration
public int Width { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
CompareTo(Object)
Compares this instance to a specified size and returns an indication of their relative values.
Declaration
public int CompareTo(object size)
Parameters
Type | Name | Description |
---|---|---|
System.Object | size | A size to compare. |
Returns
Type | Description |
---|---|
System.Int32 | A signed number indicating the relative values of this instance and size. |
Equals(Size)
Determines whether the specified size is equivalent to the current size. Does not require the object pointers to match.
Declaration
public bool Equals(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size | The size to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified size is equivalent to the current size; otherwise, false. |
Equals(Object)
Determines whether the specified object is equivalent to the current size. Does not require the object pointers to match.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified object is equivalent to the current object; otherwise, false. |
FromJson(String)
Deserializes an instance from JSON.
Declaration
public static Size FromJson(string sizeJson)
Parameters
Type | Name | Description |
---|---|---|
System.String | sizeJson | The JSON to deserialize. |
Returns
Type | Description |
---|---|
Size | The deserialized size. |
FromStruct(System.Drawing.Size)
Converts a System.Drawing.Size to a Size.
Declaration
public static Size FromStruct(System.Drawing.Size size)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Size | size |
Returns
Type | Description |
---|---|
Size |
GetHashCode()
Gets a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code. |
IsEquivalent(Size)
Determines whether the specified size is equivalent.
Declaration
public bool IsEquivalent(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size | The size. |
Returns
Type | Description |
---|---|
System.Boolean |
IsEquivalent(Size, Size)
Determines whether the two sizes are equivalent.
Declaration
public static bool IsEquivalent(Size size1, Size size2)
Parameters
Type | Name | Description |
---|---|---|
Size | size1 | The first size. |
Size | size2 | The second size. |
Returns
Type | Description |
---|---|
System.Boolean |
ToJson()
Serializes this instance to JSON.
Declaration
public string ToJson()
Returns
Type | Description |
---|---|
System.String | The serialized JSON. |
ToJson(Size)
Serializes an instance to JSON.
Declaration
public static string ToJson(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size | The size. |
Returns
Type | Description |
---|---|
System.String | The serialized JSON. |
ToString()
Returns a string that represents this instance using format "{width}x{height}".
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
ToStruct()
Converts this Size to a System.Drawing.Size.
Declaration
public System.Drawing.Size ToStruct()
Returns
Type | Description |
---|---|
System.Drawing.Size |
ToStruct(Size)
Converts a Size to a System.Drawing.Size.
Declaration
public static System.Drawing.Size ToStruct(Size size)
Parameters
Type | Name | Description |
---|---|---|
Size | size |
Returns
Type | Description |
---|---|
System.Drawing.Size |
Operators
Equality(Size, Size)
Determines whether the specified size is equivalent to the current size. Does not require the object pointers to match.
Declaration
public static bool operator ==(Size size1, Size size2)
Parameters
Type | Name | Description |
---|---|---|
Size | size1 | The first size. |
Size | size2 | The second size. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified size is equivalent to the current size; otherwise, false. |
Inequality(Size, Size)
Determines whether the specified size is NOT equivalent to the current size.
Declaration
public static bool operator !=(Size size1, Size size2)
Parameters
Type | Name | Description |
---|---|---|
Size | size1 | The first size. |
Size | size2 | The second size. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified size is NOT equivalent to the current size; otherwise, false. |