DiagramEditorControl

StockSharp.Xaml.Diagram.Avalonia.Controls

Avalonia diagram editor control with toolbar and keyboard shortcuts.

继承自: UserControl

构造函数

DiagramEditorControl()

Initializes a new instance of the DiagramEditorControl.

属性

CanPaste : bool

Whether paste is available.

CanRedo : bool

Whether redo is available.

CanUndo : bool

Whether undo is available.

Composition : CompositionDiagramElement

The composition element being edited.

IsEditing : bool

Whether editing is enabled.

Panel : DiagramPanel

The diagram panel.

SelectedElement : DiagramElement

Selected element.

SelectedNodeKey : string

Selected node key.

ShowToolbar : bool

Whether to show the toolbar.

Zoom : double

Current zoom level.

方法

AddElement(DiagramElement)

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

element
The element to add.
AddElementAt(DiagramElement, double, double)

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()

Clear all elements from the diagram.

ConnectPalette(DiagramPaletteControl)

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

palette
The palette control to connect.
Copy()

Copy selected elements to clipboard.

Cut()

Cut selected elements to clipboard.

Delete()

Delete selected elements.

DisconnectPalette(DiagramPaletteControl)

Disconnects a palette control from this editor.

palette
The palette control to disconnect.
ExportToImage(string, ExportOptions)

Export the diagram to an image file.

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

Export the diagram to a byte array.

options
Export options. If null, uses defaults.

返回值: The image data as bytes, or null if export failed.

ExportToImageStream(Stream, ExportOptions)

Export the diagram to an image stream.

stream
The output stream.
options
Export options. If null, uses defaults.
HandleDrop(DragEventArgs)

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

HandlePaletteDrop(PaletteItem, Point) : DiagramElement

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).

返回值: The created element, or null if creation failed.

LoadFromFile(string) : DiagramFileData

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.

返回值: Diagram file data, or null if invalid.

LoadFromStream(Stream) : DiagramFileData

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.

返回值: Diagram file data, or null if invalid.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Paste()

Paste elements from clipboard.

Redo()

Redo the last undone operation.

RestoreDiagram(DiagramFileData, ElementFactory) : bool

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.

返回值: True if restore was successful.

RestoreFromFile(string, ElementFactory) : bool

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.

返回值: True if restore was successful.

SaveToFile(string)

Save the diagram to a file.

filePath
The file path to save to.
SaveToStream(Stream)

Save the diagram to a stream.

stream
The stream to write to.
SaveToString() : string

Save the diagram to a JSON string.

返回值: JSON representation of the diagram.

SelectAll()

Select all elements.

Undo()

Undo the last operation.

事件

ModelModified : EventHandler

Occurs when the diagram model is modified.

SelectionChanged : EventHandler<DiagramElement>

Occurs when the selected diagram element changes.

字段

CompositionProperty : StyledProperty<CompositionDiagramElement>

Identifies the Composition dependency property.

IsEditingProperty : StyledProperty<bool>

Identifies the IsEditing dependency property.

ShowToolbarProperty : StyledProperty<bool>

Identifies the ShowToolbar dependency property.