DiagramEditorControl
Avalonia diagram editor control with toolbar and keyboard shortcuts.
Erbt von: UserControl
Implementiert: IAsyncPersistable, IUndoRedoManager, IDisposable
Konstruktoren
public DiagramEditorControl()
diagramEditorControl = DiagramEditorControl()
Initializes a new instance of the DiagramEditorControl.
Eigenschaften
public bool CanPaste { get; }
value = diagramEditorControl.CanPaste
Gets whether canonical diagram data is available for paste.
public bool CanRedo { get; }
value = diagramEditorControl.CanRedo
Gets whether redo is available.
public bool CanUndo { get; }
value = diagramEditorControl.CanUndo
Gets whether undo is available.
public CompositionDiagramElement Composition { get; set; }
value = diagramEditorControl.Composition
diagramEditorControl.Composition = value
The composition element being edited.
public IDictionary<Type, IDoubleClickHandler> DoubleClickHandlers { get; }
value = diagramEditorControl.DoubleClickHandlers
Gets the element-specific double-click handlers.
internal ICompositionModel DrawnModel { get; }
value = diagramEditorControl.DrawnModel
The graph the surface is drawing, or when it draws nothing.
public ICommand HelpCommand { get; set; }
value = diagramEditorControl.HelpCommand
diagramEditorControl.HelpCommand = value
Gets or sets the host command that opens element help.
public bool IsEditing { get; set; }
value = diagramEditorControl.IsEditing
diagramEditorControl.IsEditing = value
Whether editing is enabled.
public bool IsEncrypted { get; set; }
value = diagramEditorControl.IsEncrypted
diagramEditorControl.IsEncrypted = value
Gets or sets whether the encrypted-content overlay is visible.
public bool IsReadOnly { get; set; }
value = diagramEditorControl.IsReadOnly
diagramEditorControl.IsReadOnly = value
Gets or sets whether model mutations are disabled.
public ICommand OpenElementCommand { get; set; }
value = diagramEditorControl.OpenElementCommand
diagramEditorControl.OpenElementCommand = value
Gets or sets the host command that opens the selected element.
public ICommand OpenPropertiesCommand { get; set; }
value = diagramEditorControl.OpenPropertiesCommand
diagramEditorControl.OpenPropertiesCommand = value
Gets or sets the host command that opens element properties.
public static DataFormat<PaletteItem> PaletteItemDataFormat { get; }
value = DiagramEditorControl.PaletteItemDataFormat
Gets the in-process drag-and-drop format used for palette items.
public DiagramPanel Panel { get; }
value = diagramEditorControl.Panel
Gets the diagram panel compatibility facade.
public ICommand RedoCommand { get; set; }
value = diagramEditorControl.RedoCommand
diagramEditorControl.RedoCommand = value
Gets or sets the redo command.
public ICompositionRegistry Registry { get; set; }
value = diagramEditorControl.Registry
diagramEditorControl.Registry = value
Gets or sets the registry used for canonical serialization and clipboard operations.
public ICommand RemoveCommand { get; set; }
value = diagramEditorControl.RemoveCommand
diagramEditorControl.RemoveCommand = value
Gets or sets the command that removes the context object.
public double Scale { get; set; }
value = diagramEditorControl.Scale
diagramEditorControl.Scale = value
Gets or sets the viewport scale.
public DiagramElement SelectedElement { get; set; }
value = diagramEditorControl.SelectedElement
diagramEditorControl.SelectedElement = value
Gets or sets the primary selected element.
public IReadOnlyList<DiagramElement> SelectedElements { get; set; }
value = diagramEditorControl.SelectedElements
diagramEditorControl.SelectedElements = value
Gets or sets the selected elements.
public string SelectedNodeKey { get; }
value = diagramEditorControl.SelectedNodeKey
Gets the selected node key.
public bool ShowGrid { get; set; }
value = diagramEditorControl.ShowGrid
diagramEditorControl.ShowGrid = value
Gets or sets whether the diagram grid is visible.
public bool ShowOverview { get; set; }
value = diagramEditorControl.ShowOverview
diagramEditorControl.ShowOverview = value
Gets or sets whether the diagram overview is visible.
public bool ShowToolbar { get; set; }
value = diagramEditorControl.ShowToolbar
diagramEditorControl.ShowToolbar = value
Whether to show the toolbar.
public bool SnapToGrid { get; set; }
value = diagramEditorControl.SnapToGrid
diagramEditorControl.SnapToGrid = value
Gets or sets whether moves snap to the grid.
public ICommand UndoCommand { get; set; }
value = diagramEditorControl.UndoCommand
diagramEditorControl.UndoCommand = value
Gets or sets the undo command.
public double Zoom { get; set; }
value = diagramEditorControl.Zoom
diagramEditorControl.Zoom = value
Gets or sets the current zoom level.
Methoden
public void AddElement(DiagramElement element)
diagramEditorControl.AddElement(element)
Adds an element at the default diagram position.
- element
- Element.
public void AddElementAt(DiagramElement element, double x, double y)
diagramEditorControl.AddElementAt(element, x, y)
Adds an element at the specified diagram position.
- element
- Element.
- x
- Diagram X coordinate.
- y
- Diagram Y coordinate.
private void ApplyModel()
diagramEditorControl.ApplyModel()
Hands the panel the graph to draw. Composition can become null (e.g. switching to a code configuration, or panel teardown); the panel renders nothing for a null model. An encrypted schema is withheld as well - the overlay says it cannot be shown, and drawing it underneath would be showing what the overlay says is hidden.
public bool CanAcceptPaletteDrop(PaletteItem item)
result = diagramEditorControl.CanAcceptPaletteDrop(item)
Gets whether an item can currently be dropped into the editor.
- item
- Palette item.
Rückgabe: when the item represents an element and the model is editable.
public void ClearDiagram()
diagramEditorControl.ClearDiagram()
Clears all nodes and connected links.
public void ClearSelection()
diagramEditorControl.ClearSelection()
Clears node and socket selection.
public void ConnectPalette(DiagramPaletteControl palette)
diagramEditorControl.ConnectPalette(palette)
Connects a palette to this editor.
- palette
- Palette control.
public Task CopyAsync(CancellationToken cancellationToken)
result = diagramEditorControl.CopyAsync(cancellationToken)
Copies selected elements to the system clipboard.
- cancellationToken
- CancellationToken
Rückgabe: Task
public Task CutAsync(CancellationToken cancellationToken)
result = diagramEditorControl.CutAsync(cancellationToken)
Cuts selected elements to the system clipboard.
- cancellationToken
- CancellationToken
Rückgabe: Task
public void DisconnectPalette(DiagramPaletteControl palette)
diagramEditorControl.DisconnectPalette(palette)
Disconnects a palette from this editor.
- palette
- Palette control.
public void Dispose()
diagramEditorControl.Dispose()
Disposes of items in the pool that implement IDisposable.
public void ExportToImage(string filePath, DiagramImageExportOptions options)
diagramEditorControl.ExportToImage(filePath, options)
Exports the diagram to an image file.
- filePath
- Output file path.
- options
- Export options.
public byte[] ExportToImageBytes(DiagramImageExportOptions options)
result = diagramEditorControl.ExportToImageBytes(options)
Exports the diagram to a byte array.
- options
- Export options.
Rückgabe: PNG image data, or when no model is loaded.
public void ExportToImageStream(Stream stream, DiagramImageExportOptions options)
diagramEditorControl.ExportToImageStream(stream, options)
Exports the diagram to an image stream.
- stream
- Output stream.
- options
- Export options.
public void FitToView()
diagramEditorControl.FitToView()
Fits every cube into the current viewport.
public Task<CompositionDiagramElement> GetSelectionCopyElementAsync(CancellationToken cancellationToken)
result = diagramEditorControl.GetSelectionCopyElementAsync(cancellationToken)
Creates a detached composition containing the selected elements and their internal links.
- cancellationToken
- CancellationToken
Rückgabe: The selected composition fragment, or when no registry or composition is available.
public Task HandleDropAsync(DragEventArgs e, CancellationToken cancellationToken)
result = diagramEditorControl.HandleDropAsync(e, cancellationToken)
Handles a native Avalonia drop event.
- e
- Drop event.
- cancellationToken
- CancellationToken
Rückgabe: Task
public Task<DiagramElement> HandlePaletteDropAsync(PaletteItem item, Point dropPosition, CancellationToken cancellationToken)
result = diagramEditorControl.HandlePaletteDropAsync(item, dropPosition, cancellationToken)
Creates a palette element at the supplied panel position.
- item
- Palette item.
- dropPosition
- Panel-space drop position.
- cancellationToken
- CancellationToken
Rückgabe: Created element, or .
public Task LoadAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = diagramEditorControl.LoadAsync(storage, cancellationToken)
Asynchronously loads the state of the object from the specified SettingsStorage.
- storage
- The SettingsStorage instance from which to load the data.
- cancellationToken
- A token to monitor for cancellation requests.
Rückgabe: A task that represents the asynchronous load operation.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
diagramEditorControl.OnPropertyChanged(change)
public Task PasteAsync(CancellationToken cancellationToken)
result = diagramEditorControl.PasteAsync(cancellationToken)
Pastes elements from the system clipboard.
- cancellationToken
- CancellationToken
Rückgabe: Task
public Task ProcessElementDoubleClickAsync(DiagramElement element)
result = diagramEditorControl.ProcessElementDoubleClickAsync(element)
Processes a diagram element double click through its specialized or host handler.
- element
- The activated element.
Rückgabe: Task
public void ResetView()
diagramEditorControl.ResetView()
Restores the default scale and centers the diagram.
public Task<bool> RestoreFromFileAsync(string filePath, CancellationToken cancellationToken)
result = diagramEditorControl.RestoreFromFileAsync(filePath, cancellationToken)
Restores a canonical file into the current composition.
- filePath
- Source file.
- cancellationToken
- CancellationToken
Rückgabe: when restore succeeds.
public Task<bool> RestoreFromStreamAsync(Stream stream, CancellationToken cancellationToken)
result = diagramEditorControl.RestoreFromStreamAsync(stream, cancellationToken)
Restores a canonical stream into the current composition.
- stream
- Source stream.
- cancellationToken
- CancellationToken
Rückgabe: when restore succeeds.
public Task<bool> RestoreFromStringAsync(string text, CancellationToken cancellationToken)
result = diagramEditorControl.RestoreFromStringAsync(text, cancellationToken)
Restores canonical diagram text into the current composition.
- text
- Canonical serialized diagram.
- cancellationToken
- CancellationToken
Rückgabe: when restore succeeds.
public Task SaveAsync(SettingsStorage storage, CancellationToken cancellationToken)
result = diagramEditorControl.SaveAsync(storage, cancellationToken)
Asynchronously saves the state of the object to the specified SettingsStorage.
- storage
- The SettingsStorage instance to which to save the data.
- cancellationToken
- A token to monitor for cancellation requests.
Rückgabe: A task that represents the asynchronous save operation.
public Task SaveToFileAsync(string filePath, CancellationToken cancellationToken)
result = diagramEditorControl.SaveToFileAsync(filePath, cancellationToken)
Saves the diagram to a canonical registry file.
- filePath
- Destination file.
- cancellationToken
- CancellationToken
Rückgabe: Task
public void SaveToImage(string filePath, DiagramImageExportOptions options)
diagramEditorControl.SaveToImage(filePath, options)
Saves the production diagram presenter tree to a PNG file.
- filePath
- Destination file.
- options
- Export options.
public void SaveToImage(Stream stream)
diagramEditorControl.SaveToImage(stream)
Saves the production diagram presenter tree to a PNG stream.
- stream
- Destination stream.
public Task SaveToStreamAsync(Stream stream, CancellationToken cancellationToken)
result = diagramEditorControl.SaveToStreamAsync(stream, cancellationToken)
Saves the diagram to a stream without closing it.
- stream
- Destination stream.
- cancellationToken
- CancellationToken
Rückgabe: Task
public Task<string> SaveToStringAsync(CancellationToken cancellationToken)
result = diagramEditorControl.SaveToStringAsync(cancellationToken)
Saves the diagram to the canonical registry text format.
- cancellationToken
- CancellationToken
Rückgabe: Canonical serialized diagram.
public void Select(DiagramElement element)
diagramEditorControl.Select(element)
Selects one element and clears the previous selection.
- element
- Element to select, or to clear selection.
Ereignisse
public event EventHandler<DiagramContextMenuBuildingEventArgs> ContextMenuBuilding
diagramEditorControl.ContextMenuBuilding += handler
Occurs before a diagram context menu opens and lets the host append items.
public event EventHandler<DiagramElement> ElementDoubleClicked
diagramEditorControl.ElementDoubleClicked += handler
Occurs when a diagram element is double-clicked.
public event EventHandler<DiagramElement> HelpRequested
diagramEditorControl.HelpRequested += handler
Occurs when the default help command is invoked.
public event EventHandler ModelModified
diagramEditorControl.ModelModified += handler
Occurs when the diagram model is modified.
public event EventHandler<DiagramOperationFailedEventArgs> OperationFailed
diagramEditorControl.OperationFailed += handler
Occurs when a diagram operation cannot complete its platform-side work.
public event EventHandler<DiagramElement> PropertiesRequested
diagramEditorControl.PropertiesRequested += handler
Occurs when the default properties command is invoked.
public event EventHandler<DiagramElement> SelectionChanged
diagramEditorControl.SelectionChanged += handler
Occurs when the selected diagram element changes.
public event EventHandler<DiagramSocketClickedEventArgs> SocketClicked
diagramEditorControl.SocketClicked += handler
Occurs when a diagram socket is activated.
Felder
public static readonly StyledProperty<CompositionDiagramElement> CompositionProperty
value = DiagramEditorControl.CompositionProperty
Identifies the Composition dependency property.
public static readonly StyledProperty<ICommand> HelpCommandProperty
value = DiagramEditorControl.HelpCommandProperty
Identifies the HelpCommand styled property.
public static readonly StyledProperty<bool> IsEditingProperty
value = DiagramEditorControl.IsEditingProperty
Identifies the IsEditing dependency property.
public static readonly StyledProperty<bool> IsEncryptedProperty
value = DiagramEditorControl.IsEncryptedProperty
Identifies the IsEncrypted styled property.
public static readonly StyledProperty<bool> IsReadOnlyProperty
value = DiagramEditorControl.IsReadOnlyProperty
Identifies the IsReadOnly styled property.
public static readonly StyledProperty<ICommand> OpenElementCommandProperty
value = DiagramEditorControl.OpenElementCommandProperty
Identifies the OpenElementCommand styled property.
public static readonly StyledProperty<ICommand> OpenPropertiesCommandProperty
value = DiagramEditorControl.OpenPropertiesCommandProperty
Identifies the OpenPropertiesCommand styled property.
public static readonly StyledProperty<ICommand> RedoCommandProperty
value = DiagramEditorControl.RedoCommandProperty
Identifies the RedoCommand styled property.
public static readonly StyledProperty<ICompositionRegistry> RegistryProperty
value = DiagramEditorControl.RegistryProperty
Identifies the Registry styled property.
public static readonly StyledProperty<ICommand> RemoveCommandProperty
value = DiagramEditorControl.RemoveCommandProperty
Identifies the RemoveCommand styled property.
public static readonly StyledProperty<double> ScaleProperty
value = DiagramEditorControl.ScaleProperty
Identifies the Scale styled property.
public static readonly StyledProperty<DiagramElement> SelectedElementProperty
value = DiagramEditorControl.SelectedElementProperty
Identifies the SelectedElement styled property.
public static readonly StyledProperty<IReadOnlyList<DiagramElement>> SelectedElementsProperty
value = DiagramEditorControl.SelectedElementsProperty
Identifies the SelectedElements styled property.
public static readonly StyledProperty<bool> ShowGridProperty
value = DiagramEditorControl.ShowGridProperty
Identifies the ShowGrid styled property.
public static readonly StyledProperty<bool> ShowOverviewProperty
value = DiagramEditorControl.ShowOverviewProperty
Identifies the ShowOverview styled property.
public static readonly StyledProperty<bool> ShowToolbarProperty
value = DiagramEditorControl.ShowToolbarProperty
Identifies the ShowToolbar dependency property.
public static readonly StyledProperty<bool> SnapToGridProperty
value = DiagramEditorControl.SnapToGridProperty
Identifies the SnapToGrid styled property.
public static readonly StyledProperty<ICommand> UndoCommandProperty
value = DiagramEditorControl.UndoCommandProperty
Identifies the UndoCommand styled property.