DiagramEditorControl

StockSharp.Xaml.Diagram.Avalonia.Controls

Avalonia diagram editor control with toolbar and keyboard shortcuts.

Inherits: UserControl

Constructors

DiagramEditorControl
public DiagramEditorControl()
diagramEditorControl = DiagramEditorControl()

Initializes a new instance of the DiagramEditorControl.

Properties

CanPaste
public bool CanPaste { get; }
value = diagramEditorControl.CanPaste

Whether paste is available.

CanRedo
public bool CanRedo { get; }
value = diagramEditorControl.CanRedo

Whether redo is available.

CanUndo
public bool CanUndo { get; }
value = diagramEditorControl.CanUndo

Whether undo is available.

Composition
public CompositionDiagramElement Composition { get; set; }
value = diagramEditorControl.Composition
diagramEditorControl.Composition = value

The composition element being edited.

IsEditing
public bool IsEditing { get; set; }
value = diagramEditorControl.IsEditing
diagramEditorControl.IsEditing = value

Whether editing is enabled.

Panel
public DiagramPanel Panel { get; }
value = diagramEditorControl.Panel

The diagram panel.

SelectedElement
public DiagramElement SelectedElement { get; }
value = diagramEditorControl.SelectedElement

Selected element.

SelectedNodeKey
public string SelectedNodeKey { get; }
value = diagramEditorControl.SelectedNodeKey

Selected node key.

ShowToolbar
public bool ShowToolbar { get; set; }
value = diagramEditorControl.ShowToolbar
diagramEditorControl.ShowToolbar = value

Whether to show the toolbar.

Zoom
public double Zoom { get; set; }
value = diagramEditorControl.Zoom
diagramEditorControl.Zoom = value

Current zoom level.

Methods

AddElement
public void AddElement(DiagramElement element)
diagramEditorControl.AddElement(element)

Adds an element to the diagram at default position (0, 0).

element
The element to add.
AddElementAt
public void AddElementAt(DiagramElement element, double x, double y)
diagramEditorControl.AddElementAt(element, x, y)

Adds an element to the diagram at specified position.

element
The element to add.
x
X position on canvas (diagram coordinates).
y
Y position on canvas (diagram coordinates).
ClearDiagram
public void ClearDiagram()
diagramEditorControl.ClearDiagram()

Clear all elements from the diagram.

ConnectPalette
public void ConnectPalette(DiagramPaletteControl palette)
diagramEditorControl.ConnectPalette(palette)

Connects a palette control to this editor for drag-drop support.

palette
The palette control to connect.
Copy
public void Copy()
diagramEditorControl.Copy()

Copy selected elements to clipboard.

Cut
public void Cut()
diagramEditorControl.Cut()

Cut selected elements to clipboard.

Delete
public void Delete()
diagramEditorControl.Delete()

Delete selected elements.

DisconnectPalette
public void DisconnectPalette(DiagramPaletteControl palette)
diagramEditorControl.DisconnectPalette(palette)

Disconnects a palette control from this editor.

palette
The palette control to disconnect.
ExportToImage
public void ExportToImage(string filePath, ExportOptions options)
diagramEditorControl.ExportToImage(filePath, options)

Export the diagram to an image file.

filePath
The output file path.
options
Export options. If null, uses defaults.
ExportToImageBytes
public byte[] ExportToImageBytes(ExportOptions options)
result = diagramEditorControl.ExportToImageBytes(options)

Export the diagram to a byte array.

options
Export options. If null, uses defaults.

Returns: The image data as bytes, or null if export failed.

ExportToImageStream
public void ExportToImageStream(Stream stream, ExportOptions options)
diagramEditorControl.ExportToImageStream(stream, options)

Export the diagram to an image stream.

stream
The output stream.
options
Export options. If null, uses defaults.
HandleDrop
public void HandleDrop(DragEventArgs e)
diagramEditorControl.HandleDrop(e)

Handle drop event on the panel. Call this from DragOver/Drop events.

HandlePaletteDrop
public DiagramElement HandlePaletteDrop(PaletteItem item, Point dropPosition)
result = diagramEditorControl.HandlePaletteDrop(item, dropPosition)

Handles drag events from a palette control. Call this from the palette's DragStarted event handler.

item
The palette item being dragged.
dropPosition
The position on the panel where the item was dropped (screen coordinates).

Returns: The created element, or null if creation failed.

LoadFromFile
public static DiagramFileData LoadFromFile(string filePath)
result = DiagramEditorControl.LoadFromFile(filePath)

Load diagram data from a file. Note: This only returns the data structure. Use composition loading for full restore.

filePath
The file path to load from.

Returns: Diagram file data, or null if invalid.

LoadFromStream
public static DiagramFileData LoadFromStream(Stream stream)
result = DiagramEditorControl.LoadFromStream(stream)

Load diagram data from a stream. Note: This only returns the data structure. Use composition loading for full restore.

stream
The stream to read from.

Returns: Diagram file data, or null if invalid.

OnPropertyChanged
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
diagramEditorControl.OnPropertyChanged(change)
Paste
public void Paste()
diagramEditorControl.Paste()

Paste elements from clipboard.

Redo
public void Redo()
diagramEditorControl.Redo()

Redo the last undone operation.

RestoreDiagram
public bool RestoreDiagram(DiagramFileData data, ElementFactory elementFactory)
result = diagramEditorControl.RestoreDiagram(data, elementFactory)

Restore a diagram from file data into the current composition.

data
The file data to restore from.
elementFactory
Optional factory for creating elements by type.

Returns: True if restore was successful.

RestoreFromFile
public bool RestoreFromFile(string filePath, ElementFactory elementFactory)
result = diagramEditorControl.RestoreFromFile(filePath, elementFactory)

Restore a diagram from a file into the current composition.

filePath
The file path to restore from.
elementFactory
Optional factory for creating elements by type.

Returns: True if restore was successful.

SaveToFile
public void SaveToFile(string filePath)
diagramEditorControl.SaveToFile(filePath)

Save the diagram to a file.

filePath
The file path to save to.
SaveToStream
public void SaveToStream(Stream stream)
diagramEditorControl.SaveToStream(stream)

Save the diagram to a stream.

stream
The stream to write to.
SaveToString
public string SaveToString()
result = diagramEditorControl.SaveToString()

Save the diagram to a JSON string.

Returns: JSON representation of the diagram.

SelectAll
public void SelectAll()
diagramEditorControl.SelectAll()

Select all elements.

Undo
public void Undo()
diagramEditorControl.Undo()

Undo the last operation.

Events

ModelModified
public event EventHandler ModelModified
diagramEditorControl.ModelModified += handler

Occurs when the diagram model is modified.

SelectionChanged
public event EventHandler<DiagramElement> SelectionChanged
diagramEditorControl.SelectionChanged += handler

Occurs when the selected diagram element changes.

Fields

CompositionProperty
public static readonly StyledProperty<CompositionDiagramElement> CompositionProperty
value = DiagramEditorControl.CompositionProperty

Identifies the Composition dependency property.

IsEditingProperty
public static readonly StyledProperty<bool> IsEditingProperty
value = DiagramEditorControl.IsEditingProperty

Identifies the IsEditing dependency property.

ShowToolbarProperty
public static readonly StyledProperty<bool> ShowToolbarProperty
value = DiagramEditorControl.ShowToolbarProperty

Identifies the ShowToolbar dependency property.