GraphController
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:
public sealed class GraphController : IControllerService, ISerializable
Inheritance: objectGraphController
Implements:
Constructors
Initializes a new instance of the GraphController class.
public GraphController(IGraphInternal graph, IContainerGeneratorInternal containerGenerator)
The graph internal.
containerGeneratorIContainerGeneratorInternalThe container generator.
Properties
Gets the service locator.
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.
public void ActivateTool(MouseTool mouseTool)
The mouse tool type to activate (pointer, connector, pan, pencil, path, or text tool).
Adds the connection.
public void AddConnection(IConnection connection, bool isUndoable = true)
The connection.
isUndoableboolIf set to true [is undoable].
Aligns the specified shapes to the most left, top, right, or bottom edge defined by the selection bounds, providing precise geometric alignment control.
public void AlignShapes(Alignment alignment, IEnumerable<IShape> shapes)
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.
public void BringForward(IEnumerable<IDiagramItem> items, bool isUndoable = true)
The collection of diagram items to move forward one level in the drawing order.
isUndoableboolTrue 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.
public void BringToFront(IEnumerable<IDiagramItem> items, bool isUndoable = true)
The collection of diagram items to move to the front of the drawing order.
isUndoableboolTrue 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.
public void ChangeTool(string toolName)
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.
public void Clear(bool isItemsCollectionChanging = false)
Indicates whether the items collection is currently being modified to prevent recursive clearing operations.
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.
public void ClearConnections()
Clears all shapes from the diagram by removing each shape individually while maintaining proper cleanup procedures.
public void ClearShapes()
Creates a serialized copy of the currently selected diagram items and places it in the system clipboard for later pasting operations.
public string Copy()
A string representation of the serialized diagram items that were copied to the clipboard.
Cuts the items.
public string CutItems()
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.
public void DeleteItems(IEnumerable<IDiagramItem> itemsToDelete, bool isUndoable)
The collection of diagram items to remove from the diagram.
isUndoableboolTrue 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.
public void DeselectItem(IDiagramItem deselectedItem)
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.
public void Deserialize(SerializationInfo info)
The SerializationInfo object containing serialized diagram data to restore.
Implements:
Forces the immediate realization of all virtualized diagram elements, making them available for layout and manipulation operations.
public void ForceRealization()
Groups the specified diagram items together into a single logical unit with optional naming and undo/redo support for organizational purposes.
public IGroup Group(string name = null, bool isUndoable = false, params IGroupable[] items)
The optional name to assign to the created group for identification purposes.
isUndoableboolTrue 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: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.
public bool IsInViewport(IDiagramItem item)
The diagram item to check for viewport visibility.
Returns: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.
Handles keyboard key up events and processes them through the active tool service for diagram interaction.
Organizes the diagram using the specified layout algorithm type, applying automatic arrangement and positioning of diagram elements.
public void Layout(LayoutType type = LayoutType.Sugiyama, object settings = null)
The layout algorithm type to apply (Sugiyama is the default hierarchical layout).
settingsobjectThe 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.
public void Load(string serializationValue)
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.
public IEnumerable<IDiagramItem> MergeItems(IEnumerable<IDiagramItem> items, string originId, bool usePosition = false, Point position = default, Size size = default)
The collection of diagram items to merge into the current diagram.
originIdstringThe unique identifier of the source diagram to determine if items are being merged from the same or different diagram instance.
usePositionboolTrue to use the specified position parameter for item placement; false to calculate position automatically.
positionPointThe target position for placing merged items when usePosition is true.
sizeSizeThe 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.
public void MouseDoubleClick(PointerArgs e)
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.
public void MouseDown(PointerArgs e)
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.
public void MouseMove(PointerArgs e)
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.
public bool MouseUp(PointerArgs e)
The pointer event arguments containing mouse position and button information.
Returns: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.
public void Nudge(Point amount)
The amount of translation defined as a point (vector) specifying the X and Y displacement values.
This is an undoable action and plugs into the same mechanism as the DraggingTool.
Called when graph source changes.
Called when Items collection changes.
public void OnItemsChanged(NotifyCollectionChangedEventArgs e)
The NotifyCollectionChangedEventArgs instance containing the event data.
Handles viewport boundary changes by updating virtualization and refreshing scrollbar positions to reflect the new visible area.
public void OnViewportChanged()
Pastes diagram items from a serialized string representation, deserializing and adding them to the current diagram with position adjustments.
public IEnumerable<IDiagramItem> Paste(string pasteText)
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.
public void RemoveConnection(IConnection connection, bool isUndoable = false)
The connection.
isUndoableboolIf set to true [is undoable].
Serializes the entire diagram to an XML string representation that can be saved to storage or transmitted for later restoration.
public string Save()
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.
public void SelectItem(IDiagramItem selectedItem, bool addToExistingSelection = false)
The diagram item to select, or null to clear the current selection.
addToExistingSelectionboolTrue 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.
public void SendBackward(IEnumerable<IDiagramItem> itemsToSend, bool isUndoable = true)
The collection of diagram items to move backward one level in the drawing order.
isUndoableboolTrue 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.
public void SendToBack(IEnumerable<IDiagramItem> itemsToSend, bool isUndoable = true)
The collection of diagram items to move to the back of the drawing order.
isUndoableboolTrue 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.
public SerializationInfo Serialize()
A SerializationInfo object containing the serialized diagram data, or null if serialization fails.
Implements:
Snaps the specified shapes to the nearest snap points based on the current snap value, using an undoable command that supports undo/redo operations.
public void SnapShapes(IEnumerable<IShape> shapes)
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.
public void Ungroup(bool isUndoable = false, params IGroup[] groups)
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.