Class DiagramController
Implements a generic diagram controller containing a default set of tools.
Inherited Members
Namespace: Syncfusion.Windows.Forms.Diagram
Assembly: Syncfusion.Diagram.Windows.dll
Syntax
public class DiagramController : Controller, IServiceReferenceHolder, IServiceReferenceProvider, IDisposable, IMouseController
Remarks
The DiagramController class implements a concrete controller with a generic diagramming user interface. It overrides the Initialize() method and registers all available tools in the Diagram Windows assembly. A tool is an object that implements a distinct functionality for the controller. Tools can be added to the controller using the RegisterTool(Tool) method in order to customize the behavior of the controller.
The DiagramController is responsible for coordinating the activation and deactivation of tools. The ActivateTool(Tool) method activates a specified tool. The DeactivateTool(Tool) method deactivates a specified tool. Tools can be accessed by name with the GetTool(String) method.
The DiagramController captures all mouse events and performs hit testing on the diagram. Nodes, ports, and vertices hit by mouse movements are tracked by the controller. Tools can access this hit testing information in the controller. In other words, the controller provides basic hit testing services to tools so that each tool doesn't need to implement (and possible duplicate) that hit testing logic. The following properties and methods provide access to the hit testing state information: MouseLocation, NodesHit,
Controller ToolConstructors
DiagramController()
Initializes a new instance of the DiagramController class.
Declaration
public DiagramController()
DiagramController(View)
Initializes a new instance of the DiagramController class.
Declaration
public DiagramController(View view)
Parameters
| Type | Name | Description |
|---|---|---|
| View | view | The view. |
Fields
accctiveTool
References the currently active Tool.
Declaration
protected Tool accctiveTool
Field Value
| Type |
|---|
| Tool |
guid
Unique ID used to identify the source of copy and paste operations.
Declaration
protected Guid guid
Field Value
| Type |
|---|
| System.Guid |
m_szPasteOffset
Paste Offset.
Declaration
protected SizeF m_szPasteOffset
Field Value
| Type |
|---|
| System.Drawing.SizeF |
pasteIndex
Number of consecutive paste operations - used to offset nodes pasted.
Declaration
protected int pasteIndex
Field Value
| Type |
|---|
| System.Int32 |
Properties
ActiveTool
Gets or sets the diagram active tool.
Declaration
public Tool ActiveTool { get; set; }
Property Value
| Type | Description |
|---|---|
| Tool | The active tool. |
AllowCopyAtCtrlDrag
Gets or sets a value indicating whether the controller allows copying a node while pressing Ctrl+drag or Ctrl+Shift+drag.
Declaration
public bool AllowCopyAtCtrlDrag { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
CanCopy
Gets a value indicating whether there are any selected nodes that can be copied to the clipboard.
Declaration
public virtual bool CanCopy { get; }
Property Value
| Type |
|---|
| System.Boolean |
CanCut
Gets a value indicating whether if there are any selected nodes that can be removed from the the model.
Declaration
public virtual bool CanCut { get; }
Property Value
| Type |
|---|
| System.Boolean |
CanPaste
Gets a value indicating whether there is any data in the clipboard that can be pasted into the model.
Declaration
public virtual bool CanPaste { get; }
Property Value
| Type |
|---|
| System.Boolean |
Remarks
This method checks the clipboard to see if a NodeCollection is available.
Cursor
Gets or sets cursor to use inside the view.
Declaration
public Cursor Cursor { get; set; }
Property Value
| Type |
|---|
| System.Windows.Forms.Cursor |
DraggingStyle
Gets or sets dragging style of rendering helper
Declaration
public RenderingHelperStyle DraggingStyle { get; set; }
Property Value
| Type |
|---|
| RenderingHelperStyle |
Guides
Gets the diagram Guides.
Declaration
public Guides Guides { get; }
Property Value
| Type |
|---|
| Guides |
InPlaceEditing
Gets or sets a value indicating whether in place editing is enabled or not.
Declaration
public bool InPlaceEditing { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
InPlaceEditor
Gets the in place editor instance.
Declaration
public InPlaceEditor InPlaceEditor { get; }
Property Value
| Type | Description |
|---|---|
| InPlaceEditor | The text editor. |
MouseLocation
Gets the last known location of the mouse pointer.
Declaration
public PointF MouseLocation { get; }
Property Value
| Type |
|---|
| System.Drawing.PointF |
Remarks
This property is updated each time the controller receives a mouse event: NodesHit
MouseTrackingEnabled
Gets or sets a value indicating whether mouse tracking is enabled.
Declaration
public bool MouseTrackingEnabled { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Nodes
Declaration
public List<NodeWrapper> Nodes { get; set; }
Property Value
| Type |
|---|
| System.Collections.Generic.List<NodeWrapper> |
NodesHit
Gets the list of nodes that were hit during the last received mouse event.
Declaration
public NodeCollection NodesHit { get; }
Property Value
| Type |
|---|
| NodeCollection |
Remarks
NodeToInsert
Gets or sets a node to insert the model through InsertNodeTool
Declaration
public Node NodeToInsert { get; set; }
Property Value
| Type |
|---|
| Node |
ParentControl
Gets the System.Windows.Forms.Control that owns the view that this controller is attached to.
Declaration
public virtual Control ParentControl { get; }
Property Value
| Type |
|---|
| System.Windows.Forms.Control |
PasteOffset
Gets or sets the paste offset that indicate offset of next paste object.
Declaration
public SizeF PasteOffset { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Drawing.SizeF | The paste offset. |
ResizingStyle
Gets or sets resizing style of rendering helper
Declaration
public RenderingHelperStyle ResizingStyle { get; set; }
Property Value
| Type |
|---|
| RenderingHelperStyle |
RotatingStyle
Gets or sets rotating style of rendering helper
Declaration
public RenderingHelperStyle RotatingStyle { get; set; }
Property Value
| Type |
|---|
| RenderingHelperStyle |
TextEditor
Gets the text editor instance.
Declaration
public TextEditor TextEditor { get; }
Property Value
| Type | Description |
|---|---|
| TextEditor | The text editor. |
Methods
ActivateTool(Tool)
Activates the given Tool object.
Declaration
public bool ActivateTool(Tool tool)
Parameters
| Type | Name | Description |
|---|---|---|
| Tool | tool | Tool to activate. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if successful; otherwise False. |
ActivateTool(String)
Activates the Tool object matching the given name.
Declaration
public bool ActivateTool(string toolName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | toolName | Name of Tool to activate. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if successful; otherwise False. |
Remarks
This method first locates the tool matching the given name and then passes it to the ActivateTool(Tool) method. Tool
ChangeCursor(Cursor)
Changes the mouse cursor.
Declaration
protected void ChangeCursor(Cursor newCursor)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Cursor | newCursor | The new cursor. |
Copy()
Copy the currently selected nodes to the clipboard.
Declaration
public virtual void Copy()
Remarks
Creates a new NodeCollection and copies the selected nodes into it. It then copies the new NodeCollection to the clipboard.
Cut()
Remove the currently selected nodes from the diagram and move them to the clipboard.
Declaration
public virtual void Cut()
DeactivateTool(Tool)
Deactivates the given Tool object.
Declaration
public bool DeactivateTool(Tool tool)
Parameters
| Type | Name | Description |
|---|---|---|
| Tool | tool | The Tool to deactivate. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if successful; otherwise False. |
Dispose()
Declaration
public override void Dispose()
Overrides
Document_NodeCollectionChanged(CollectionExEventArgs)
Documents the node collection changed.
Declaration
protected override void Document_NodeCollectionChanged(CollectionExEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| CollectionExEventArgs | evtArgs | The CollectionExEventArgs instance containing the event data. |
Overrides
Document_PropertyChanging(PropertyChangingEventArgs)
Documents the property changing.
Declaration
protected override void Document_PropertyChanging(PropertyChangingEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyChangingEventArgs | evtArgs | The PropertyChangingEventArgs instance containing the event data. |
Overrides
DrawGuides(Node, Graphics, RectangleF)
Draws the Guides
Declaration
public void DrawGuides(Node renderHelper, Graphics gfx, RectangleF curNodeBounds)
Parameters
| Type | Name | Description |
|---|---|---|
| Node | renderHelper | Node |
| System.Drawing.Graphics | gfx | Graphics |
| System.Drawing.RectangleF | curNodeBounds | Node bounds |
DrawPortHighlighter(Graphics, ConnectionPoint, RectangleF)
Declaration
public virtual void DrawPortHighlighter(Graphics gfx, ConnectionPoint port, RectangleF rect)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Graphics | gfx | |
| ConnectionPoint | port | |
| System.Drawing.RectangleF | rect |
EventSink_PropertyChanging(PropertyChangingEventArgs)
Events the sink property changing.
Declaration
protected override void EventSink_PropertyChanging(PropertyChangingEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyChangingEventArgs | evtArgs | The PropertyChangingEventArgs instance containing the event data. |
Overrides
GetActualObject(Node)
Declaration
public void GetActualObject(Node selectednode)
Parameters
| Type | Name | Description |
|---|---|---|
| Node | selectednode |
GetAllNodesAtPoint(ICompositeNode, PointF)
Gets all nodes include composite node children at point in model coordinates.
Declaration
public NodeCollection GetAllNodesAtPoint(ICompositeNode compositeNode, PointF ptPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompositeNode | compositeNode | The composite node. |
| System.Drawing.PointF | ptPoint | The given point in model coordinates. |
Returns
| Type | Description |
|---|---|
| NodeCollection | The nodes at the given point. |
GetAllNodesAtPoint(ICompositeNode, PointF, Boolean)
Gets all nodes include composite node children at point in model coordinates.
Declaration
public NodeCollection GetAllNodesAtPoint(ICompositeNode compositeNode, PointF ptPoint, bool bOnlyCanSelected)
Parameters
| Type | Name | Description |
|---|---|---|
| ICompositeNode | compositeNode | The composite node. |
| System.Drawing.PointF | ptPoint | The given point in model coordinates. |
| System.Boolean | bOnlyCanSelected | if set to |
Returns
| Type | Description |
|---|---|
| NodeCollection | The nodes at the given point. |
GetAllTools()
Returns an array of all Tool objects registered with the controller.
Declaration
public Tool[] GetAllTools()
Returns
| Type | Description |
|---|---|
| Tool[] | Array of registered Tool objects. |
Remarks
GetConnectionPointAtPoint(PointF)
Declaration
public virtual ConnectionPoint GetConnectionPointAtPoint(PointF ptSnapping)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.PointF | ptSnapping |
Returns
| Type |
|---|
| ConnectionPoint |
GetNodeAtPoint(PointF)
Gets the node at point in model coordinates.
Declaration
public Node GetNodeAtPoint(PointF ptMouseLocation)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.PointF | ptMouseLocation | The given point in model coordinates. |
Returns
| Type | Description |
|---|---|
| Node | The node at the given point. |
GetNodesAtPoint(Point)
Gets the nodes at point in client coordinates.
Declaration
public NodeCollection GetNodesAtPoint(Point ptMouseLocation)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Point | ptMouseLocation | The given point in client coordinates. |
Returns
| Type | Description |
|---|---|
| NodeCollection | The nodes at the given point. |
GetNodeUnderMouse(Point)
Gets the top node under mouse cursor.
Declaration
public INode GetNodeUnderMouse(Point ptMouse)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Point | ptMouse | The mouse cursor position. |
Returns
| Type | Description |
|---|---|
| INode | Top node under mouse cursor. |
GetTool(String)
Returns the Tool object matching the given name.
Declaration
public Tool GetTool(string toolName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | toolName | Name of Tool object to return. |
Returns
| Type | Description |
|---|---|
| Tool | Tool object matching the given name, or NULL if not found. |
Remarks
HistoryManager_CommandStarted(Object, EventArgs)
Handles the CommandStarted event of the HistoryManager control.
Declaration
protected override void HistoryManager_CommandStarted(object sender, EventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | The source of the event. |
| System.EventArgs | e | The System.EventArgs instance containing the event data. |
Overrides
InitialiizeController()
Initializes the controller.
Declaration
protected virtual void InitialiizeController()
Initialize()
Initializes this instance.
Declaration
public void Initialize()
OnClick(EventArgs)
Called when a click event is received.
Declaration
public virtual void OnClick(EventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | evtArgs | Event arguments. |
Remarks
Iterates through the nodes hit by the click event and notifies them of the click by calling the Click(EventArgs) method. IDispatchNodeEvents
OnDoubleClick(EventArgs)
Called when a double click event is received.
Declaration
public virtual void OnDoubleClick(EventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | evtArgs | Event arguments. |
Remarks
Iterates through the nodes hit by the double click event and notifies them of the click by calling the DoubleClick(EventArgs) method.
IDispatchNodeEventsOnDragEnter(DragEventArgs)
Called when the drag enter event occurs.
Declaration
public virtual void OnDragEnter(DragEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.DragEventArgs | evtArgs | Event arguments. |
OnHorizontalScroll(Object, ScrollEventArgs)
Called when a HorizontalScroll event is received.
Declaration
protected virtual void OnHorizontalScroll(object sender, ScrollEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | Object sending the event. |
| System.Windows.Forms.ScrollEventArgs | evtArgs | Event arguments. |
Remarks
Iterates through all tools that implement the IScrollEventReceiver interface and forwards the event onto them.
IScrollEventReceiverOnKeyDown(KeyEventArgs)
Called when a key down event is received.
Declaration
public virtual void OnKeyDown(KeyEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.KeyEventArgs | evtArgs | Event arguments. |
OnKeyPress(KeyPressEventArgs)
Called when a key press event is received.
Declaration
public virtual void OnKeyPress(KeyPressEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.KeyPressEventArgs | evtArgs | Event arguments. |
OnKeyUp(KeyEventArgs)
Called when a key up event is received.
Declaration
public virtual void OnKeyUp(KeyEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.KeyEventArgs | evtArgs | Event arguments. |
OnMouseDown(MouseEventArgs)
Called when a mouse down event occurs.
Declaration
public virtual void OnMouseDown(MouseEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | evtArgs | Event arguments. |
Remarks
This method updates the current mouse location and then performs hit testing for handles and nodes.
OnMouseLeave(EventArgs)
Called when a mouse leave event is received.
Declaration
public virtual void OnMouseLeave(EventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | evtArgs | Event arguments. |
OnMouseMove(MouseEventArgs)
Called when a mouse move event occurs.
Declaration
public virtual void OnMouseMove(MouseEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | evtArgs | Event arguments. |
Remarks
This method updates the current mouse location and then performs hit testing for handles and nodes.
OnMouseUp(MouseEventArgs)
Called when a mouse up event is received.
Declaration
public virtual void OnMouseUp(MouseEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | evtArgs | Event arguments. |
Remarks
This method updates the current mouse location and then performs hit testing for handles and nodes.
OnToolActivated(ToolEventArgs)
Raise the tool activated event.
Declaration
protected virtual void OnToolActivated(ToolEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| ToolEventArgs | evtArgs | The ToolEventArgs instance containing the event data. |
OnToolDeactivated(ToolEventArgs)
Raise the tool deactivated event.
Declaration
protected virtual void OnToolDeactivated(ToolEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| ToolEventArgs | evtArgs | The ToolEventArgs instance containing the event data. |
OnVerticalScroll(Object, ScrollEventArgs)
Called when a VerticalScroll event is received.
Declaration
protected virtual void OnVerticalScroll(object sender, ScrollEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | The sender |
| System.Windows.Forms.ScrollEventArgs | evtArgs | Event arguments. |
Remarks
Iterates through all tools that implement the IScrollEventReceiver interface and forwards the event onto them.
IScrollEventReceiverPaste()
Paste the contents of the clipboard to the diagram.
Declaration
public virtual void Paste()
Remarks
If a NodeCollection is available on the clipboard, this method gets it and inserts it into the diagram.
Paste(PointF)
Paste the contents of the clipboard to the diagram.
Declaration
public virtual void Paste(PointF location)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.PointF | location | The location at which to insert the nodes. |
Remarks
If a NodeCollection is available on the clipboard, this method gets it and inserts it into the diagram.
Paste(String, PointF)
Paste the contents of the clipboard to the diagram.
Declaration
public virtual void Paste(string layername, PointF location)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | layername | Name of the layer in which to insert the nodes. |
| System.Drawing.PointF | location | The location at which to insert the nodes. |
Remarks
If a NodeCollection is available on the clipboard, this method gets it and inserts it into the diagram.
RegisterStandardTools()
Registers the standard interactive tools used by the diagram.
Declaration
protected virtual void RegisterStandardTools()
RegisterTool(Tool)
Adds a new tool to the controller.
Declaration
public bool RegisterTool(Tool tool)
Parameters
| Type | Name | Description |
|---|---|---|
| Tool | tool | Tool object to register. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if successful; otherwise False. |
RestoreCursor()
Restores the saved cursor.
Declaration
public void RestoreCursor()
SetCursor(BoxPosition, Node)
Sets the cursor.
Declaration
public void SetCursor(BoxPosition handlePos, Node node)
Parameters
| Type | Name | Description |
|---|---|---|
| BoxPosition | handlePos | The handle pos. |
| Node | node | The node. |
UninitialiizeController()
Uninitializes the controller.
Declaration
protected virtual void UninitialiizeController()
Uninitialize()
Uninitializes this instance.
Declaration
public void Uninitialize()
UnRegisterTool(Tool)
Removes a previously registered tool from the Controller.
Declaration
public bool UnRegisterTool(Tool tool)
Parameters
| Type | Name | Description |
|---|---|---|
| Tool | tool | Tool object to unregister. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the unregistration is successful; otherwise False. |
View_OriginChanged(ViewOriginEventArgs)
Handles the view origin changed event.
Declaration
protected override void View_OriginChanged(ViewOriginEventArgs evtArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| ViewOriginEventArgs | evtArgs | The ViewOriginEventArgs instance containing the event data. |
Overrides
Explicit Interface Implementations
IMouseController.CancelMode()
Declaration
void IMouseController.CancelMode()
IMouseController.Cursor
Gets the cursor currently assigned to the controller.
Declaration
Cursor IMouseController.Cursor { get; }
Returns
| Type |
|---|
| System.Windows.Forms.Cursor |
IMouseController.HitTest(MouseEventArgs, IMouseController)
Declaration
int IMouseController.HitTest(MouseEventArgs mouseEventArgs, IMouseController controller)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | mouseEventArgs | |
| IMouseController | controller |
Returns
| Type |
|---|
| System.Int32 |
IMouseController.MouseDown(MouseEventArgs)
Declaration
void IMouseController.MouseDown(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | e |
IMouseController.MouseHover(MouseEventArgs)
Declaration
void IMouseController.MouseHover(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | e |
IMouseController.MouseHoverEnter()
Declaration
void IMouseController.MouseHoverEnter()
IMouseController.MouseHoverLeave(EventArgs)
Declaration
void IMouseController.MouseHoverLeave(EventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | e |
IMouseController.MouseMove(MouseEventArgs)
Declaration
void IMouseController.MouseMove(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | e |
IMouseController.MouseUp(MouseEventArgs)
Declaration
void IMouseController.MouseUp(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.MouseEventArgs | e |
IMouseController.Name
Gets the name of the mouse controller.
Declaration
string IMouseController.Name { get; }
Returns
| Type |
|---|
| System.String |