ClassGraphController
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
GraphController(IGraphInternal, IContainerGeneratorInternal)
Initializes a new instance of the GraphController class.
Declaration
public GraphController(IGraphInternal graph, IContainerGeneratorInternal containerGenerator)
Parameters
graph
The graph internal.
containerGenerator
The container generator.
Properties
ServiceLocator
Gets the service locator.
Declaration
public ServiceLocator ServiceLocator { get; }
Property Value
Methods
ActivateTool(MouseTool)
Activates the specified mouse tool for interaction with the diagram, changing the current primary tool based on the provided mouse tool type.
Declaration
public void ActivateTool(MouseTool mouseTool)
Parameters
mouseTool
The mouse tool type to activate (pointer, connector, pan, pencil, path, or text tool).
AddConnection(IConnection, bool)
Adds the connection.
Declaration
public void AddConnection(IConnection connection, bool isUndoable = true)
Parameters
connection
The connection.
isUndoable
If set to true [is undoable].
AddShape(IShape, bool)
Adds the shape.
AddShape(object, bool)
Adds the shape.
Declaration
public IShape AddShape(object item, bool isUndoable = true)
Parameters
item
The item.
isUndoable
If set to true [is undoable].
Returns
Exceptions
If the item is null.
AlignShapes(Alignment, IEnumerable<IShape>)
Aligns the specified shapes to the most left, top, right, or bottom edge defined by the selection bounds, providing precise geometric alignment control.
Declaration
public void AlignShapes(Alignment alignment, IEnumerable<IShape> shapes)
Parameters
alignment
The alignment direction that determines whether alignment should be calculated towards left, top, right, or bottom edge.
shapes
The collection of shapes to align according to the specified alignment direction.
BringForward(IEnumerable<IDiagramItem>, bool)
Brings the specified diagram items forward by one level in the Z-order drawing hierarchy with optional undo/redo support.
Declaration
public void BringForward(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Parameters
items
The collection of diagram items to move forward one level in the drawing order.
isUndoable
True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.
BringToFront(IEnumerable<IDiagramItem>, bool)
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.
Declaration
public void BringToFront(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Parameters
items
The collection of diagram items to move to the front of the drawing order.
isUndoable
True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.
ChangeTool(string)
Changes the active tool to the specified tool name, switching the current interaction mode for the diagram controller.
Declaration
public void ChangeTool(string toolName)
Parameters
toolName
The name or label of the tool to activate for diagram interaction.
Clear(bool)
Clears the diagram by removing all items and resetting the document to its initial state without saving the current content.
Declaration
public void Clear(bool isItemsCollectionChanging = false)
Parameters
isItemsCollectionChanging
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.
ClearConnections()
Clears all connections from the diagram by removing each connection individually while maintaining proper cleanup procedures.
Declaration
public void ClearConnections()
ClearShapes()
Clears all shapes from the diagram by removing each shape individually while maintaining proper cleanup procedures.
Declaration
public void ClearShapes()
Copy()
Creates a serialized copy of the currently selected diagram items and places it in the system clipboard for later pasting operations.
Declaration
public string Copy()
Returns
A string representation of the serialized diagram items that were copied to the clipboard.
CreateConnection(IShape, IShape, bool)
Creates the connection.
Declaration
public IConnection CreateConnection(IShape source, IShape target, bool isUndoable)
Parameters
source
The source.
target
The target.
isUndoable
If set to true [is undoable].
Returns
CreateConnectionInGraphSource(IShape, IShape)
Creates the connection in graph source.
CreateShapeInGraphSource(IShape)
Creates the shape in graph source.
CutItems()
Cuts the items.
Declaration
public string CutItems()
Returns
A string representation of the serialized diagram items that were cut and placed in the clipboard.
DeleteItems(IEnumerable<IDiagramItem>, bool)
Deletes the specified diagram items from the diagram with optional undo/redo support for operation history tracking.
Declaration
public void DeleteItems(IEnumerable<IDiagramItem> itemsToDelete, bool isUndoable)
Parameters
itemsToDelete
The collection of diagram items to remove from the diagram.
isUndoable
True to make this operation undoable and add it to the undo/redo history; false to delete permanently.
DeselectItem(IDiagramItem)
Deselects a specific diagram item from the current selection, or clears the entire selection if the item is null.
Declaration
public void DeselectItem(IDiagramItem deselectedItem)
Parameters
deselectedItem
The diagram item to remove from the selection, or null to clear the entire selection.
Deserialize(SerializationInfo)
Deserializes diagram data from a SerializationInfo object and restores the diagram state, replacing current content with deserialized items.
Declaration
public void Deserialize(SerializationInfo info)
Parameters
info
The SerializationInfo object containing serialized diagram data to restore.
Implements
ForceRealization()
Forces the immediate realization of all virtualized diagram elements, making them available for layout and manipulation operations.
Declaration
public void ForceRealization()
Group(string, bool, params IGroupable[])
Groups the specified diagram items together into a single logical unit with optional naming and undo/redo support for organizational purposes.
Declaration
public IGroup Group(string name = null, bool isUndoable = false, params IGroupable[] items)
Parameters
name
The optional name to assign to the created group for identification purposes.
isUndoable
True to make this operation undoable and add it to the undo/redo history; false to group permanently.
items
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.
IsInViewport(IDiagramItem)
Checks if the specified diagram item is currently visible within the diagram's viewport boundaries for virtualization purposes.
Declaration
public bool IsInViewport(IDiagramItem item)
Parameters
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.
KeyDown(KeyArgs)
Handles keyboard key down events and processes them through the active tool service for diagram interaction.
KeyUp(KeyArgs)
Handles keyboard key up events and processes them through the active tool service for diagram interaction.
Layout(LayoutType, object)
Organizes the diagram using the specified layout algorithm type, applying automatic arrangement and positioning of diagram elements.
Declaration
public void Layout(LayoutType type = LayoutType.Sugiyama, object settings = null)
Parameters
type
The layout algorithm type to apply (Sugiyama is the default hierarchical layout).
settings
The layout-specific settings object that configures the behavior of the chosen layout algorithm.
Load(string)
Loads and deserializes a diagram from a serialized XML string representation, replacing the current diagram content.
Declaration
public void Load(string serializationValue)
Parameters
serializationValue
A string containing XML data representing a previously serialized diagram to load and restore.
MergeItems(IEnumerable<IDiagramItem>, string, bool, Point, Size)
Merges the specified diagram items into the current diagram with position and size adjustments, supporting container integration and paste operations with undoable commands.
Declaration
public IEnumerable<IDiagramItem> MergeItems(IEnumerable<IDiagramItem> items, string originId, bool usePosition = false, Point position = default, Size size = default)
Parameters
items
The collection of diagram items to merge into the current diagram.
originId
The unique identifier of the source diagram to determine if items are being merged from the same or different diagram instance.
usePosition
True to use the specified position parameter for item placement; false to calculate position automatically.
position
The target position for placing merged items when usePosition is true.
size
The target size constraints for merged items during the merge operation.
Returns
A collection of diagram items that were successfully merged and added to the current diagram.
MouseDoubleClick(PointerArgs)
Handles mouse double-click events by detecting the shape under the cursor and publishing shape double-click events or delegating to the tool service.
Declaration
public void MouseDoubleClick(PointerArgs e)
Parameters
e
The pointer event arguments containing mouse position and button information.
MouseDown(PointerArgs)
Handles mouse button down events, processes them through the tool service, and exits edit mode for any diagram items currently being edited.
Declaration
public void MouseDown(PointerArgs e)
Parameters
e
The pointer event arguments containing mouse position and button information.
MouseMove(PointerArgs)
Handles mouse move events and processes them through the active tool service for diagram interaction and cursor tracking.
Declaration
public void MouseMove(PointerArgs e)
Parameters
e
The pointer event arguments containing current mouse position and movement information.
MouseUp(PointerArgs)
Handles mouse button up events, processes them through the tool service, and publishes shape or connection click events for items under the cursor.
Declaration
public bool MouseUp(PointerArgs e)
Parameters
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.
Nudge(Point)
Nudges (applies a small translation movement) the currently selected diagram items by the specified amount using the same undoable mechanism as the dragging tool.
Declaration
public void Nudge(Point amount)
Parameters
amount
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.
OnGraphSourceChanged(IGraphSource)
Called when graph source changes.
Declaration
public void OnGraphSourceChanged(IGraphSource source)
Parameters
source
The source.
OnItemsChanged(NotifyCollectionChangedEventArgs)
Called when Items collection changes.
Declaration
public void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Parameters
e
NotifyCollectionChangedEventArgs
The NotifyCollectionChangedEventArgs instance containing the event data.
OnViewportChanged()
Handles viewport boundary changes by updating virtualization and refreshing scrollbar positions to reflect the new visible area.
Declaration
public void OnViewportChanged()
Paste(string)
Pastes diagram items from a serialized string representation, deserializing and adding them to the current diagram with position adjustments.
Declaration
public IEnumerable<IDiagramItem> Paste(string pasteText)
Parameters
pasteText
The serialized string representation of diagram items to paste into the current diagram.
Returns
A collection of diagram items that were successfully pasted and added to the diagram.
RemoveConnection(IConnection, bool)
Removes the connection.
Declaration
public void RemoveConnection(IConnection connection, bool isUndoable = false)
Parameters
connection
The connection.
isUndoable
If set to true [is undoable].
RemoveShape(IShape, bool)
Removes the shape from the diagram.
Save()
Serializes the entire diagram to an XML string representation that can be saved to storage or transmitted for later restoration.
Declaration
public string Save()
Returns
An XML string containing the serialized diagram data, or null if serialization fails.
SelectItem(IDiagramItem, bool)
Selects a specific diagram item, optionally adding it to the existing selection or replacing the current selection based on the selection mode.
Declaration
public void SelectItem(IDiagramItem selectedItem, bool addToExistingSelection = false)
Parameters
selectedItem
The diagram item to select, or null to clear the current selection.
addToExistingSelection
True to add the item to the current selection; false to replace the current selection (subject to selection mode restrictions).
SendBackward(IEnumerable<IDiagramItem>, bool)
Sends the specified diagram items backward by one level in the Z-order drawing hierarchy with optional undo/redo support.
Declaration
public void SendBackward(IEnumerable<IDiagramItem> itemsToSend, bool isUndoable = true)
Parameters
itemsToSend
The collection of diagram items to move backward one level in the drawing order.
isUndoable
True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.
SendToBack(IEnumerable<IDiagramItem>, bool)
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.
Declaration
public void SendToBack(IEnumerable<IDiagramItem> itemsToSend, bool isUndoable = true)
Parameters
itemsToSend
The collection of diagram items to move to the back of the drawing order.
isUndoable
True to make this operation undoable and add it to the undo/redo history; false to change Z-order permanently.
Serialize()
Serializes the current diagram state into a SerializationInfo object containing all diagram data for persistence or transmission.
Declaration
public SerializationInfo Serialize()
Returns
A SerializationInfo object containing the serialized diagram data, or null if serialization fails.
Implements
SnapShapes(IEnumerable<IShape>)
Snaps the specified shapes to the nearest snap points based on the current snap value, using an undoable command that supports undo/redo operations.
Declaration
public void SnapShapes(IEnumerable<IShape> shapes)
Parameters
shapes
The collection of shapes to snap to the nearest snap points based on their current positions.
Ungroup(bool, params IGroup[])
Ungroups the specified group items by separating their contained elements back into individual diagram items with optional undo/redo support.
Declaration
public void Ungroup(bool isUndoable = false, params IGroup[] groups)
Parameters
isUndoable
True to make this operation undoable and add it to the undo/redo history; false to ungroup permanently.
groups
IGroup[]
The collection of group items to dissolve and separate into their constituent individual elements.