New to Telerik UI for WinFormsStart a free 30-day trial

Main MVC controller. The view type is based on an interface in function of platform independence.

Definition

Namespace:Telerik.Windows.Diagrams.Core

Assembly:Telerik.WinControls.RadDiagram.dll

Syntax:

C#
public sealed class GraphController : IControllerService, ISerializable

Inheritance: objectGraphController

Implements: IControllerServiceISerializable

Constructors

Initializes a new instance of the GraphController class.

C#
public GraphController(IGraphInternal graph, IContainerGeneratorInternal containerGenerator)
Parameters:graphIGraphInternal

The graph internal.

containerGeneratorIContainerGeneratorInternal

The container generator.

Properties

Gets the service locator.

C#
public ServiceLocator ServiceLocator { get; }

Methods

Activates the specified mouse tool for interaction with the diagram, changing the current primary tool based on the provided mouse tool type.

C#
public void ActivateTool(MouseTool mouseTool)
Parameters:mouseToolMouseTool

The mouse tool type to activate (pointer, connector, pan, pencil, path, or text tool).

Adds the connection.

C#
public void AddConnection(IConnection connection, bool isUndoable = true)
Parameters:connectionIConnection

The connection.

isUndoablebool

If set to true [is undoable].

Adds the shape.

C#
public void AddShape(IShape shape, bool isUndoable = true)
Parameters:shapeIShape

The shape.

isUndoablebool

If set to true [is undoable].

Adds the shape.

C#
public IShape AddShape(object item, bool isUndoable = true)
Parameters:itemobject

The item.

isUndoablebool

If set to true [is undoable].

Returns:

IShape

Exceptions:

ArgumentNullException

If the item is null.

Aligns the specified shapes to the most left, top, right, or bottom edge defined by the selection bounds, providing precise geometric alignment control.

C#
public void AlignShapes(Alignment alignment, IEnumerable<IShape> shapes)
Parameters:alignmentAlignment

The alignment direction that determines whether alignment should be calculated towards left, top, right, or bottom edge.

shapesIEnumerable<IShape>

The collection of shapes to align according to the specified alignment direction.

Brings the specified diagram items forward by one level in the Z-order drawing hierarchy with optional undo/redo support.

C#
public void BringForward(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Parameters:itemsIEnumerable<IDiagramItem>

The collection of diagram items to move forward one level in the drawing order.

isUndoablebool

True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.

Brings the specified diagram items to the front of the Z-order by setting their Z-index above all other items with optional undo/redo support.

C#
public void BringToFront(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Parameters:itemsIEnumerable<IDiagramItem>

The collection of diagram items to move to the front of the drawing order.

isUndoablebool

True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.

Changes the active tool to the specified tool name, switching the current interaction mode for the diagram controller.

C#
public void ChangeTool(string toolName)
Parameters:toolNamestring

The name or label of the tool to activate for diagram interaction.

Clears the diagram by removing all items and resetting the document to its initial state without saving the current content.

C#
public void Clear(bool isItemsCollectionChanging = false)
Parameters:isItemsCollectionChangingbool

Indicates whether the items collection is currently being modified to prevent recursive clearing operations.

Remarks:

The diagram is not saved prior to this reset. You need to handle in the application the eventual necessity to save (or request the user) the diagram before this.

Clears all connections from the diagram by removing each connection individually while maintaining proper cleanup procedures.

C#
public void ClearConnections()

Clears all shapes from the diagram by removing each shape individually while maintaining proper cleanup procedures.

C#
public void ClearShapes()

Creates a serialized copy of the currently selected diagram items and places it in the system clipboard for later pasting operations.

C#
public string Copy()
Returns:

string

A string representation of the serialized diagram items that were copied to the clipboard.

Creates the connection.

C#
public IConnection CreateConnection(IShape source, IShape target, bool isUndoable)
Parameters:sourceIShape

The source.

targetIShape

The target.

isUndoablebool

If set to true [is undoable].

Returns:

IConnection

Creates the connection in graph source.

C#
public ILink CreateConnectionInGraphSource(IShape source, IShape target)
Parameters:sourceIShape

The source.

targetIShape

The target.

Returns:

ILink

Creates the shape in graph source.

C#
public object CreateShapeInGraphSource(IShape shape)
Parameters:shapeIShape

The shape.

Returns:

object

Cuts the items.

C#
public string CutItems()
Returns:

string

A string representation of the serialized diagram items that were cut and placed in the clipboard.

Deletes the specified diagram items from the diagram with optional undo/redo support for operation history tracking.

C#
public void DeleteItems(IEnumerable<IDiagramItem> itemsToDelete, bool isUndoable)
Parameters:itemsToDeleteIEnumerable<IDiagramItem>

The collection of diagram items to remove from the diagram.

isUndoablebool

True to make this operation undoable and add it to the undo/redo history; false to delete permanently.

Deselects a specific diagram item from the current selection, or clears the entire selection if the item is null.

C#
public void DeselectItem(IDiagramItem deselectedItem)
Parameters:deselectedItemIDiagramItem

The diagram item to remove from the selection, or null to clear the entire selection.

Deserializes diagram data from a SerializationInfo object and restores the diagram state, replacing current content with deserialized items.

C#
public void Deserialize(SerializationInfo info)
Parameters:infoSerializationInfo

The SerializationInfo object containing serialized diagram data to restore.

Implements: ISerializable.Deserialize(SerializationInfo)

Forces the immediate realization of all virtualized diagram elements, making them available for layout and manipulation operations.

C#
public void ForceRealization()

Groups the specified diagram items together into a single logical unit with optional naming and undo/redo support for organizational purposes.

C#
public IGroup Group(string name = null, bool isUndoable = false, params IGroupable[] items)
Parameters:namestring

The optional name to assign to the created group for identification purposes.

isUndoablebool

True to make this operation undoable and add it to the undo/redo history; false to group permanently.

itemsIGroupable[]

The collection of groupable diagram items to combine into a single group.

Returns:

IGroup

The IGroup instance representing the newly created group containing the specified items.

Checks if the specified diagram item is currently visible within the diagram's viewport boundaries for virtualization purposes.

C#
public bool IsInViewport(IDiagramItem item)
Parameters:itemIDiagramItem

The diagram item to check for viewport visibility.

Returns:

bool

True if the item is within the current viewport boundaries; false if it is outside the visible area.

Handles keyboard key down events and processes them through the active tool service for diagram interaction.

C#
public bool KeyDown(KeyArgs e)
Parameters:eKeyArgs

The keyboard event arguments containing key information and modifier states.

Returns:

bool

True if the key down event was handled by the tool service; otherwise, false.

Handles keyboard key up events and processes them through the active tool service for diagram interaction.

C#
public bool KeyUp(KeyArgs e)
Parameters:eKeyArgs

The keyboard event arguments containing key information and modifier states.

Returns:

bool

True if the key up event was handled by the tool service; otherwise, false.

Organizes the diagram using the specified layout algorithm type, applying automatic arrangement and positioning of diagram elements.

C#
public void Layout(LayoutType type = LayoutType.Sugiyama, object settings = null)
Parameters:typeLayoutType

The layout algorithm type to apply (Sugiyama is the default hierarchical layout).

settingsobject

The layout-specific settings object that configures the behavior of the chosen layout algorithm.

Loads and deserializes a diagram from a serialized XML string representation, replacing the current diagram content.

C#
public void Load(string serializationValue)
Parameters:serializationValuestring

A string containing XML data representing a previously serialized diagram to load and restore.

Merges the specified diagram items into the current diagram with position and size adjustments, supporting container integration and paste operations with undoable commands.

C#
public IEnumerable<IDiagramItem> MergeItems(IEnumerable<IDiagramItem> items, string originId, bool usePosition = false, Point position = default, Size size = default)
Parameters:itemsIEnumerable<IDiagramItem>

The collection of diagram items to merge into the current diagram.

originIdstring

The unique identifier of the source diagram to determine if items are being merged from the same or different diagram instance.

usePositionbool

True to use the specified position parameter for item placement; false to calculate position automatically.

positionPoint

The target position for placing merged items when usePosition is true.

sizeSize

The target size constraints for merged items during the merge operation.

Returns:

IEnumerable<IDiagramItem>

A collection of diagram items that were successfully merged and added to the current diagram.

Handles mouse double-click events by detecting the shape under the cursor and publishing shape double-click events or delegating to the tool service.

C#
public void MouseDoubleClick(PointerArgs e)
Parameters:ePointerArgs

The pointer event arguments containing mouse position and button information.

Handles mouse button down events, processes them through the tool service, and exits edit mode for any diagram items currently being edited.

C#
public void MouseDown(PointerArgs e)
Parameters:ePointerArgs

The pointer event arguments containing mouse position and button information.

Handles mouse move events and processes them through the active tool service for diagram interaction and cursor tracking.

C#
public void MouseMove(PointerArgs e)
Parameters:ePointerArgs

The pointer event arguments containing current mouse position and movement information.

Handles mouse button up events, processes them through the tool service, and publishes shape or connection click events for items under the cursor.

C#
public bool MouseUp(PointerArgs e)
Parameters:ePointerArgs

The pointer event arguments containing mouse position and button information.

Returns:

bool

True if the mouse up event was handled by the tool service; otherwise, false.

Nudges (applies a small translation movement) the currently selected diagram items by the specified amount using the same undoable mechanism as the dragging tool.

C#
public void Nudge(Point amount)
Parameters:amountPoint

The amount of translation defined as a point (vector) specifying the X and Y displacement values.

Remarks:

This is an undoable action and plugs into the same mechanism as the DraggingTool.

Called when graph source changes.

C#
public void OnGraphSourceChanged(IGraphSource source)
Parameters:sourceIGraphSource

The source.

Called when Items collection changes.

C#
public void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Parameters:eNotifyCollectionChangedEventArgs

The NotifyCollectionChangedEventArgs instance containing the event data.

Handles viewport boundary changes by updating virtualization and refreshing scrollbar positions to reflect the new visible area.

C#
public void OnViewportChanged()

Pastes diagram items from a serialized string representation, deserializing and adding them to the current diagram with position adjustments.

C#
public IEnumerable<IDiagramItem> Paste(string pasteText)
Parameters:pasteTextstring

The serialized string representation of diagram items to paste into the current diagram.

Returns:

IEnumerable<IDiagramItem>

A collection of diagram items that were successfully pasted and added to the diagram.

Removes the connection.

C#
public void RemoveConnection(IConnection connection, bool isUndoable = false)
Parameters:connectionIConnection

The connection.

isUndoablebool

If set to true [is undoable].

Removes the shape from the diagram.

C#
public void RemoveShape(IShape shape, bool isUndoable = false)
Parameters:shapeIShape

The shape to be removed.

isUndoablebool

If set to true the action will be recorded in the undo stack.

Serializes the entire diagram to an XML string representation that can be saved to storage or transmitted for later restoration.

C#
public string Save()
Returns:

string

An XML string containing the serialized diagram data, or null if serialization fails.

Selects a specific diagram item, optionally adding it to the existing selection or replacing the current selection based on the selection mode.

C#
public void SelectItem(IDiagramItem selectedItem, bool addToExistingSelection = false)
Parameters:selectedItemIDiagramItem

The diagram item to select, or null to clear the current selection.

addToExistingSelectionbool

True to add the item to the current selection; false to replace the current selection (subject to selection mode restrictions).

Sends the specified diagram items backward by one level in the Z-order drawing hierarchy with optional undo/redo support.

C#
public void SendBackward(IEnumerable<IDiagramItem> itemsToSend, bool isUndoable = true)
Parameters:itemsToSendIEnumerable<IDiagramItem>

The collection of diagram items to move backward one level in the drawing order.

isUndoablebool

True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.

Sends the specified diagram items to the back of the Z-order by setting their Z-index below all other items with optional undo/redo support.

C#
public void SendToBack(IEnumerable<IDiagramItem> itemsToSend, bool isUndoable = true)
Parameters:itemsToSendIEnumerable<IDiagramItem>

The collection of diagram items to move to the back of the drawing order.

isUndoablebool

True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.

Serializes the current diagram state into a SerializationInfo object containing all diagram data for persistence or transmission.

C#
public SerializationInfo Serialize()
Returns:

SerializationInfo

A SerializationInfo object containing the serialized diagram data, or null if serialization fails.

Implements: ISerializable.Serialize()

Snaps the specified shapes to the nearest snap points based on the current snap value, using an undoable command that supports undo/redo operations.

C#
public void SnapShapes(IEnumerable<IShape> shapes)
Parameters:shapesIEnumerable<IShape>

The collection of shapes to snap to the nearest snap points based on their current positions.

Ungroups the specified group items by separating their contained elements back into individual diagram items with optional undo/redo support.

C#
public void Ungroup(bool isUndoable = false, params IGroup[] groups)
Parameters:isUndoablebool

True to make this operation undoable and add it to the undo/redo history; false to ungroup permanently.

groupsIGroup[]

The collection of group items to dissolve and separate into their constituent individual elements.