Class GraphObject
This is the abstract base class for all graphical objects.
Classes inheriting from GraphObject include:
Shape, Text
Namespace: Northwoods.Go
Assembly: Northwoods.GoDiagram.WinForms.dll
Syntax
public abstract class GraphObject : IHasContextMenu, IHasToolTip
Remarks
It is very common to make use of the functions Add(params Graph
Since GraphObject is an abstract class, programmers do not create GraphObjects themselves, but this class defines many properties used by all kinds of GraphObjects.
The only visual property on GraphObject is Background.
However one can control whether the GraphObject is drawn at all by setting Visible,
or by setting Opacity to zero if you still want the GraphObject to occupy space.
Call the Is
For more information about specifying how things get drawn, see the properties on the
Shape, Text
GraphObject Sizing
GraphObject defines most of the properties that cause objects to size themselves differently. The most prominent ones include:
- The Desired
Size , MinSize , and MaxSize properties are used to explicitly set or limit the size of visual elements. Width and Height are convenience properties that set the DesiredSize width and height, respectively. - The Angle and Scale properties are used to transform visual elements.
- The Stretch property determines how a GraphObject will fill its visual space, contextually granted to it by its containing Panel. Top-level (Part) GraphObjects are not affected by this property because they are always granted infinite space.
All GraphObjects in a Diagram are measured and then arranged by their containing Panels in a tree-like fashion.
After measuring and arranging, a GraphObject will have valid values for the read-only
properties Natural
- The Natural
Bounds of a GraphObject describe its local size, without any transformations (Scale, Angle) affecting it. - The Measured
Bounds of a GraphObject describe its size within its containing Panel. - The Actual
Bounds of a GraphObject describe its position and given size inside of its panel. This size may be smaller than MeasuredBounds , for instance if a GraphObject with a large DesiredSize is placed in a Panel of a smaller DesiredSize . Smaller ActualBounds than MeasuredBounds typically means an object will be cropped.
See the Introduction page on sizing for usage information and examples.
GraphObject Size and Position within Panel
Several GraphObject properties guide the containing Panel for how to size and position the object within the panel.- The Alignment specifies where the object should be relative to some area of the panel.
For example, an alignment value of Bottom
Right means that the GraphObject should be at the bottom-right corner of the panel. - The Alignment
Focus specifies precisely which point of the GraphObject should be aligned at the Alignment spot. - The Column and Row properties are only used by Panel
Layout panels, to indicate where the GraphObject should be.Table - The Column
Span and RowSpan properties tell the PanelLayout panel how large the GraphObject should be.Table - The Is
Panel property indicates to some kinds of Panels that the GraphObject is the "primary" object that other panel children should be measured with or positioned in.Main - The Margin property tells the containing Panel how much extra space to put around this GraphObject.
- The Position property is used to determine the relative position of GraphObjects when they are elements of a Panel
Layout panel.Position
See the Introduction page on Panels and Table Panels for an overview of the capabilities.
Top-level GraphObjects are Parts
A Part is a derived class of GraphObject representing a top-level object. All top-level GraphObjects must be Parts, and Node, Link, Group, and Adornment derive from Part. The position of a Part determines the point of the Part's top-left corner in document coordinates. See also Location, which supports an way to specify the position based on a different spot of a different element within the Part.
There are several read-only properties that help navigate up the visual tree.
- Panel returns the Panel that directly contains this GraphObject
- Part returns the Part that this GraphObject is in, perhaps via intervening Panels; this is frequently used in order to get to the model data, Data
- Layer returns the Layer that this GraphObject's Part is in
- Diagram returns the Diagram that this GraphObject's Part's Layer is in
See the Visual Tree sample for a diagram displaying the visual tree of a simple diagram.
User Interaction
GraphObjects have several properties enabling dynamic customizable interaction.
There are several definable functions that execute on input events: Mouse
myDiagram.LinkTemplate =
new Link()
.Add(
new Shape {
StrokeWidth = 2, Stroke = "gray", // default color is "gray"
MouseEnter = (e, obj, prev) => { var shp = obj as Shape; shp.StrokeWidth = 4; shp.Stroke = "dodgerblue"; },
MouseLeave = (e, obj, prev) => { var shp = obj as Shape; shp.StrokeWidth = 2; shp.Stroke = "gray"; }
}
);
There are Click, Double
myDiagram.NodeTemplate =
new Node(PanelLayoutAuto.Instance) {
// second arg will be this GraphObject, which in this case is the Node itself:
Click = (e, obj) => {
var d = ((Node)obj).Data as MyNodeData;
Console.WriteLine("Node key is " + d.Key);
}
}.Add(
new Shape("RoundedRectangle")
.Bind("Fill", "Color"),
new TextBlock { Name = "TB", Margin = 3 }
.Bind("Text", "Key")
);
Note: you may prefer defining Diagram
The properties Action
See the Introduction page on Events for a more general discussion.
GraphObjects as Ports
Links can only connect to elements within a Node
that are specified as "ports", and by default the only port is the Node itself.
Setting the Port
GraphObjects have several properties that are only relevant when they are acting as ports. These port-related properties are:
- Port
Id , which must be set to a string that is unique within the Node, in order for this GraphObject to be treated as a "port", rather than the whole node - From
Spot and ToSpot , where a link should connect with this port - From
End and ToSegment Length End , the length of the link segment adjacent to this portSegment Length - From
Short and ToLength Short , the distance the link should terminate before touching this portLength - From
Linkable and ToLinkable , whether the user may draw links connecting with this port - From
Linkable and ToDuplicates Linkable , whether the user may draw multiple links between the same pair of portsDuplicates - From
Linkable and ToSelf Node Linkable , whether the user may draw a link between ports on the same nodeSelf Node - From
Max and ToLinks Max , to limit the double of links connecting with this port in a particular directionLinks
See the Introduction page on ports and link routing and link connection points for port usage information and examples.
GraphObjects as labels on a Link
GraphObjects can also be used as "labels" on a Link.
In addition to the Alignment
- Segment
Index , which segment the label should be on - Segment
Fraction , how far along the segment the label should be - Segment
Offset , where the label should be positioned relative to the segment - Segment
Orientation , how the label should be rotated relative to the angle of the segment
See the Introduction page on link labels for examples of how to make use of labels on Links.
Interactive Behavior
There are several properties that specify fairly high-level interactive behavior:
- Cursor, a CSS string specifying a cursor
- Context
Menu , an Adornment - Tool
Tip , an Adornment
For more information, please read the Introduction page about Context Menus and the page about ToolTips.
Also see the Basic sample for examples of how to show context menus and tooltips.
Constructors
GraphObject()
This is an abstract class, so you should not use this constructor.
Declaration
public GraphObject()
Properties
ActionCancel
Gets or sets the function to execute when the Action
Declaration
public Action<InputEvent, GraphObject> ActionCancel { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is infrequently set. By default this property is null.
This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events,
in conjunction with Action
The Action
See Also
ActionDown
Gets or sets the function to execute on a mouse-down event when this GraphObject's Is
Declaration
public Action<InputEvent, GraphObject> ActionDown { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is infrequently set. By default this property is null.
This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events,
in conjunction with Action
The Action
See Also
ActionMove
Gets or sets the function to execute on a mouse-move event when this GraphObject's Is
Declaration
public Action<InputEvent, GraphObject> ActionMove { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is infrequently set. By default this property is null.
This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events,
in conjunction with Action
The Action
See Also
ActionUp
Gets or sets the function to execute on a mouse-up event when this GraphObject's Is
Declaration
public Action<InputEvent, GraphObject> ActionUp { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is infrequently set. By default this property is null.
This functional property is only set on objects such as buttons, knobs, or sliders that want to handle all events,
in conjunction with Action
The Action
See Also
ActualBounds
This read-only property returns the bounds of this GraphObject in container coordinates. This means that the actualBounds are in the coordinate space of the GraphObject's Panel, unless this is a Part, in which case they are in the Diagram's coordinate system.
Declaration
public Rect ActualBounds { get; protected set; }
Property Value
Type | Description |
---|---|
Rect |
Remarks
You must not modify any of the properties of the Rect that is the value of this property.
If this GraphObject is a Part,
then the x and y values of the actualBounds are identical to that Part's Position,
and the width and height values of the actualBounds represent the rectangular space occupied
by the Part in Document
If this GraphObject is not a top-level object (not a Part), then the actualBounds
x and y values represent that GraphObject's position within its Panel. In a Panel of type Panel
It is possible for a GraphObject (be it an GraphObject or a Panel containing several more GraphObjects) to have no containing Part, in which case these GraphObjects cannot possibly be in a Diagram. These GraphObjects are unlikely to have real-double values for their actualBounds, as they may never have had the chance to be measured and arranged.
As with all read-only properties, using this property as a binding source is unlikely to be useful.
See Also
Alignment
Gets or sets the alignment Spot of this GraphObject used in Panel layouts, to determine where in the area allocated by the panel this object should be placed.
Declaration
public Spot Alignment { get; set; }
Property Value
Type | Description |
---|---|
Spot |
Remarks
The default value is Default, which lets the Panel determine the Spot using
Default
The Alignment
A Default is equivalent to Spot.Center in Spot, Auto, Horizontal, and Vertical panels. For examples of alignments in different panels, see the Introduction page on Panels.
See Also
AlignmentFocus
Gets or sets the spot on this GraphObject to be used as the alignment point in Spot and Fixed Panels.
Declaration
public Spot AlignmentFocus { get; set; }
Property Value
Type | Description |
---|---|
Spot |
Remarks
Value must be of type Spot.
The default value is Default, which means that the Panel type can decide the effective alignment spot.
The Alignment is often used along with this property to specify where this object should be positioned in a Panel.
For Panel
When you want a link label Node to be positioned by its location spot rather than by this alignmentFocus spot, you can set this property to None, only on Nodes.
For examples of alignments in different panels, see the Introduction page on Panels.
See Also
Angle
Gets or sets the angle transform, in degrees, of this GraphObject.
Declaration
public double Angle { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Value must be a double. If the value is not between (0 <= value < 360), it will be normalized to be in that range. Zero is along the positive X-axis (rightwards); 90 is along the positive Y-axis (downwards). Default is 0.
When set on a Graduated Panel's TextBlock label, this value will be be ignored if Segment
When set on a Link label, this value will be be ignored if Segment
See Also
Background
Gets or sets the background Brush of this GraphObject, filling the rectangle of this object's local coordinate space.
Declaration
public Brush Background { get; set; }
Property Value
Type | Description |
---|---|
Brush |
Remarks
If the object is rotated, the background will rotate with it.
The value may be either a Brush object or a string that is a CSS color. The default value is null -- no background is drawn. More information about the syntax of CSS color strings is available at: CSS colors (mozilla.Org).
See Also
Click
Gets or sets the function to execute when the user single-primary-clicks on this object. This typically involves a mouse-down followed by a prompt mouse-up at approximately the same position using the left (primary) mouse button.
Declaration
public Action<InputEvent, GraphObject> Click { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Click
If this property value is a function, it is called with an Input
From the second argument, obj, you can get to the Node or Link via the Part property.
From there you can access the bound data via the Data property.
So from an event handler you can get the bound data by obj.Part.Data
.
By default this property is null.
Objects in Layers that are Is
If you do provide a function that makes changes to the diagram or to its model,
you should do so within a transaction -- call Start
An example of a click event handler is shown in the Arrowheads sample.
See Also
Column
Gets or sets the column of this GraphObject if it is in a Table Panel.
Declaration
public int Column { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The value must be a small non-negative integer. The default is 0.
ColumnSpan
Gets or sets the double of columns spanned by this GraphObject if it is in a Table Panel.
Declaration
public int ColumnSpan { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The value must be a small positive integer. The default is 1.
ContextClick
Gets or sets the function to execute when the user single-secondary-clicks on this object. This typically involves a mouse-down followed by a prompt mouse-up at approximately the same position using the right (secondary) mouse button.
Declaration
public Action<InputEvent, GraphObject> ContextClick { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Click
If this property value is a function, it is called with an Input
From the second argument, obj, you can get to the Node or Link via the Part property.
From there you can access the bound data via the Data property.
So from an event handler you can get the bound data by obj.Part.Data
.
By default this property is null.
Objects in Layers that are Is
If you do provide a function that makes changes to the diagram or to its model,
you should do so within a transaction -- call Start
See Also
ContextMenu
This context menu is shown upon a context click on this object.
This value is typically an Adornment, which implements IShow
Declaration
public IShowHidable ContextMenu { get; set; }
Property Value
Type | Description |
---|---|
IShow |
Remarks
The default value is null, which means no context menu is shown.
Changing this value will not modify or remove any existing menu that is being shown for this object.
Context menus may also depend on having the same data binding as the adorned Part (i.e. the same value for Data).
Context menus are not copied by Copy(), so that context menus may be shared by all instances of a template.
A typical context menu is implemented as an Adornment with several buttons in it. For example, this context menu is defined in the Dynamic Port sample:
var nodeMenu = // context menu for each Node
Builder.Make<Adornment>("ContextMenu")
.Add(
Builder.Make<Panel>("ContextMenuButton")
.Add(new TextBlock("Add top port"))
.Set(new { Click = new Action<InputEvent, GraphObject>((e, obj) => { AddPort("top"); }) }),
Builder.Make<Panel>("ContextMenuButton")
.Add(new TextBlock("Add left port"))
.Set(new { Click = new Action<InputEvent, GraphObject>((e, obj) => { AddPort("left"); }) }),
Builder.Make<Panel>("ContextMenuButton")
.Add(new TextBlock("Add right port"))
.Set(new { Click = new Action<InputEvent, GraphObject>((e, obj) => { AddPort("right"); }) }),
Builder.Make<Panel>("ContextMenuButton")
.Add(new TextBlock("Add bottom port"))
.Set(new { Click = new Action<InputEvent, GraphObject>((e, obj) => { AddPort("bottom"); }) })
);
and is used in the node template:
myDiagram.NodeTemplate =
new Node(PanelLayoutTable.Instance) { ..., ContextMenu = nodeMenu } ...;
Context menus are normally positioned by Position
The Basic sample also shows how to make context menu items invisible when the command is disabled.
Replacing this value will not modify or remove any existing context menu that is being shown for this object.
Read more about context menus at Context Menus.
Cursor
Gets or sets the mouse cursor to use when the mouse is over this object with no mouse buttons pressed.
Declaration
public string Cursor { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
The value is null when no particular cursor is specified for this object; the actual cursor is determined by any containing Panel.
The default value is the empty string, which means the current mouse cursor is determined by the Diagram. Other strings should be valid CSS strings that specify a cursor. This provides some more information about cursor syntax: CSS cursors (mozilla.Org).
See Also
CustomProperties
This write-only property allows for setting multiple programmer-defined properties.
Declaration
public object CustomProperties { set; }
Property Value
Type | Description |
---|---|
object |
Remarks
The object should be an anonymous type object containing property names, beginning with "_", and their corresponding values.
// standalone set
myNode.CustomProperties = new {
_ExtraString = "hello",
_ExtraPoint = new Point(5, 5)
};
// more common, within a call to GraphObject.Set
myNode.Set(new Node {
LocationSpot = Spot.Center,
FromSpot = Spot.BottomRightSides,
ToSpot = Spot.TopLeftSides,
CustomProperties = new {
_ExtraString = "hello",
_ExtraPoint = new Point(5, 5)
}
});
DesiredSize
Gets or sets the desired size of this GraphObject in local coordinates.
Declaration
public Size DesiredSize { get; set; }
Property Value
Type | Description |
---|---|
Size |
Remarks
Value must be of type Size. Default is Size(double.NaN, double.NaN). You cannot modify the width or height of the value of this property -- if you want to change the desiredSize you must set this property to a different Size.
Getting or setting Width or Height is equivalent to getting or setting the width or height of this property.
The size does not include any transformation due to Scale or Angle,
nor any pen thickness due to Stroke
See Also
Diagram
This read-only property returns the Diagram that this GraphObject is in, if it is.
Declaration
public virtual Diagram Diagram { get; }
Property Value
Type | Description |
---|---|
Diagram |
Remarks
This property is not settable. Although you cannot add any plain GraphObject to a Diagram, you can call Add(Part) to add a Part to a Diagram.
DoubleClick
Gets or sets the function to execute when the user double-primary-clicks on this object. This typically involves a mouse-down/up/down/up in rapid succession at approximately the same position using the left (primary) mouse button.
Declaration
public Action<InputEvent, GraphObject> DoubleClick { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Click
If this property value is a function, it is called with an Input
From the second argument, obj, you can get to the Node or Link via the Part property.
From there you can access the bound data via the Data property.
So from an event handler you can get the bound data by obj.Part.Data
.
By default this property is null.
Objects in Layers that are Is
If you do provide a function that makes changes to the diagram or to its model,
you should do so within a transaction -- call Start
myDiagram.NodeTemplate =
new Node(...) {
...,
// second arg will be this GraphObject, which in this case is the Node itself:
DoubleClick = (e, obj) => {
var d = ((Node)obj).Data as MyNodeData;
Console.WriteLine("Node key is " + d.Key);
}
} ... ;
See Also
EnabledChanged
Gets or sets the function to execute when some containing Panel changes the value of Is
Declaration
public Action<GraphObject, bool> EnabledChanged { get; set; }
Property Value
Type | Description |
---|---|
Action<Graph |
Remarks
It is typically used to modify the appearance of the object.
This function must not change the value of any panel Is
If this property value is a function, it is called with two arguments,
this Graph
See Also
FromEndSegmentLength
Gets or sets the length of the first segment of a link coming from this port.
Declaration
public virtual double FromEndSegmentLength { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
This value is used when the computed "from spot" is not None.
The default value is 10.
This value also limits how short the From
The value of From
For examples of how to use this property, see Link End Segment Lengths.
You must set this property on a GraphObject whose Port
See Also
FromLinkable
Gets or sets whether the user may draw Links from this port.
Declaration
public bool? FromLinkable { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Remarks
This property is used by Is
The default value is null, which indicates that the real value is inherited from the parent Panel, or false if there is no containing panel.
You must set this property on a GraphObject whose Port
See Also
FromLinkableDuplicates
Gets or sets whether the user may draw duplicate Links from this port.
Declaration
public bool FromLinkableDuplicates { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This property is used by Is
The default value is false.
You must set this property on a GraphObject whose Port
See Also
FromLinkableSelfNode
Gets or sets whether the user may draw Links that connect from this port's Node.
Declaration
public bool FromLinkableSelfNode { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This property is used by Is
The default value is false.
You must set this property on a GraphObject whose Port
See Also
FromMaxLinks
Gets or sets the maximum double of links that may come out of this port.
Declaration
public double FromMaxLinks { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
This property is used by Is
The value must be non-negative. The default value is Infinity.
You must set this property on a GraphObject whose Port
See Also
FromShortLength
Gets or sets how far the end segment of a link coming from this port stops short of the actual port.
Declaration
public virtual double FromShortLength { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Positive values are limited by the From
This property is useful when you have a thick link and a pointy arrowhead. Normally the link Shape extends all the way to the end of the arrowhead. If the link Shape is wide, its edges will be seen behind the arrowhead. By setting this property to a small positive value, the link Shape can end within the body of the arrowhead, leaving only the point of the arrowhead visible at the end of the link.
A negative value for this property can also be useful when you want the link Shape to continue into the port, perhaps because a portion of the port is transparent and you want the link to appear to connect visually with a different point on the node.
The value of From
For examples of how to use this property, see Link Connection Points.
You must set this property on a GraphObject whose Port
See Also
FromSpot
Gets or sets where a link should connect from this port.
Declaration
public Spot FromSpot { get; set; }
Property Value
Type | Description |
---|---|
Spot |
Remarks
The default value is None, meaning that the link routing must consider the shape of the port and connect at the closest point.
The value of From
For examples of how to use this property, see Link Connection Points.
You must set this property on a GraphObject whose Port
See Also
Height
Gets or sets the desired height of this GraphObject in local coordinates.
This just gets or sets the height component of the Desired
Declaration
public double Height { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Default is double.NaN.
Size can also be constrained by setting Min
The height does not include any transformation due to Scale or Angle,
nor any pen thickness due to Stroke
IsActionable
This property determines whether or not this GraphObject's events occur
before all other events, including selection. This enables the Action
Declaration
public bool IsActionable { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This object does not get any mouse/touch events if it is not Visible or if it is not Pickable.
This property is infrequently used -- typically only when implementing objects that act as buttons or knobs or sliders. The default value is false.
See Also
IsPanelMain
Gets or sets whether a GraphObject is the "main" object for some types of Panel.
Declaration
public bool IsPanelMain { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Panels that use a "main" object include Panel
Panels that use a "main" object will use the first object that has this property set to true, or else just the first object, if none have the property set.
Do not modify this property once this object is an element of a panel.
this[string]
This index operator allows for access to programmer-defined properties stored in a Dictionary<string, object>.
Declaration
public object this[string prop] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
string | prop | the property name, which must begin with a _ |
Property Value
Type | Description |
---|---|
object |
Layer
This read-only property returns the GraphObject's containing Layer, if there is any. A plain GraphObject cannot belong directly to a Layer -- only a Part can belong directly to a Layer.
Declaration
public virtual Layer Layer { get; }
Property Value
Type | Description |
---|---|
Layer |
Remarks
This property is not settable.
Normally one changes which Layer that a GraphObject is in by setting Layer
Margin
Gets or sets the size of empty area around this GraphObject, as a Margin, in the containing Panel coordinates.
Declaration
public Margin Margin { get; set; }
Property Value
Type | Description |
---|---|
Margin |
Remarks
Negative values are permitted but may cause overlaps with adjacent objects in a Panel. You cannot modify the top or left or right or bottom of the value of this property -- if you want to change the margin you must set this property to a different Margin. Default margin is Margin(0,0,0,0).
The property setter accepts a double instead of a Margin object: providing a double N will result in using a Margin(N, N, N, N). The property getter will always return a Margin.
See Also
MaxSize
Gets or sets the maximum size of this GraphObject in container coordinates (either a Panel or the document).
Declaration
public Size MaxSize { get; set; }
Property Value
Type | Description |
---|---|
Size |
Remarks
Any new value must be of type Size; double.NaN values are treated as Infinity. If you want no maximum width or height, use double.NaN or Infinity.
You cannot modify the width or height of the value of this property -- if you want to change the maxSize you must set this property to a different Size. The default value is Infinity by Infinity. A containing Panel will determine the actual size of this object.
See Also
MeasuredBounds
This read-only property returns the measuredBounds of the GraphObject in container coordinates (either a Panel or the document). This describes the transformed bounds with margins excluded.
Declaration
public Rect MeasuredBounds { get; }
Property Value
Type | Description |
---|---|
Rect |
Remarks
You must not modify any of the properties of the Rect that is the value of this property.
As with all read-only properties, using this property as a binding source is unlikely to be useful.
See Also
MinSize
Gets or sets the minimum size of this GraphObject in container coordinates (either a Panel or the document).
Declaration
public Size MinSize { get; set; }
Property Value
Type | Description |
---|---|
Size |
Remarks
Any new value must be of type Size; double.NaN values are treated as 0.
You cannot modify the width or height of the value of this property -- if you want to change the minSize you must set this property to a different Size. The default value is zero by zero. A containing Panel will determine the actual size of this object.
See Also
MouseDragEnter
Gets or sets the function to execute when the user moves the mouse
into this stationary object during a Dragging
Declaration
public Action<InputEvent, GraphObject, GraphObject> MouseDragEnter { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
If this property value is a function, it is called with an Input
Note that for a drag-and-drop that originates in a different diagram, the target diagram's
selection collection will not be the parts that are being dragged.
Instead the temporary parts being dragged can be found as the source diagram's Copied
This function is called with Skips
For an example of a mouseDragEnter event handler, see the node template in the Org Chart Editor sample.
See Also
MouseDragLeave
Gets or sets the function to execute when the user moves the mouse
out of this stationary object during a Dragging
Declaration
public Action<InputEvent, GraphObject, GraphObject> MouseDragLeave { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
If this property value is a function, it is called with an Input
Note that for a drag-and-drop that originates in a different diagram, the target diagram's
selection collection will not be the parts that are being dragged.
Instead the temporary parts being dragged can be found as the source diagram's Copied
This function is called with Skips
For an example of a mouseDragLeave event handler, see the node template in the Org Chart Editor sample.
See Also
MouseDrop
Gets or sets the function to execute when a user drops the selection on this object
at the end of a Dragging
Declaration
public Action<InputEvent, GraphObject> MouseDrop { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
If this property value is a function, it is called with an Input
For an example of a mouseDrop event handler, see the node template in the Org Chart Editor sample.
See Also
MouseEnter
Gets or sets the function to execute when the user moves the mouse into this object without holding down any buttons.
Declaration
public Action<InputEvent, GraphObject, GraphObject> MouseEnter { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Tool
If this property value is a function, it is called with an Input
This function is called with Skips
For example, consider the situation where one wants to display buttons that the user can click whenever the user passes the mouse over a node, and the buttons automatically disappear when the mouse leaves the node. This can be implemented by showing an Adornment holding the buttons.
var nodeContextMenu =
new Adornment("Spot")
{ Background = "transparent" }
.Add(
new Placeholder(),
new Panel("Vertical")
{ Alignment = Spot.Right, AlignmentFocus = Spot.Left }
.Add(
Builder.Make<Panel>("Button")
.Add(new TextBlock("Command 1"))
.Set(new {
Click = new Action<InputEvent, GraphObject>((e, obj) => {
var node = ((Adornment)obj.Part).AdornedPart;
Console.WriteLine("Command 1 on " + ((MyNodeData)node.Data).Text);
node.RemoveAdornment("ContextMenuOver");
})
}),
Builder.Make<Panel>("Button")
.Add(new TextBlock("Command 2"))
.Set(new {
Click = new Action<InputEvent, GraphObject>((e, obj) => {
var node = ((Adornment)obj.Part).AdornedPart;
Console.WriteLine("Command 2 on " + ((MyNodeData)node.Data).Text);
node.RemoveAdornment("ContextMenuOver");
})
})
)
);
Then in the definition of the Node we can implement a MouseEnter event handler:
myDiagram.NodeTemplate =
new Node {
...,
MouseEnter = (e, obj, _) => {
var node = (Node)obj;
nodeContextMenu.AdornedElement = node;
nodeContextMenu.MouseLeave = (ev, cm, _) => {
node.RemoveAdornment("ContextMenuOver");
};
node.AddAdornment("ContextMenuOver", nodeContextMenu);
}
} ...;
Note how it automatically defines a Mouse
See Also
MouseHold
Gets or sets the function to execute when the user holds the mouse still for a while over this object while holding down a button.
Declaration
public Action<InputEvent, GraphObject> MouseHold { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Tool
If this property value is a function, it is called with an Input
If you do provide a function that makes changes to the diagram or to its model,
you should do so within a transaction -- call Start
You can control how long the user must wait during a drag with a motionless mouse before
a "mouse hold" event occurs, by setting Hold
myDiagram.ToolManager.HoldDelay = 500; // 500 milliseconds
See Also
MouseHover
Gets or sets the function to execute when the user holds the mouse still for a while over this object without holding down any buttons.
Declaration
public Action<InputEvent, GraphObject> MouseHover { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Tool
If this property value is a function, it is called with an Input
If you do provide a function that makes changes to the diagram or to its model,
you should do so within a transaction -- call Start
You can control how long the user must wait with a motionless mouse before
a "mouse hover" event occurs, by setting Hover
myDiagram.ToolManager.HoverDelay = 500; // 500 milliseconds
See Also
MouseLeave
Gets or sets the function to execute when the user moves the mouse out of this object without holding down any buttons.
Declaration
public Action<InputEvent, GraphObject, GraphObject> MouseLeave { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Tool
If this property value is a function, it is called with an Input
This function is called with Skips
For example, the Flow Chart sample automatically shows and hides the ports as the mouse passes over a node. The node template includes the following settings:
myDiagram.NodeTemplate =
new Node {
...,
// handle mouse enter/leave events to show/hide the ports
MouseEnter = (e, obj, _) => { showPorts(obj.Part, true); },
MouseLeave = (e, obj, _) => { showPorts(obj.Part, false); }
} ...;
where the showPorts
function is defined to set the Visible
property of each of the port elements of the node.
See Also
MouseOver
Gets or sets the function to execute when the user moves the mouse over this object without holding down any buttons.
Declaration
public Action<InputEvent, GraphObject> MouseOver { get; set; }
Property Value
Type | Description |
---|---|
Action<Input |
Remarks
This property is used by the Tool
If this property value is a function, it is called with an Input
This function is called with Skips
See Also
Name
Gets or sets the name for this object.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
The default value is the empty string.
The name should be unique within a Panel, although if it isn't,
it reduces the usefulness of methods such as Find
You must not modify the name of a GraphObject once it is in the visual tree of a Part.
This is frequently needed to identify a particular GraphObject in the visual tree of a Part,
for example as the value of the Location
NaturalBounds
This read-only property returns the natural bounding rectangle of this GraphObject in local coordinates,
before any transformation by Scale or Angle,
and before any resizing due to Min
Declaration
public virtual Rect NaturalBounds { get; }
Property Value
Type | Description |
---|---|
Rect |
Remarks
Defaults to unknown (double.NaN,double.NaN).
You must not modify any of the properties of the Rect that is the value of this property.
The value can only be changed by changing properties of the particular GraphObject,
such as Desired
As with all read-only properties, using this property as a binding source is unlikely to be useful.
See Also
Opacity
Gets or sets the multiplicative opacity for this GraphObject and (if a Panel) all elements.
Declaration
public double Opacity { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
The value must be between 0.0 (fully transparent) and 1.0 (no additional transparency).
Unlike Visible, Opacity only affects drawing, it does not cause objects to be resized or remeasured. Opacity settings do not change the shape of the object or exclude it from object-picking (does not change whether any objects are found by the "find..." methods).
This value is multiplicative with any existing transparency, for instance from Opacity or a GraphObject's opacity higher in the visual tree, or from a Brush or image transparency. The default value is 1.
See Also
Panel
This read-only property returns the GraphObject's containing Panel, or null if this object is not in a Panel.
Declaration
public Panel Panel { get; }
Property Value
Type | Description |
---|---|
Panel |
Remarks
Although Part inherits from this class, a Part will never belong to a Panel, so this property will always be null for every Node or Link.
This property is not settable.
Instead, call Add(params Graph
Part
This read-only property returns the Part containing this object, if any. The Part will be the root GraphObject in this GraphObject's visual tree.
Declaration
public Part Part { get; }
Property Value
Type | Description |
---|---|
Part |
Remarks
It is common to refer to the containing Part of a GraphObject in order to refer to the Data to which it is bound.
This property is not settable.
If you want this GraphObject to belong to a Part, you will need to add it to a Part,
or else add it to some visual tree structure that is added to a Part using Add(params Graph
Note that for objects such as buttons that are in Adornments such as tooltips or context menus, this property will return that Adornment, not the Node or Link that is adorned.
If you want to find a Group that contains a Part, use the ContainingsomeObj.Part.ContainingGroup
Pickable
Gets or sets whether or not this GraphObject can be chosen by visual "find" or "hit-test" methods such as FindElementAt(Point, Func<GraphObject, GraphObject>, Predicate<GraphObject>).
Declaration
public bool Pickable { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This object does not get any mouse/touch events if it is not Visible or if it is not Pickable.
The default value is true -- mouse events on this object will be noticed. If this value is false and this object is a Panel, not only is this Panel not "hittable", but all of the elements inside the Panel will be ignored.
See Also
PortId
Gets or sets an identifier for an object acting as a port on a Node.
Declaration
public string PortId { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
The default value is null -- this object is not a port.
A value that is the empty string is used by convention to mean the primary (and usually only) port of the node.
If a Node has no named ports, then the Node itself is the sole port.
Note: the only kind of model that can save port information, i.e. portIds that are not an empty string,
for links is a GraphLinksModel<TNodeData, TNodeKey, TSharedData, TLinkData, TLinkKey, TPort> whose Link
The value should be unique within the Node. You must not modify this property once this GraphObject is in the visual tree of a Node.
See the Introduction page on ports for usage information and examples.
See Also
Position
Gets or sets the position of this GraphObject in container coordinates (either a Panel or the document).
Declaration
public Point Position { get; set; }
Property Value
Type | Description |
---|---|
Point |
Remarks
Value must be of type Point.
You cannot modify the x or y of the value of this property --
if you want to change the position you must set this property to a different Point.
Default is Point(double.NaN, double.NaN)
.
Row
Gets or sets the row of this GraphObject if it is in a Table Panel.
Declaration
public int Row { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The value must be a small non-negative integer. The default is 0.
RowSpan
Gets or sets the double of rows spanned by this GraphObject if it is in a Table Panel.
Declaration
public int RowSpan { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The value must be a small positive integer. The default is 1.
Scale
Gets or sets the scale transform of this GraphObject.
Declaration
public double Scale { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Value must be a double; larger values will make this object appear bigger. Default is 1.
See Also
SegmentFraction
Gets or sets the fractional distance along a segment of a GraphObject that is in a Link.
Declaration
public double SegmentFraction { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
The value should be between zero and one, where zero is at the point at the start of the segment, and where one is at the point at the end of the segment. The default value is zero.
If Segment
For examples of how to use this property, see Link Labels.
See Also
SegmentIndex
Gets or sets the segment index of a GraphObject that is in a Link.
Declaration
public double SegmentIndex { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Non-negative numbers count up from zero, which is the first segment, at the "from" end of the Link. Negative numbers count segments from the "to" end of the Link, where -1 means the last segment and -2 means the next-to-last segment. The default value is double.NegativeInfinity. The value should be an integer or double.NaN.
Setting this value to double.NaN means Segment
If you do not set this property, the Link will choose a place that is approximately at the mid-point of the link's route.
For examples of how to use this property, see Link Labels.
See Also
SegmentOffset
Gets or sets the offset of a GraphObject that is in a Link from a point on a segment
or in a Panel
Declaration
public Point SegmentOffset { get; set; }
Property Value
Type | Description |
---|---|
Point |
Remarks
The X component of the Point indicates the distance along the route, with positive values going further toward the "to" end of the link or panel. The Y component of the Point indicates the distance away from the route, with positive values towards the right as seen when facing further towards the "to" end of the link or panel. The value defaults to the Point (0, 0). You cannot modify the x or y of the value of this property -- if you want to change the SegmentOffset you must set this property to a different Point.
For labels that are near either end of a link, it may be convenient to set the segmentOffset to Point(double.NaN, double.NaN). This causes the offset to be half the width and half the height of the label object.
For examples of how to use this property, see Link Labels.
See Also
SegmentOrientation
Gets or sets the orientation of a GraphObject that is in a Link or Panel
Declaration
public Orientation SegmentOrientation { get; set; }
Property Value
Type | Description |
---|---|
Orientation |
Remarks
The only accepted values are the Link "Orient..." values of Link and the default value: None.
When the value is None, the Angle of this object is unchanged as the link is routed. Setting this to a value of Along will cause routing to set the Angle to be the angle of the segment that this object is on. Other values compute the angle somewhat differently. If the value is changed back to None, the Angle of this object is set to zero.
Note that when this property is not None, this property takes precedence over any setting or binding of the Angle property. Changes to the angle caused by orientation might not result in Changed events, and any original value for the angle may be lost.
In the case of Graduated Panels, if this value is None, Along, or Upright, any TextBlock label Angle will be respected. Depending on this value, the effective TextBlock angle will be either fixed or relative to the slope of the path where it is rendered.
For examples of how to use this property, see Link Labels.
See Also
ShadowVisible
Gets or sets whether or not this GraphObject will be shadowed inside a Part that has Is
Declaration
public bool? ShadowVisible { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Remarks
The default is null, which means this GraphObject will obey the default shadow rules (see Is
A value of true or false will ensure that this part is shadowed or not regardless of the default shadow rules, but this GraphObject's shadowed status will not affect other GraphObjects in the Part.
Typically this property does not need to be set, but you may need to set this value to false on GraphObjects inside a Part that you do not wish to be shadowed.
See Also
Stretch
Gets or sets the stretch of the GraphObject. This controls whether the width and/or height of this object automatically adjusts to fill the area allotted by the containing Panel.
Declaration
public Stretch Stretch { get; set; }
Property Value
Type | Description |
---|---|
Stretch |
Remarks
The only accepted values are listed as constant properties of GraphObject, such as None, Fill, Horizontal, or Vertical. The default value is Default, which allows the Panel to decide how to treat this object, depending on the type of Panel.
Objects with an Angle that are stretched may look incorrect unless the angle is a multiple of 90.
Stretch will have have different effects based upon the Panel containing this object. Elements of:
- Auto panels will not stretch, except the main element growing to fill the panel or being made uniform
- Horizontal panels will only stretch vertically
- Vertical panels will only stretch horizontally
- Spot panels will stretch to the size of the main element
- Table panels will stretch to the size of their cell, defined by their row and column, which is usually determined by other GraphObjects in that cell that are not stretching
- Grid panels, Link panels, and Graduated panels will not stretch
See Also
ToEndSegmentLength
Gets or sets the length of the last segment of a link going to this port.
Declaration
public virtual double ToEndSegmentLength { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
This value is used when the computed "to spot" is not None. The default value is 10.
The value of To
For examples of how to use this property, see Link End Segment Lengths.
You must set this property on a GraphObject whose Port
See Also
ToLinkable
Gets or sets whether the user may draw Links to this port.
Declaration
public bool? ToLinkable { get; set; }
Property Value
Type | Description |
---|---|
bool? |
Remarks
This property is used by Is
The default value is null, which indicates that the real value is inherited from the parent Panel, or false if there is no containing panel.
You must set this property on a GraphObject whose Port
See Also
ToLinkableDuplicates
Gets or sets whether the user may draw duplicate Links to this port.
Declaration
public bool ToLinkableDuplicates { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This property is used by Is
The default value is false.
You must set this property on a GraphObject whose Port
See Also
ToLinkableSelfNode
Gets or sets whether the user may draw Links that connect to this port's Node.
Declaration
public bool ToLinkableSelfNode { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This property is used by Is
The default value is false.
You must set this property on a GraphObject whose Port
See Also
ToMaxLinks
Gets or sets the maximum number of links that may go into this port.
Declaration
public double ToMaxLinks { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
This property is used by Is
The value must be non-negative. The default value is Infinity.
You must set this property on a GraphObject whose Port
See Also
ToolTip
This tooltip is shown when the mouse hovers over this object.
This value is typically an Adornment, which implements IShow
Declaration
public IShowHidable ToolTip { get; set; }
Property Value
Type | Description |
---|---|
IShow |
Remarks
The default value is null, which means no tooltip is shown.
A typical tooltip is defined in the following manner, as taken from the Kitten Monitor sample:
myDiagram.NodeTemplate =
new Node {
...,
// this tooltip shows the name and picture of the kitten
ToolTip =
Builder.Make<Adornment>("ToolTip")
.Add(
new Panel(PanelLayoutVertical.Instance)
.Add(
new Picture()
.Bind("Source", "Src", (s, _) => { return "images/" + s + ".png"; }),
new TextBlock { Margin = 3 }
.Bind("Text", "Key")
)
)
} ...;
Note that this Adornment depends on having the same data binding as the adorned Part (i.e. the same value for Data).
Tooltips are not copied by Copy(), so that tooltips may be shared by all instances of a template.
Tooltips are shown after a timed delay given by the Hover
myDiagram.ToolManager.HoverDelay = 500; // 500 milliseconds
Tooltips are normally positioned by Position
Replacing this value will not modify or remove any existing tooltip that is being shown for this object.
Read more about tooltips at ToolTips.
ToShortLength
Gets or sets how far the end segment of a link going to this port stops short of the actual port.
Declaration
public virtual double ToShortLength { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Positive values are limited by the To
This property is useful when you have a thick link and a pointy arrowhead. Normally the link Shape extends all the way to the end of the arrowhead. If the link Shape is wide, its edges will be seen behind the arrowhead. By setting this property to a small positive value, the link Shape can end within the body of the arrowhead, leaving only the point of the arrowhead visible at the end of the link.
A negative value for this property can also be useful when you want the link Shape to continue into the port, perhaps because a portion of the port is transparent and you want the link to appear to connect visually with a different point on the node.
The value of To
For examples of how to use this property, see Link Connection Points.
You must set this property on a GraphObject whose Port
See Also
ToSpot
Gets or sets where a link should connect to this port.
Declaration
public virtual Spot ToSpot { get; set; }
Property Value
Type | Description |
---|---|
Spot |
Remarks
The default value is None, meaning that the link routing must consider the shape of the port and connect to the closest point.
The value of To
For examples of how to use this property, see Link Connection Points.
You must set this property on a GraphObject whose Port
See Also
Visible
Gets or sets whether a GraphObject is visible.
Declaration
public bool Visible { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The default value is true. A not visible object takes no space in the Panel that it is in. Toggling visibility may cause elements in the visual tree to re-measure and re-arrange. Making a Panel not visible causes all of its elements not to be seen or receive input events. Changing a Panel to become visible causes all of its elements to be seen and be active, unless those elements are themselves not visible.
This object does not get any mouse/touch events if it is not Visible or if it is not Pickable.
One can have a visible Shape that is not drawn by setting its Fill
and Stroke to null or to "transparent"
.
Similarly, one can set Stroke to null or to "transparent"
.
It is also possible make a GraphObjects transparent by setting Opacity to 0.
Finally, one can make a whole Layer-full of Parts invisible by setting Visible to false.
Use the Is
For Parts, you can call the Is
See Also
Width
Gets or sets the desired width of this GraphObject in local coordinates.
This just gets or sets the width component of the Desired
Declaration
public double Width { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Default is double.NaN.
Size can also be constrained by setting Min
The width does not include any transformation due to Scale or Angle,
nor any pen thickness due to Stroke
Methods
Apply(Action<GraphObject>)
This method takes a function that can be used to apply multiple settings, bindings,
or Add(params Graph
Declaration
public GraphObject Apply(Action<GraphObject> func)
Parameters
Type | Name | Description |
---|---|---|
Action<Graph |
func | the function to apply to this GraphObject |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
If you are just adding settings, bindings, or GraphObjects to a single GraphObject,
you do not need to use this, you can just chain calls to Set(object), Bind(params Binding[]),
and Add(params Graph
// define some common property settings
void nodeStyle(Node node) {
node
.Bind("Location", "Loc", Point.Parse, Point.Stringify))
.Set(new { SelectionAdorned = false, Resizable = true });
}
var template1 =
new Node() { ... }
.Apply(nodeStyle);
var template2 =
new Node() { ... }
.Apply(nodeStyle);
Bind(params Binding[])
Add a number of data-bindings to this GraphObject.
Declaration
public GraphObject Bind(params Binding[] bindings)
Parameters
Type | Name | Description |
---|---|---|
Binding[] | bindings | the Bindings |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
Bind(IEnumerable<Binding>)
Add a number of data-bindings to this GraphObject.
Declaration
public GraphObject Bind(IEnumerable<Binding> bindings)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Binding> | bindings | a collection of Bindings |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
Bind(string, SimpleConversion, BackConversion)
Add a data-binding to this GraphObject for the given property name and optional conversion functions.
Declaration
public GraphObject Bind(string prop, SimpleConversion conv, BackConversion backconv = null)
Parameters
Type | Name | Description |
---|---|---|
string | prop | A string naming the source and target property on the target object. This should not be the empty-string. |
Simple |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Back |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
Bind(string, SimpleConversion, SimpleConversion)
Add a data-binding to this GraphObject for the given property name and optional conversion functions.
Declaration
public GraphObject Bind(string prop, SimpleConversion conv, SimpleConversion backconv)
Parameters
Type | Name | Description |
---|---|---|
string | prop | A string naming the source and target property on the target object. This should not be the empty-string. |
Simple |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Simple |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
Bind(string, TargetConversion, BackConversion)
Add a data-binding to this GraphObject for the given property name and optional conversion functions.
Declaration
public GraphObject Bind(string prop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
Type | Name | Description |
---|---|---|
string | prop | A string naming the source and target property on the target object. This should not be the empty-string. |
Target |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Back |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
Bind(string, TargetConversion, SimpleConversion)
Add a data-binding to this GraphObject for the given property name and optional conversion functions.
Declaration
public GraphObject Bind(string prop, TargetConversion conv, SimpleConversion backconv)
Parameters
Type | Name | Description |
---|---|---|
string | prop | A string naming the source and target property on the target object. This should not be the empty-string. |
Target |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Simple |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
Bind(string, string, SimpleConversion, BackConversion)
Add a data-binding to this GraphObject for the given property names and conversion functions.
Declaration
public GraphObject Bind(string targetprop, string sourceprop, SimpleConversion conv, BackConversion backconv = null)
Parameters
Type | Name | Description |
---|---|---|
string | targetprop | A string naming the target property on the target object. This should not be the empty-string. |
string | sourceprop | A string name the source property on the bound data object If this is the empty string, the whole Data object is used. |
Simple |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Back |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
Bind(string, string, SimpleConversion, SimpleConversion)
Add a data-binding to this GraphObject for the given property names and conversion functions.
Declaration
public GraphObject Bind(string targetprop, string sourceprop, SimpleConversion conv, SimpleConversion backconv)
Parameters
Type | Name | Description |
---|---|---|
string | targetprop | A string naming the target property on the target object. This should not be the empty-string. |
string | sourceprop | A string name the source property on the bound data object If this is the empty string, the whole Data object is used. |
Simple |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Simple |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
Bind(string, string, TargetConversion, BackConversion)
Add a data-binding to this GraphObject for the given property names and conversion functions.
Declaration
public GraphObject Bind(string targetprop, string sourceprop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
Type | Name | Description |
---|---|---|
string | targetprop | A string naming the target property on the target object. This should not be the empty-string. |
string | sourceprop | A string name the source property on the bound data object If this is the empty string, the whole Data object is used. |
Target |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Back |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
Bind(string, string, TargetConversion, SimpleConversion)
Add a data-binding to this GraphObject for the given property names and conversion functions.
Declaration
public GraphObject Bind(string targetprop, string sourceprop, TargetConversion conv, SimpleConversion backconv)
Parameters
Type | Name | Description |
---|---|---|
string | targetprop | A string naming the target property on the target object. This should not be the empty-string. |
string | sourceprop | A string name the source property on the bound data object If this is the empty string, the whole Data object is used. |
Target |
conv | An optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place. |
Simple |
backconv | An optional conversion function to convert property values back to data values.
Specifying this modifies the binding to set its Mode to be Two |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Do not add, modify, or remove object Bindings after this object has been copied.
Read more about Bindings at the Introduction page about Data Bindings.
If you need to call Ofnew Binding()
to Northwoods.Go.GraphObject.Bind<T>(params Northwoods.Go.Models.Binding[]).
CloneProtected(GraphObject)
Copies properties from this object to the given object, which must be of the same class. This is called by Copy(). This method may be overridden.
Declaration
protected virtual void CloneProtected(GraphObject copy)
Parameters
Type | Name | Description |
---|---|---|
Graph |
copy |
Remarks
For every property that you add to a subclass of a GraphObject-inheriting class, in this method you should consider assigning its value to the copied object. By default, the base method will call MemberwiseClone(), so reference properties will be shallow copies by default.
For example, let us define a custom Link class and add two properties:
public class CustomLink : Link {
public int SomeNewProperty { get; set; } = 17;
public List<double> SomeNewProperty2 { get; set; } = new List<double>();
protected override void CloneProtected(GraphObject c) {
// always call the base method in an override
base.CloneProtected(c);
var copy = (CustomLink)c;
// assign the reference property of the new copy:
copy.SomeNewProperty2 = new List<double>(SomeNewProperty2); // make a copy of the list
}
}
This ensures that copies of GraphObjects and their subclasses are faithful reproductions. Consider for properties that are references to objects whether the reference should be shared (the default via MemberwiseClone) or whether that object value should be copied as well, resulting in a less shallow copy. This is demonstrated above by making a copy of the property value that is a List, so that modifications to the list will not be shared by copies of the CustomLink. Further copies of the list items might be warranted, depending on their purpose.
Please read the Introduction page on Extensions for how to override methods and how to call this base method.
Copy()
Creates a deep copy of this GraphObject and returns it.
Declaration
public virtual GraphObject Copy()
Returns
Type | Description |
---|---|
Graph |
Remarks
This method is the same as a clone for simple GraphObjects
such as Shape, Text
FindBindingPanel()
Walks up the visual tree and returns the first Panel whose Data is bound to data. This can be useful when you need to inspect Data objects.
Declaration
public Panel FindBindingPanel()
Returns
Type | Description |
---|---|
Panel |
GetDocumentAngle()
Returns the effective angle that the object is drawn at, in document coordinates, normalized to between 0 and 360.
Declaration
public double GetDocumentAngle()
Returns
Type | Description |
---|---|
double |
Remarks
Basically this adds together all of the rotation declared by this Angle and the angles of all of its containing Panels, including the Part.
GetDocumentBounds()
Returns the Rect in document coordinates for this object's bounds.
Declaration
public virtual Rect GetDocumentBounds()
Returns
Type | Description |
---|---|
Rect | in document coordinates. |
Remarks
If this GraphObject is a Part, the rect will be identical to its Actual
See Also
GetDocumentPoint(Point)
Returns the Point in document coordinates for a given Point in local coordinates.
Declaration
public Point GetDocumentPoint(Point local)
Parameters
Type | Name | Description |
---|---|---|
Point | local | a real Point in local coordinates. |
Returns
Type | Description |
---|---|
Point | in document coordinates. |
See Also
GetDocumentPoint(Spot)
Returns the Point in document coordinates for a given Spot in this object's bounds.
Declaration
public virtual Point GetDocumentPoint(Spot local)
Parameters
Type | Name | Description |
---|---|---|
Spot | local | a real Spot describing a relative location in or near this GraphObject. |
Returns
Type | Description |
---|---|
Point | in document coordinates. |
Remarks
For example, for an instance of a Node like this:
myDiagram.NodeTemplate =
new Node(PanelLayoutAuto.Instance)
.Add(
new Shape("RoundedRectangle")
.Bind("Fill", "Color),
new TextBlock { Name = "TB", Margin = 3 }
.Bind("Text", "Key")
);
where the Node is positioned at 100, 200
,
node.FindElement("TB").GetDocumentPoint(Spot.Center);
could return a Point that is approximately at 122, 213
.
See Also
GetDocumentScale()
Returns the total scale that the object is drawn at, in document coordinates.
Declaration
public double GetDocumentScale()
Returns
Type | Description |
---|---|
double |
Remarks
Basically this multiplies together this Scale with the scales of all of its containing Panels, including the Part.
GetLocalPoint(Point)
Given a Point in document coordinates, returns a new Point in local coordinates.
Declaration
public Point GetLocalPoint(Point p)
Parameters
Type | Name | Description |
---|---|---|
Point | p | a real Point in document coordinates. |
Returns
Type | Description |
---|---|
Point | The corresponding Point in local coordinates. |
Remarks
For example, if you have a mouse event whose Document122, 213
,
and if you have a Node whose Position is at 100, 200
,
node.GetLocalPoint(e.DocumentPoint)
could return a Point that is at 22, 13
.
For a GraphObject within the Node named "TB",
node.FindElement("TB").GetLocalPoint(e.DocumentPoint)
could return a Point that is at 15.7, 6.7
,
if that "TB" object is positioned somewhat inside the bounds of the Node.
See Also
IsContainedBy(GraphObject)
This predicate is true if this object is an element, perhaps indirectly, of the given panel.
Declaration
public bool IsContainedBy(GraphObject panel)
Parameters
Type | Name | Description |
---|---|---|
Graph |
panel |
Returns
Type | Description |
---|---|
bool | true if this object is contained by the given panel, or if it is contained by another panel that is contained by the given panel, to any depth; false if the argument is null or is not a Panel. |
Remarks
For example, if this GraphObject is inside a Part but is not itself the Part,
obj.IsContainedBy(obj.Part)
should be true.
IsEnabledElement()
This predicate is false if this object is inside any Panel that is not Is
Declaration
public bool IsEnabledElement()
Returns
Type | Description |
---|---|
bool |
Remarks
See Also
IsVisibleElement()
This predicate is true if this object is Visible and each of its visual containing panels is also visible.
Declaration
public bool IsVisibleElement()
Returns
Type | Description |
---|---|
bool |
Remarks
This ignores the actual location or appearance (except visibility) of the panel that this object is part of, as well as ignoring all properties of the Layer or Diagram.
For Parts, you can call the Is
Set(GraphObject)
Set properties of this GraphObject to the values of a "partial" GraphObject.
Declaration
public GraphObject Set(GraphObject obj)
Parameters
Type | Name | Description |
---|---|---|
Graph |
obj | the partial GraphObject to use for setting properties |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
Only properties that are different from the default for the GraphObject will be set in this manner.
For example, the following will only set the Angle and Opacity properties:
myObject.Set(new GraphObject {
Angle = 90,
Opacity = 0.5,
Scale = 1 // won't be set, even if this GraphObject's scale isn't 1
})
You should only call this with a GraphObject subclass as an argument.
Calling this method is much less efficient than setting properties directly. It's acceptable to call when constructing templates, as that will only happen once.
Set(object)
Set properties of this GraphObject to the values of a given anonymous object.
Declaration
public GraphObject Set(object props)
Parameters
Type | Name | Description |
---|---|---|
object | props | the dynamic object of properties |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
If this is a Panel, you can set properties on named elements within the panel by using a Name_Property syntax for the property name.
For example, if a Node has a Picture that is named "ICON" (because its Name property has been set to "ICON")
and a Text
aNode.Set(new {
Background = "red",
ICON_Source = "https://www.Example.Com/images/alert.Jpg",
TB_Font = "bold 12pt sans-serif"
});
At the current time only a single underscore is permitted in the property "name". Note that the use of all-upper-case object names is simply a convention.
Calling this method is much less efficient than setting properties directly. It's acceptable to call when constructing templates, as that will only happen once.
Set(string, object)
Set a property of this GraphObject to a value.
Declaration
public GraphObject Set(string propertyname, object value)
Parameters
Type | Name | Description |
---|---|---|
string | propertyname | the name of the property to set |
object | value | the value to set the property to |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Remarks
If this is a Panel, you can set properties on named elements within the panel by using a Name_Property syntax for the property name.
For example, if a Node has a Text
aNode.Set("Background", "red");
aNode.Set("TB_Font", "bold 12pt sans-serif");
At the current time only a single underscore is permitted in the property "name". Note that the use of all-upper-case object names is simply a convention.
Calling this method is much less efficient than setting properties directly. It's acceptable to call when constructing templates, as that will only happen once.
Trigger(params AnimationTrigger[])
Add a number of Animation
Declaration
public GraphObject Trigger(params AnimationTrigger[] triggers)
Parameters
Type | Name | Description |
---|---|---|
Animation |
triggers | the AnimationTriggers |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Trigger(IEnumerable<AnimationTrigger>)
Add a number of Animation
Declaration
public GraphObject Trigger(IEnumerable<AnimationTrigger> triggers)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Animation |
triggers | a collection of AnimationTriggers |
Returns
Type | Description |
---|---|
Graph |
this GraphObject |
Trigger(string, (int? Duration, Action<Animation> Finished, EasingFunction Easing)?, StartCondition?)
Add an Animation
Declaration
public GraphObject Trigger(string propertyName, (int? Duration, Action<Animation> Finished, EasingFunction Easing)? animationSettings = null, StartCondition? startCondition = null)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | A string naming the target property to animate. This should not be the empty string. |
(int? Duration, Action<Animation> Finished, Easing |
animationSettings | An optional tuple describing properties to set on animations created by this AnimationTrigger.
See the Animation |
Start |
startCondition | An optional Start |
Returns
Type | Description |
---|---|
Graph |