Struct Spot
A Spot represents a relative point from (0,0) to (1,1) within the bounds of a rectangular area plus an absolute offset.
Namespace: Northwoods.Go
Assembly: Northwoods.GoDiagram.WinForms.dll
Syntax
[JsonConverter(typeof(SpotJsonConverter))]
public struct Spot
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.
Declaration
public Spot(double x = 0, double y = 0, double offx = 0, double offy = 0)
Parameters
Type | Name | Description |
---|---|---|
double | x | The x value of the Spot, a fractional value between zero and one. Default is zero. |
double | y | The y value of the Spot, a fractional value between zero and one. Default is zero. |
double | offx | (Optional) The absolute x offset. Default is zero. |
double | offy | (Optional) The absolute y offset. Default is zero. |
Fields
AllSides
The set of points on all sides of the bounding rectangle.
Declaration
public static readonly Spot AllSides
Field Value
Type | Description |
---|---|
Spot |
Bottom
The specific point at the middle of the bottom side of bounding rectangle.
Declaration
public static readonly Spot Bottom
Field Value
Type | Description |
---|---|
Spot |
BottomLeft
The specific point at the bottom-left corner of the bounding rectangle.
Declaration
public static readonly Spot BottomLeft
Field Value
Type | Description |
---|---|
Spot |
BottomLeftSides
The set of points at the left or bottom sides of the bounding rectangle.
Declaration
public static readonly Spot BottomLeftSides
Field Value
Type | Description |
---|---|
Spot |
BottomRight
The specific point at the bottom-right corner of the bounding rectangle.
Declaration
public static readonly Spot BottomRight
Field Value
Type | Description |
---|---|
Spot |
BottomRightSides
The set of points at the right or bottom sides of the bounding rectangle.
Declaration
public static readonly Spot BottomRightSides
Field Value
Type | Description |
---|---|
Spot |
BottomSide
The set of points at the bottom side of the bounding rectangle.
Declaration
public static readonly Spot BottomSide
Field Value
Type | Description |
---|---|
Spot |
Center
The specific point at the very center of the bounding rectangle.
Declaration
public static readonly Spot Center
Field Value
Type | Description |
---|---|
Spot |
Default
Use this value to indicate that the real spot value is inherited from elsewhere.
Declaration
public static readonly Spot Default
Field Value
Type | Description |
---|---|
Spot |
Left
The specific point at the middle of the left side of bounding rectangle.
Declaration
public static readonly Spot Left
Field Value
Type | Description |
---|---|
Spot |
LeftRightSides
The set of points at the left or right sides of the bounding rectangle.
Declaration
public static readonly Spot LeftRightSides
Field Value
Type | Description |
---|---|
Spot |
LeftSide
The set of points at the left side of the bounding rectangle.
Declaration
public static readonly Spot LeftSide
Field Value
Type | Description |
---|---|
Spot |
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.
Declaration
public static readonly Spot None
Field Value
Type | Description |
---|---|
Spot |
NotBottomSide
The set of points on all sides of bounding rectangle except bottom side.
Declaration
public static readonly Spot NotBottomSide
Field Value
Type | Description |
---|---|
Spot |
NotLeftSide
The set of points on all sides of the bounding rectangle except left side.
Declaration
public static readonly Spot NotLeftSide
Field Value
Type | Description |
---|---|
Spot |
NotRightSide
The set of points on all sides of the bounding rectangle except right side.
Declaration
public static readonly Spot NotRightSide
Field Value
Type | Description |
---|---|
Spot |
NotTopSide
The set of points on all sides of the bounding rectangle except top side.
Declaration
public static readonly Spot NotTopSide
Field Value
Type | Description |
---|---|
Spot |
Right
The specific point at the middle of the right side of bounding rectangle.
Declaration
public static readonly Spot Right
Field Value
Type | Description |
---|---|
Spot |
RightSide
The set of points at the right side of the bounding rectangle.
Declaration
public static readonly Spot RightSide
Field Value
Type | Description |
---|---|
Spot |
Top
The specific point at the center of the top side of the bounding rectangle.
Declaration
public static readonly Spot Top
Field Value
Type | Description |
---|---|
Spot |
TopBottomSides
The set of points at the top or bottom sides of the bounding rectangle.
Declaration
public static readonly Spot TopBottomSides
Field Value
Type | Description |
---|---|
Spot |
TopLeft
The specific point at the top-left corner of the bounding rectangle.
Declaration
public static readonly Spot TopLeft
Field Value
Type | Description |
---|---|
Spot |
TopLeftSides
The set of points at the top or left sides of the bounding rectangle.
Declaration
public static readonly Spot TopLeftSides
Field Value
Type | Description |
---|---|
Spot |
TopRight
The specific point at the top-right corner of the bounding rectangle.
Declaration
public static readonly Spot TopRight
Field Value
Type | Description |
---|---|
Spot |
TopRightSides
The set of points at the top or right sides of the bounding rectangle.
Declaration
public static readonly Spot TopRightSides
Field Value
Type | Description |
---|---|
Spot |
TopSide
The set of points at the top side of the bounding rectangle.
Declaration
public static readonly Spot TopSide
Field Value
Type | Description |
---|---|
Spot |
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.
Declaration
public double OffsetX { readonly get; set; }
Property Value
Type | Description |
---|---|
double |
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.
Declaration
public double OffsetY { readonly get; set; }
Property Value
Type | Description |
---|---|
double |
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.
Declaration
public double X { get; set; }
Property Value
Type | Description |
---|---|
double |
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.
Declaration
public double Y { get; set; }
Property Value
Type | Description |
---|---|
double |
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.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The Spot to compare to the current Spot. |
Returns
Type | Description |
---|---|
bool | True if the two spots are equal, false otherwise. |
Overrides
GetHashCode()
Creates a hash code for the spot.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current spot structure. |
Overrides
IncludesSide(Spot)
This predicate is true if this Spot is a side that includes the side(s) given by the argument Spot.
Declaration
public bool IncludesSide(Spot side)
Parameters
Type | Name | Description |
---|---|---|
Spot | side |
Returns
Type | Description |
---|---|
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.
Declaration
public bool IsDefault()
Returns
Type | Description |
---|---|
bool |
IsNone()
True if this is a special spot referring to no particular spot or side.
Declaration
public bool IsNone()
Returns
Type | Description |
---|---|
bool |
IsNoSpot()
True if this is an unspecific special spot, such as None or one of the sides.
Declaration
public bool IsNoSpot()
Returns
Type | Description |
---|---|
bool |
IsSide()
True if this is a special spot referring to one (or more) of the sides. This is false if the spot is None.
Declaration
public bool IsSide()
Returns
Type | Description |
---|---|
bool |
IsSpot()
True if this is a specific spot, not a side nor None.
Declaration
public bool IsSpot()
Returns
Type | Description |
---|---|
bool |
Opposite()
Return a new spot that is opposite this spot.
Declaration
public Spot Opposite()
Returns
Type | Description |
---|---|
Spot |
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.
Declaration
public static object Parse(object str)
Parameters
Type | Name | Description |
---|---|---|
object | str |
Returns
Type | Description |
---|---|
object |
Parse(string)
This static method can be used to read in a Spot from a string that was produced by Stringify(Spot).
Declaration
public static Spot Parse(string str)
Parameters
Type | Name | Description |
---|---|---|
string | str |
Returns
Type | Description |
---|---|
Spot |
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).
Declaration
public static string Stringify(Spot val)
Parameters
Type | Name | Description |
---|---|---|
Spot | val |
Returns
Type | Description |
---|---|
string |
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.
Declaration
public static object Stringify(object spot)
Parameters
Type | Name | Description |
---|---|---|
object | spot |
Returns
Type | Description |
---|---|
object |
ToString()
Returns a string representation of the spot.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string representation of the current spot. |
Overrides
Operators
operator ==(Spot, Spot)
Declaration
public static bool operator ==(Spot left, Spot right)
Parameters
Type | Name | Description |
---|---|---|
Spot | left | |
Spot | right |
Returns
Type | Description |
---|---|
bool |
operator !=(Spot, Spot)
Declaration
public static bool operator !=(Spot left, Spot right)
Parameters
Type | Name | Description |
---|---|---|
Spot | left | |
Spot | right |
Returns
Type | Description |
---|---|
bool |