RadDiagram
Represents a powerful diagramming control that allows visualization and editing of diagrams, flowcharts, organizational charts, and other visual graph structures. Provides functionality for creating, connecting, and manipulating shapes within a canvas.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.RadDiagram.dll
Syntax:
[TelerikToolboxCategory("Diagram")]
[ComplexBindingProperties("DataSource")]
public class RadDiagram : RadControl, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, INotifyPropertyChanged, ISupportInitializeNotification, ISupportInitialize, IComponentTreeHandler, ILayoutHandler, IAnalyticsProvider, IPrintable
Inheritance: objectMarshalByRefObjectComponentControlScrollableControlRadControlRadDiagram...
Implements:
Inherited Members
Constructors
Initializes a new instance of the RadDiagram class. Sets up the control with default settings and enables gesture support.
public RadDiagram()
Properties
Gets or sets the tool which is active when interacting with the diagram elements.
public MouseTool ActiveTool { get; set; }
Gets or sets a value indicating whether copying is allowed.
public bool AllowCopy { get; set; }
True if copying is allowed; otherwise, false.
Gets or sets a value indicating whether cutting is allowed.
public bool AllowCut { get; set; }
True if cutting is allowed; otherwise, false.
Gets or sets a value indicating whether deleting is allowed.
public bool AllowDelete { get; set; }
True if deleting is allowed; otherwise, false.
Gets or sets a value indicating whether pasting is allowed.
public bool AllowPaste { get; set; }
True if pasting is allowed; otherwise, false.
Gets or sets the auto layout.
public bool AutoLayout { get; set; }
public virtual BackgroundGrid BackgroundGrid { get; }
public virtual BackgroundPageGrid BackgroundPageGrid { get; }
Gets or sets the connection bridge type.
public BridgeType ConnectionBridge { get; set; }
Gets or sets the links data member.
[Browsable(true)]
public string ConnectionDataMember { get; set; }
The data member.
Gets or sets whether the corners of the (polyline) connection are rounded.
public bool ConnectionRoundedCorners { get; set; }
This property has only an effect when the ConnectionType is set to Polyline.
Gets the connections.
[Browsable(false)]
public ConnectionCollection Connections { get; }
Gets or sets the ConnectionSourceCapTypeMember data member.
[Browsable(true)]
public string ConnectionSourceCapTypeMember { get; set; }
The data member.
Gets or sets the SourceConnector data member.
[Browsable(true)]
public string ConnectionSourceConnectorMember { get; set; }
The data member.
Gets or sets the ConnectionTargetShapeIdMember data member.
[Browsable(true)]
public string ConnectionSourceShapeIdMember { get; set; }
The data member.
Gets or sets the ConnectionTargetCapTypeMember data member.
[Browsable(true)]
public string ConnectionTargetCapTypeMember { get; set; }
The data member.
Gets or sets the Target connector data member.
[Browsable(true)]
public string ConnectionTargetConnectorMember { get; set; }
The data member.
Gets or sets the ConnectionTargetShapeIdMember data member.
[Browsable(true)]
public string ConnectionTargetShapeIdMember { get; set; }
The data member.
Gets or sets the ConnectionTextMember data member.
[Browsable(true)]
public string ConnectionTextMember { get; set; }
The data member.
Gets the container generator.
public IContainerGenerator<RadDiagramItem> ContainerGenerator { get; }
Gets or sets the data source of the RadDiagram.
public object DataSource { get; set; }
Gets the default size of the RadDiagram control.
protected override Size DefaultSize { get; }
A Size object representing the default size of the control.
Overrides:
public RadDiagramElement DiagramElement { get; set; }
Gets or sets the display member path.
public string DisplayMemberPath { get; set; }
The display member path.
Gets or sets the graph source.
public IGraphSource GraphSource { get; set; }
The graph source.
Gets the group collection.
[Browsable(false)]
public IEnumerable<IGroup> Groups { get; }
public ScrollBarVisibility HorizontalScrollbarVisibility { get; set; }
Gets or sets whether the background grid is visible.
public bool IsBackgroundSurfaceVisible { get; set; }
Gets or sets a value indicating whether manipulation on the connectors is enabled.
public bool IsConnectorsManipulationEnabled { get; set; }
True if manipulation on connectors is enabled; otherwise, false.
Gets a value indicating whether this instance is data bound.
[Browsable(false)]
public bool IsDataBound { get; }
true if this instance is data bound; otherwise, false.
Gets or sets a value indicating whether dragging is enabled.
public bool IsDraggingEnabled { get; set; }
True if dragging is enabled; otherwise, false.
Gets or sets a value indicating whether editing is enabled.
public bool IsEditable { get; set; }
True if editing is enabled; otherwise, false.
Gets or sets whether the information adorner is visible.
public bool IsInformationAdornerVisible { get; set; }
Gets or sets a value indicating whether the manipulation adorner is visible.
public bool IsManipulationAdornerVisible { get; set; }
True if the manipulation adorner is visible; otherwise, false.
Gets or sets a value indicating whether the mouse is captured.
public bool IsMouseCaptured { get; set; }
True if the mouse is captured; otherwise, false.
Gets or sets a value indicating whether panning is enabled.
public bool IsPanEnabled { get; set; }
True if panning is enabled; otherwise, false.
Gets or sets a value indicating whether resizing is enabled.
public bool IsResizingEnabled { get; set; }
True if resizing is enabled; otherwise, false.
Gets or sets a value indicating whether rotation is enabled.
public bool IsRotationEnabled { get; set; }
true if this rotation is enabled; otherwise, false.
Hide or Show the Settings pane button.
public bool IsSettingsPaneEnabled { get; set; }
Gets or sets a value indicating whether grid snapping is enabled.
public bool IsSnapToGridEnabled { get; set; }
True if grid snapping is enabled; otherwise, false.
Gets or sets a value indicating whether snapping of selected item(s) to the other items in the view port is enabled or not.
public bool IsSnapToItemsEnabled { get; set; }
Gets or sets a value indicating whether zooming is enabled.
public bool IsZoomEnabled { get; set; }
True if zooming is enabled; otherwise, false.
Gets or sets the diagramming items.
[Browsable(false)]
public DiagramItemCollection Items { get; }
The items.
Gets the diagram metadata.
[Browsable(false)]
public DiagramMetadata Metadata { get; }
Gets or sets the position.
public Point Position { get; set; }
; The position.
Gets or sets the rectangle selection mode.
public RectSelectionMode RectSelectionMode { get; set; }
public IRoutingService RoutingService { get; }
Gets or sets the index of the first item in the current selection or returns negative one (-1) if the selection is empty.
public int SelectedIndex { get; set; }
Gets or sets the first item in the current selection or returns null if the selection is empty. This is a dependency property.
public object SelectedItem { get; set; }
SelectedItems
IEnumerable<IDiagramItem>
Gets the selected items.
public IEnumerable<IDiagramItem> SelectedItems { get; }
Gets the starting selection bounds.
public Rect SelectionBounds { get; }
Gets or sets the selection mode.
public SelectionMode SelectionMode { get; set; }
public string SerializedXml { get; set; }
Gets the service locator.
public IServiceLocator ServiceLocator { get; }
Gets or sets the links data member.
[Browsable(true)]
public string ShapeDataMember { get; set; }
The data member.
Gets or sets the Shape height data member.
[Browsable(true)]
public string ShapeHeightMember { get; set; }
The data member.
Gets or sets the ID data member.
[Browsable(true)]
public string ShapeIdMember { get; set; }
The data member.
Gets the shapes.
[Browsable(false)]
public ShapeCollection Shapes { get; }
Gets or sets the links data member.
[Browsable(true)]
public string ShapeTextMember { get; set; }
The data member.
Gets or sets the Shape data member.
[Browsable(true)]
public string ShapeTypeMember { get; set; }
The data member.
Gets or sets the Shape height data member.
[Browsable(true)]
public string ShapeWidthMember { get; set; }
The data member.
Gets or sets the Shape X position data member.
[Browsable(true)]
public string ShapeXMember { get; set; }
The data member.
Gets or sets the Shape Y position data member.
[Browsable(true)]
public string ShapeYMember { get; set; }
The data member.
Gets or sets the horizontal snapping distance.
public int SnapX { get; set; }
The horizontal snapping distance.
Gets or sets the vertical snapping distance.
public int SnapY { get; set; }
The vertical snapping distance.
Gets the undo redo service.
public IUndoRedoService UndoRedoService { get; }
public ScrollBarVisibility VerticalScrollbarVisibility { get; set; }
Gets or sets the zoom. A zoom value of 1 means 100% and less then 1 means a zoom out. Zoom value will be coerced to be greater than zero, not infinity and not Nan. In addition, Zoom value will be coerced to be greater or equal than MinimumZoom and smaller or equal than MaximumZoom.
public double Zoom { get; set; }
Methods
Adds a new connection to the diagram.
public IConnection AddConnection(IConnection connection, bool isUndoable = false)
The connection to be added.
isUndoableboolIf set to true this action will be recorded in the undo stack.
Adds a new connection to the diagram connecting the given source and target shapes.
Adds a new connection to the diagram connecting the given source and target shapes.
public IConnection AddConnection(IShape source, IShape target, string connectorsPosition, bool isUndoable = false)
The source or start shape of the connection.
targetIShapeThe target or end shape of the connection.
connectorsPositionstringThe connectors position.
isUndoableboolIf set to true this action will be recorded in the undo stack.
Adds a new connection to the diagram connecting the given source and target shapes.
public IConnection AddConnection(IShape source, IShape target, string sourceConnector, string targetConnector, bool isUndoable = false)
The source.
targetIShapeThe target.
sourceConnectorstringThe source connector position.
targetConnectorstringThe target connector position.
isUndoableboolIf set to true is undoable.
Adds a floating connection.
public IConnection AddConnection(Point startPoint, Point endPoint, bool isUndoable = false)
The source (starting) point of the connection.
endPointPointThe target (end) point of the connection.
isUndoableboolTrue, if this action is undoable.
Returns:Returns the added connection.
Adds a new gliding connection to the diagram connecting the given source and target shapes.
public IConnection AddGlidingConnection(IShape source, IShape target, bool isUndoable = false)
The source or start shape of the connection.
targetIShapeThe target or end shape of the connection.
isUndoableboolIf set to true this action will be recorded in the undo stack.
If the shape already contains connections on the default connectors this will raise an exception since gliding connections are mutually exclusive with normal connections. Remove first the existing connections on the source and target shapes before calling this method.
Adds the given shape to the diagram.
Adds a new shape to the diagram.
public IShape AddShape(object content, Geometry geometry = null, Point? position = null, bool isUndoable = false)
The content of the shape.
geometryGeometryThe geometry.
positionPoint?The position.
isUndoableboolIf set to true the action is undoable.
The added shape.
The given object will be inserted as the content of a new RadDiagramShape and will internally uniquely identify the shape. Alternatively, you can instantiate a new shape and use this same AddShape method to add it to the diagram, in which case the shape rather than the content will uniquely identify it internally.
Begins a batch transformation and signals the undo-redo stack that a batch of transformation should be considered as one, i.e. a composite change.
Suspends layout operations during initialization of the diagram control. Prevents unnecessary updates while multiple properties are being set.
public override void BeginInit()
Overrides:
Called when the printing begins.
public int BeginPrint(RadPrintDocument sender, PrintEventArgs args)
The that has initiated the printing.
The event args.
Returns:The number of pages.
Implements:
Brings the items forward.
public void BringForward(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Brings the items to front.
public void BringToFront(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Clears the diagram and resets the document.
public void Clear()
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.
Commits the batch transformation and ends the composite undo redo change.
public void CommitBatchTransformation(DiagramLayoutState initialState, DiagramLayoutState finalState, bool animate = false, bool execute = true, LayoutType type = LayoutType.Sugiyama, object settings = null)
The initial state.
finalStateDiagramLayoutStateThe final state.
animateboolIf set to true the layout will be animated.
Whether the undo-redo unit is only added or also executed.
typeLayoutTypeThe layout type that has been applied.
settingsobjectThe layout specific settings used for the layout.
The animation tremendously decreases the performance.
Copies the currently selected items of the diagram.
public void Copy()
Creates and initializes the child elements of the RadDiagram control. Initializes and adds the diagram element to the control's element tree.
protected override void CreateChildItems(RadElement parent)
The parent element that contains the child items.
Overrides:
Creates a new instance of the RadDiagramElement class that will be used as the main visual element of the diagram control.
protected virtual RadDiagramElement CreateDiagramElement()
A new instance of RadDiagramElement.
Cuts the currently selected items of the diagram.
public void Cut()
Deletes the currently selected items of the diagram.
public virtual void Delete()
Deselects all shapes in the diagram.
public void DeselectAll()
Deserializes the specified info.
public virtual void Deserialize(SerializationInfo info)
The info.
Resumes layout operations after initialization of the diagram control. Updates the diagram element and applies any pending changes.
public override void EndInit()
Overrides:
Called when the printing ends.
public bool EndPrint(RadPrintDocument sender, PrintEventArgs args)
The that has initiated the printing.
The event args.
Returns:[false] if cancel
Implements:
Exports RadDiagram to Image
Refreshes ScrollBars and Background grids
public void ForceRefresh()
Gets a print settings dialog that is specific for the printable object.
public Form GetSettingsDialog(RadPrintDocument document)
The that has initiated the printing.
The dialog.
Implements:
Groups the specified items.
public IGroup Group(string groupName = null, bool isUndoable = false, params IGroupable[] items)
Name of the new group.
isUndoableboolIf set to true the action will be recorded as undoable.
The groups items to ungroup.
Returns:Groups the specified items.
public IGroup Group(string groupName = null, params IGroupable[] items)
Name of the new group.
itemsIGroupable[]The groups items to ungroup.
Returns:Determines whether the specified key is an input key or a regular key for the control. Enables arrow keys and shift+arrow key combinations to be handled by the control.
Checks if the diagram item is in the viewport.
Organizes the diagram using the specified layout asynchronously.
public void LayoutAsync(LayoutType type = LayoutType.Sugiyama, object settings = null)
The layout type to apply.
settingsobjectThe settings specific to the layout type.
Loads the specified serialization string.
public void Load(string serializationValue)
The serialization value.
Load Diagram to XML file
Raises the BindingContextChanged event and updates the diagram element's binding context. Ensures that binding context changes are propagated to child elements.
Raises the KeyDown event and processes keyboard input for the diagram. Forwards key events to the diagram element for handling, unless a text editor is active.
protected override void OnKeyDown(KeyEventArgs e)
A KeyEventArgs that contains the event data.
Overrides:
Raises the MouseDown event and handles mouse down interactions for the diagram. Delegates mouse handling to the diagram element's input behavior system.
protected override void OnMouseDown(MouseEventArgs e)
A MouseEventArgs that contains the event data.
Overrides:
Raises the MouseMove event and handles mouse movement interactions for the diagram. Delegates mouse movement handling to the diagram element's input behavior system.
protected override void OnMouseMove(MouseEventArgs e)
A MouseEventArgs that contains the event data.
Overrides:
Raises the MouseUp event and handles mouse release interactions for the diagram. Delegates mouse up handling to the diagram element's input behavior system.
protected override void OnMouseUp(MouseEventArgs e)
A MouseEventArgs that contains the event data.
Overrides:
Raises the paint background event and handles special drawing requirements. Detects changes in the clipping rectangle and triggers a redraw when necessary.
protected override void OnPaintBackground(PaintEventArgs e)
A PaintEventArgs that contains the event data.
Overrides:
Raises the VisibleChanged event and performs necessary updates when visibility changes. Refreshes the diagram when the control becomes visible.
Pans the diagram to the provided position. The values are interpreted in the zoomed coordinate system. This means that panning with 100 pixel will result in visual translation with 100 pixel.
public virtual void PanToPosition(Point newPosition)
The new position coordinates to pan the diagram to.
Pastes the content of the clipboard onto the diagram.
public virtual void Paste()
Directly prints the RadDiagram to the default printer.
public virtual void Print()
Directly prints the RadDiagram to the default printer or shows printer settings and then prints the RadDiagram.
public virtual void Print(bool showPrinterSettings, RadPrintDocument document)
Indicates whether printer settings dialog should be shown.
documentRadPrintDocumentAs instance of RadPrintDocument used to control the print process.
Directly prints the RadDiagram to the default printer or shows printer settings and then prints the RadDiagram.
public virtual void Print(bool showPrinterSettings)
Indicates whether printer settings dialog should be shown.
Prints the page with the specified number.
public bool PrintPage(int pageNumber, RadPrintDocument sender, PrintPageEventArgs args)
The number of the current page.
senderRadPrintDocumentThe that has initiated the printing.
The event args.
Returns:[true] if there are more pages, [false] otherwise
Implements:
Shows a RadPrintPreviewDialog for editing print settings.
public virtual void PrintPreview()
Shows a RadPrintPreviewDialog for editing print settings.
public virtual void PrintPreview(RadPrintDocument document)
As instance of RadPrintDocument used to control the print process.
Overrides the base implementation of ProcessAutoSizeChanged. This method is intentionally empty as RadDiagram does not support auto-sizing.
protected override void ProcessAutoSizeChanged(bool value)
A boolean value indicating whether auto-size is enabled.
Overrides:
Performs redo on the last undone action.
public void Redo()
Removes the connection.
public void RemoveConnection(IConnection connection, bool isUndoable = false)
The connection.
isUndoableboolIf set to true the action is undoable.
Save Diagram to XML file
Selects all shapes in the diagram.
public void SelectAll()
Sends the items backward.
public void SendBackward(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Sends the items to back.
public void SendToBack(IEnumerable<IDiagramItem> items, bool isUndoable = true)
Serializes this instance.
Organizes the diagram using the specified layout.
public void SetLayout(LayoutType type = LayoutType.Sugiyama, object settings = null)
The layout type to apply.
settingsobjectThe settings specific to the layout type.
Snaps the specified shapes.
Performs undo on the last action.
public void Undo()
Ungroups the specified items.
public void Ungroup(params IGroup[] groups)
The groups items to ungroup.
Zooms in the diagram. Simulates zooming with the mouse. Performs incremental zoom taking into account previous zoom operations.
public virtual void ZoomIn(double? factor = null, Point? targetPoint = null)
The value by which to change Zoom property. When factor is null, smaller or equal to zero the ZoomScaleFactor value will be used.
targetPointPoint?The center of the zoom. The point should be provided in viewport coordinates.
Zooms out the diagram. Simulates zooming with the mouse. Performs incremental zoom taking into account previous zoom operations.
public virtual void ZoomOut(double? factor = null, Point? targetPoint = null)
The value by which to change Zoom property. When factor is null, smaller or equal to zero the ZoomScaleFactor value will be used.
targetPointPoint?The center of the zoom. The point should be provided in viewport coordinates.
Events
Occurs when AdditionContent is activated.
public event EventHandler<AdditionalContentActivatedEventArgs> AdditionalContentActivated
Occurs when a async command is executed.
public event EventHandler<CommandEventArgs> CommandExecuted
Occurs when a connection is added.
public event EventHandler<GenericEventArgs<IConnection>> ConnectionAdded
Occurs when the connection is being added.
public event EventHandler<GenericEventArgs<IConnection>> ConnectionAdding
Occurs when connection is clicked.
public event EventHandler<GenericEventArgs<IConnection>> ConnectionClicked
Occurs when a connection has been deserialized.
public event EventHandler<SerializationEventArgs<IConnection>> ConnectionDeserialized
This event allows you to recover additional, application specific data from the serialization.
Occurs when the connection manipulation has completed.
public event EventHandler<ManipulationEventArgs> ConnectionManipulationCompleted
Occurs before the connection manipulation has started.
public event EventHandler<ManipulationEventArgs> ConnectionManipulationStarted
Occurs when a connection has been serialized.
public event EventHandler<SerializationEventArgs<IConnection>> ConnectionSerialized
This event allows you to add additional, application specific data to the serialization.
Occurs after a connector activation or deactivation.
public event EventHandler<ConnectorActivationChangedEventArgs> ConnectorActivationChanged
Occurs when the diagram has been deserialized.
public event RoutedEventHandler Deserialized
Occurs when the diagram layout has completed.
public event EventHandler<DiagramLayoutEventArgs> DiagramLayoutComplete
Occurs when an item is dragged.
public event EventHandler<DragRoutedEventArgs> Drag
Occurs when the graph source has changed.
public event EventHandler GraphSourceChanged
Occurs when the graph source begins changing.
public event EventHandler GraphSourceChanging
Occurs after an Item is databound.
public event DiagramItemDataBindingEventHandler ItemDataBound
Occurs when count of the items change.
public event EventHandler<DiagramItemsChangedEventArgs> ItemsChanged
Occurs while the diagram items are changing.
public event EventHandler<DiagramItemsChangingEventArgs> ItemsChanging
Occurs when the diagram's metadata has been deserialized.
public event EventHandler<SerializationInfoEventArgs> MetadataDeserialized
The event allows you to deserialize the additional data added, if any, using the MetadataDeserialized event handler.
Occurs when the diagram's metadata has been serialized.
public event EventHandler<SerializationInfoEventArgs> MetadataSerialized
This event allows you to add additional, application specific data to the serialization.
Occurs after the diagram is panned.
public event EventHandler<PositionChangedRoutedEventArgs> Pan
Occurs when the position has changed.
public event EventHandler<PositionChangedEventArgs> PositionChanged
Occurs when AdditionContent is about to be activated.
public event EventHandler<AdditionalContentActivatedEventArgs> PreviewAdditionalContentActivated
Occurs before an item is dragged.
public event EventHandler<DragRoutedEventArgs> PreviewDrag
Occurs before the diagram is panned.
public event EventHandler<PositionChangedRoutedEventArgs> PreviewPan
Occurs before an item is resized.
public event EventHandler<ResizeRoutedEventArgs> PreviewResize
Occurs before an item is rotated.
public event EventHandler<RoutedEventArgs> PreviewRotate
Occurs when the selection of the diagram starts changing.
public event EventHandler PreviewSelectionChanged
Occurs before the zoom has been changed.
public event EventHandler<DiagramZoomEventArgs> PreviewZoom
Occurs when an item is resized.
public event EventHandler<ResizingEventArgs> Resize
Occurs when an item is rotated.
public event EventHandler<RotateRoutedEventArgs> Rotate
public event EventHandler SelectionBoundsChanged
Occurs when the selection of the diagram changes.
public event EventHandler SelectionChanged
Occurs after the diagram has been serialized.
public event RoutedEventHandler Serialized
Occurs when shape is clicked.
public event EventHandler<ShapeRoutedEventArgs> ShapeClicked
Occurs when a shape has been deserialized.
public event EventHandler<SerializationEventArgs<IShape>> ShapeDeserialized
The event allows you to deserialize the additional data added, if any, using the ShapeSerialized event handler.
Occurs when a shape has been double-clicked.
public event EventHandler<ShapeRoutedEventArgs> ShapeDoubleClicked
Occurs when a shape has been serialized.
public event EventHandler<SerializationEventArgs<IShape>> ShapeSerialized
This event allows you to add additional, application specific data to the serialization.
Occurs when the zoom has been changed.
public event EventHandler<DiagramZoomEventArgs> ZoomChanged