Struct Spot
- Namespace
- Northwoods.Go
- Assembly
- Northwoods.GoDiagram.WinForms.dll
A Spot represents a relative point from (0,0) to (1,1) within the bounds of a rectangular area plus an absolute offset.
[JsonConverter(typeof(SpotJsonConverter))]
public struct Spot
- Inherited Members
Remarks
Use the static functions Parse(string) and Stringify(Spot) to convert to and from a standard string representation that is independent of the current locale.
Constructors
Spot(double, double, double, double)
The default constructor produces the Spot(0, 0, 0, 0), at the top-left corner.
public Spot(double x = 0, double y = 0, double offx = 0, double offy = 0)
Parameters
x
doubleThe x value of the Spot, a fractional value between zero and one. Default is zero.
y
doubleThe y value of the Spot, a fractional value between zero and one. Default is zero.
offx
double(Optional) The absolute x offset. Default is zero.
offy
double(Optional) The absolute y offset. Default is zero.
Fields
AllSides
The set of points on all sides of the bounding rectangle.
public static readonly Spot AllSides
Field Value
Bottom
The specific point at the middle of the bottom side of bounding rectangle.
public static readonly Spot Bottom
Field Value
BottomLeft
The specific point at the bottom-left corner of the bounding rectangle.
public static readonly Spot BottomLeft
Field Value
BottomLeftSides
The set of points at the left or bottom sides of the bounding rectangle.
public static readonly Spot BottomLeftSides
Field Value
BottomRight
The specific point at the bottom-right corner of the bounding rectangle.
public static readonly Spot BottomRight
Field Value
BottomRightSides
The set of points at the right or bottom sides of the bounding rectangle.
public static readonly Spot BottomRightSides
Field Value
BottomSide
The set of points at the bottom side of the bounding rectangle.
public static readonly Spot BottomSide
Field Value
Center
The specific point at the very center of the bounding rectangle.
public static readonly Spot Center
Field Value
Default
Use this value to indicate that the real spot value is inherited from elsewhere.
public static readonly Spot Default
Field Value
Left
The specific point at the middle of the left side of bounding rectangle.
public static readonly Spot Left
Field Value
LeftRightSides
The set of points at the left or right sides of the bounding rectangle.
public static readonly Spot LeftRightSides
Field Value
LeftSide
The set of points at the left side of the bounding rectangle.
public static readonly Spot LeftSide
Field Value
None
Use this Spot value to indicate no particular spot -- code looking for a particular point on an element will need to do their own calculations to determine the desired point depending on the circumstances.
public static readonly Spot None
Field Value
NotBottomSide
The set of points on all sides of bounding rectangle except bottom side.
public static readonly Spot NotBottomSide
Field Value
NotLeftSide
The set of points on all sides of the bounding rectangle except left side.
public static readonly Spot NotLeftSide
Field Value
NotRightSide
The set of points on all sides of the bounding rectangle except right side.
public static readonly Spot NotRightSide
Field Value
NotTopSide
The set of points on all sides of the bounding rectangle except top side.
public static readonly Spot NotTopSide
Field Value
Right
The specific point at the middle of the right side of bounding rectangle.
public static readonly Spot Right
Field Value
RightSide
The set of points at the right side of the bounding rectangle.
public static readonly Spot RightSide
Field Value
Top
The specific point at the center of the top side of the bounding rectangle.
public static readonly Spot Top
Field Value
TopBottomSides
The set of points at the top or bottom sides of the bounding rectangle.
public static readonly Spot TopBottomSides
Field Value
TopLeft
The specific point at the top-left corner of the bounding rectangle.
public static readonly Spot TopLeft
Field Value
TopLeftSides
The set of points at the top or left sides of the bounding rectangle.
public static readonly Spot TopLeftSides
Field Value
TopRight
The specific point at the top-right corner of the bounding rectangle.
public static readonly Spot TopRight
Field Value
TopRightSides
The set of points at the top or right sides of the bounding rectangle.
public static readonly Spot TopRightSides
Field Value
TopSide
The set of points at the top side of the bounding rectangle.
public static readonly Spot TopSide
Field Value
Properties
OffsetX
Gets or sets the offsetX value of the Spot. The value may be negative. If this represents a side value instead of a specific spot, this value is meaningless.
public double OffsetX { readonly get; set; }
Property Value
Remarks
A Spot(0,0,5,5) of a large rectangle is near the top-left corner, inside the rectangle. A Spot(1,1,5,5) would be near the bottom-right corner, outside the rectangle. A Spot(1,1,-5,-5) would also be near the bottom-right corner, but inside the rectangle.
OffsetY
Gets or sets the offsetY value of the Spot. The value may be negative. If this represents a side value instead of a specific spot, this value is meaningless.
public double OffsetY { readonly get; set; }
Property Value
Remarks
A Spot(0,0,5,5) of a large rectangle is near the top-left corner, inside the rectangle. A Spot(1,1,5,5) would be near the bottom-right corner, outside the rectangle. A Spot(1,1,-5,-5) would also be near the bottom-right corner, but inside the rectangle.
X
Gets or sets the x value of the Spot, a fractional value between zero and one.
public double X { get; set; }
Property Value
Remarks
The Spot(0,0) of a rectangle is at the top-left corner. This value is commonly available as TopLeft. The Spot(0.5,1) would be at the middle of the bottom side. That value is commonly available as Bottom.
Y
Gets or sets the y value of the Spot, a fractional value between zero and one.
public double Y { get; set; }
Property Value
Remarks
The Spot(0,1) of a rectangle is at the bottom-left corner. This value is commonly available as BottomLeft. The Spot(1,0.5) would be at the middle of the right side. That value is commonly available as Right.
Methods
Equals(object)
Two spots are equal if all four property values are the same.
public override bool Equals(object obj)
Parameters
obj
objectThe Spot to compare to the current Spot.
Returns
- bool
True if the two spots are equal, false otherwise.
GetHashCode()
Creates a hash code for the spot.
public override int GetHashCode()
Returns
- int
A hash code for the current spot structure.
IncludesSide(Spot)
This predicate is true if this Spot is a side that includes the side(s) given by the argument Spot.
public bool IncludesSide(Spot side)
Parameters
side
Spot
Returns
- bool
false if either this Spot or the argument Spot is not a "Side"; true if the side(s) that this Spot represents are a superset or the same set of sides represented by the argument Spot.
IsDefault()
True if this is a special spot indicating that the real spot value will come from another source.
public bool IsDefault()
Returns
IsNoSpot()
True if this is an unspecific special spot, such as None or one of the sides.
public bool IsNoSpot()
Returns
IsNone()
True if this is a special spot referring to no particular spot or side.
public bool IsNone()
Returns
IsSide()
True if this is a special spot referring to one (or more) of the sides. This is false if the spot is None.
public bool IsSide()
Returns
IsSpot()
True if this is a specific spot, not a side nor None.
public bool IsSpot()
Returns
Opposite()
Return a new spot that is opposite this spot.
public Spot Opposite()
Returns
Remarks
The X and Y values will be an equal distance away from the center on the other side of the center. The OffsetX and OffsetY values are also negated.
The result is meaningless if IsNoSpot() is true.
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 Spot from a string that was produced by Stringify(Spot).
public static Spot Parse(string str)
Parameters
str
string
Returns
Remarks
Spot.Parse("0 1 2 3")
produces the Spot new Spot(0, 1, 2, 3)
.
Stringify(Spot)
This static method can be used to write out a Spot as a string that can be read by Parse(string).
public static string Stringify(Spot val)
Parameters
val
Spot
Returns
Remarks
Spot.Stringify(new Spot(0, 1, 2, 3))
produces the string "0 1 2 3".
Stringify(object)
This is a convenience method for Stringify(Spot) that can be used as a BackConverter.
public static object Stringify(object spot)
Parameters
spot
object
Returns
StringifyFixed(Spot, int)
This static method can be used to write out a Spot as a string with its numbers at a fixed number of digits after the decimal point.
public static string StringifyFixed(Spot 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(Spot, int) that can be used as a BackConverter. This convenience method uses two decimal places.
public static object StringifyFixed(object spot)
Parameters
spot
object
Returns
ToString()
Returns a string representation of the spot.
public override string ToString()
Returns
- string
A string representation of the current spot.
Operators
operator ==(Spot, Spot)
public static bool operator ==(Spot left, Spot right)
Parameters
Returns
operator !=(Spot, Spot)
public static bool operator !=(Spot left, Spot right)