Struct Size
- Namespace
- Northwoods.Go
- Assembly
- Northwoods.GoDiagram.WinForms.dll
A Size describes a width and a height in two-dimensional coordinates. The width and height must both be non-negative.
public struct Size
- Inherited Members
Remarks
Use the static functions Parse(string) and Stringify(Size) to convert to and from a standard string representation that is independent of the current locale.
Constructors
Size(double, double)
The default constructor produces the Size(0,0). This constructor may take either zero arguments or two arguments.
public Size(double w = 0, double h = 0)
Parameters
w
doubleThe initial width (must be non-negative).
h
doubleThe initial height (must be non-negative).
Properties
Height
Gets or sets the height value of the Size. The value must not be negative.
public double Height { get; set; }
Property Value
Width
Gets or sets the width value of the Size. The value must not be negative.
public double Width { get; set; }
Property Value
Methods
Equals(double, double)
Indicates whether the given size is equal to this Size.
public bool Equals(double w, double h)
Parameters
Returns
- bool
True if the Sizes have the same width and height, false otherwise.
- See Also
Equals(object)
Indicates whether the given Size is equal to the current Size.
public override bool Equals(object obj)
Parameters
obj
objectThe Size to compare to the current Size.
Returns
- bool
True if the Sizes have the same width and height, false otherwise.
- See Also
EqualsApprox(Size)
Indicates whether the given Size is nearly equal to this Size.
public bool EqualsApprox(Size s)
Parameters
s
SizeThe Size to compare to the current Size.
Returns
- bool
True if the two Sizes have Width and Height values that are equal with a tolerance of 0.5, false otherwise.
GetHashCode()
Creates a hash code for the size.
public override int GetHashCode()
Returns
- int
A hash code for the current size structure.
Inflate(double, double)
Returns a new Size that is this Size with its width and height changed by the given distances. When the arguments are negative, this operation deflates this Size, but not beyond zero.
public Size Inflate(double w, double h)
Parameters
w
doubleThe additional width, which must be a real number; may be negative.
h
doubleThe additional height, which must be a real number; may be negative.
Returns
- Size
A new Size.
IsReal()
True if this Size has Width and Height values that are real numbers and not infinity.
public bool IsReal()
Returns
Parse(object)
This is a convenience method for Parse(string) that can be used as a Converter.
public static object Parse(object str)
Parameters
str
object
Returns
Parse(string)
This static method can be used to read in a Size from a string that was produced by Stringify(Size).
public static Size Parse(string str)
Parameters
str
string
Returns
Remarks
Size.Parse("1 2")
produces the Size new Size(1, 2)
.
Stringify(Size)
This static method can be used to write out a Size as a string that can be read by Parse(string).
public static string Stringify(Size val)
Parameters
val
Size
Returns
Remarks
Size.Stringify(new Size(1, 2))
produces the string "1 2".
Stringify(object)
This is a convenience method for Stringify(Size) that can be used as a BackConverter.
public static object Stringify(object sz)
Parameters
sz
object
Returns
StringifyFixed(Size, int)
This static method can be used to write out a Size as a string with its numbers at a fixed number of digits after the decimal point.
public static string StringifyFixed(Size val, int digits)
Parameters
Returns
Remarks
This is useful for limiting the size of JSON output and making it more legible. It might also be useful for regression testing.
StringifyFixed(object)
This is a convenience method for StringifyFixed(Size, int) that can be used as a BackConverter. This convenience method uses two decimal places.
public static object StringifyFixed(object size)
Parameters
size
object
Returns
ToString()
Returns a string representation of the size.
public override string ToString()
Returns
- string
A string representation of the current size.
Operators
operator ==(Size, Size)
public static bool operator ==(Size left, Size right)
Parameters
Returns
operator !=(Size, Size)
public static bool operator !=(Size left, Size right)