DiagramSurface
Hosts diagram presenters and keeps them synchronized with a composition model.
継承元: Panel
実装: IDisposable
コンストラクター
public DiagramSurface()
diagramSurface = DiagramSurface()
Initializes a new instance of the DiagramSurface class.
プロパティ
public bool CanRedo { get; }
value = diagramSurface.CanRedo
Gets whether the most recently undone editor operation can be redone.
public bool CanUndo { get; }
value = diagramSurface.CanUndo
Gets whether the most recent editor operation can be undone.
public Func<IReadOnlyCollection<string>, PointF, CancellationToken, Task> CopyNodes { get; set; }
value = diagramSurface.CopyNodes
diagramSurface.CopyNodes = value
Gets or sets what makes copies of the blocks a drag with the control key lets go of: it is given their keys and how far from them the copies land, in diagram units. Without it the control key does not copy.
public IReadOnlyDictionary<ICompositionModelLink, IReadOnlyList<DiagramRoutePoint>> DrawnLinks { get; }
value = diagramSurface.DrawnLinks
Gets the links this surface last drew, each with the polyline it drew for it.
public DiagramScrollRange HorizontalScroll { get; private set; }
value = diagramSurface.HorizontalScroll
diagramSurface.HorizontalScroll = value
Gets where the view stands across the scheme, in the terms of a scroll bar.
public ICompositionModelLink HoveredLink { get; }
value = diagramSurface.HoveredLink
Gets the link currently under the pointer.
public bool IsEditing { get; set; }
value = diagramSurface.IsEditing
diagramSurface.IsEditing = value
Gets or sets whether model mutation is enabled.
public ICompositionModel Model { get; set; }
value = diagramSurface.Model
diagramSurface.Model = value
Gets or sets the composition model.
public IReadOnlyCollection<DiagramNodePresenter> NodePresenters { get; }
value = diagramSurface.NodePresenters
Gets the current node presenter instances.
public Point PanOffset { get; set; }
value = diagramSurface.PanOffset
diagramSurface.PanOffset = value
Gets or sets the viewport translation.
public double Scale { get; set; }
value = diagramSurface.Scale
diagramSurface.Scale = value
Gets or sets the viewport scale.
public DiagramElement SelectedElement { get; }
value = diagramSurface.SelectedElement
Gets the primary selected diagram element.
public IReadOnlyList<DiagramElement> SelectedElements { get; }
value = diagramSurface.SelectedElements
Gets all selected diagram elements.
public IReadOnlySet<ICompositionModelLink> SelectedLinks { get; }
value = diagramSurface.SelectedLinks
Gets the selected links.
public string SelectedNodeKey { get; set; }
value = diagramSurface.SelectedNodeKey
diagramSurface.SelectedNodeKey = value
Gets or sets the primary selected node key.
public IReadOnlySet<string> SelectedNodeKeys { get; }
value = diagramSurface.SelectedNodeKeys
Gets selected node keys.
public bool ShowGrid { get; set; }
value = diagramSurface.ShowGrid
diagramSurface.ShowGrid = value
Gets or sets whether the grid is visible.
public bool ShowOverview { get; set; }
value = diagramSurface.ShowOverview
diagramSurface.ShowOverview = value
Gets or sets whether the 250 by 150 overview is visible.
public bool SnapToGrid { get; set; }
value = diagramSurface.SnapToGrid
diagramSurface.SnapToGrid = value
Gets or sets whether moves snap to the grid.
public DiagramScrollRange VerticalScroll { get; private set; }
value = diagramSurface.VerticalScroll
diagramSurface.VerticalScroll = value
Gets where the view stands down the scheme, in the terms of a scroll bar.
public double Zoom { get; set; }
value = diagramSurface.Zoom
diagramSurface.Zoom = value
Gets or sets the viewport scale through the legacy property name.
メソッド
public string AddElement(DiagramElement element, PointF location)
result = diagramSurface.AddElement(element, location)
Adds an element as one undoable operation.
- element
- Element to add.
- location
- Diagram-space location.
戻り値: New node key.
public void AddToSelection(ICompositionModelLink link)
diagramSurface.AddToSelection(link)
Adds a link to the current selection.
- link
- Link.
public void AddToSelection(string nodeKey)
diagramSurface.AddToSelection(nodeKey)
Adds a node to the current selection.
- nodeKey
- Node key.
protected override Size ArrangeOverride(Size finalSize)
result = diagramSurface.ArrangeOverride(finalSize)
internal void BeginNodeDragForTest()
diagramSurface.BeginNodeDragForTest()
Enter the node-drag interaction, so a test can assert what it silences.
public void CenterView()
diagramSurface.CenterView()
Centers all diagram nodes without changing the current scale.
public void ClearDiagram()
diagramSurface.ClearDiagram()
Removes every node and connected link in one model operation.
public void ClearDropTargetHighlight()
diagramSurface.ClearDropTargetHighlight()
Clears potential drop target feedback.
public void ClearSelection()
diagramSurface.ClearSelection()
Clears node, link and socket selection.
public void DeleteSelected()
diagramSurface.DeleteSelected()
Deletes the selected nodes with their links, and the selected links, as one step to undo.
public Point DiagramToScreen(Point diagram)
result = diagramSurface.DiagramToScreen(diagram)
Converts a diagram-space point to screen coordinates.
- diagram
- Diagram-space point.
戻り値: Screen-space point.
public void Dispose()
diagramSurface.Dispose()
Disposes of items in the pool that implement IDisposable.
internal void EndInteractionForTest()
diagramSurface.EndInteractionForTest()
Leave whatever interaction is running.
public void FitToView()
diagramSurface.FitToView()
Fits all diagram nodes into the current viewport.
public void FitView()
diagramSurface.FitView()
Fits all diagram nodes into the current viewport.
public Rect GetContentBounds()
result = diagramSurface.GetContentBounds()
Gets the measured diagram-space bounds of all visible cubes.
戻り値: Diagram-space content bounds.
public ICompositionModelLink GetLinkAtPosition(Point screenPosition)
result = diagramSurface.GetLinkAtPosition(screenPosition)
Gets the link at the specified screen position.
- screenPosition
- Screen-space position.
戻り値: Link under the pointer, or .
public string GetNodeAtPosition(Point screenPosition)
result = diagramSurface.GetNodeAtPosition(screenPosition)
Returns the topmost node at a screen position.
- screenPosition
- Screen-space position.
戻り値: Node key, or .
public void HideDragPreview()
diagramSurface.HideDragPreview()
Hides the palette drag preview.
public void HighlightDropTarget(string nodeKey, bool isValid)
diagramSurface.HighlightDropTarget(nodeKey, isValid)
Highlights a potential node drop target.
- nodeKey
- Target node key.
- isValid
- Whether the drop is valid.
public Task<IReadOnlyList<string>> ImportClipboardAsync(ICompositionRegistry registry, DiagramClipboardData data, PointF offset, CancellationToken cancellationToken)
result = diagramSurface.ImportClipboardAsync(registry, data, offset, cancellationToken)
Imports a canonical clipboard fragment into the current model.
- registry
- Composition registry.
- data
- Clipboard envelope.
- offset
- Coordinate offset.
- cancellationToken
- CancellationToken
戻り値: New node keys.
protected override Size MeasureOverride(Size availableSize)
result = diagramSurface.MeasureOverride(availableSize)
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
diagramSurface.OnAttachedToVisualTree(e)
protected override AutomationPeer OnCreateAutomationPeer()
result = diagramSurface.OnCreateAutomationPeer()
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
diagramSurface.OnDetachedFromVisualTree(e)
protected override void OnPointerCaptureLost(PointerCaptureLostEventArgs e)
diagramSurface.OnPointerCaptureLost(e)
protected override void OnPointerExited(PointerEventArgs e)
diagramSurface.OnPointerExited(e)
protected override void OnPointerMoved(PointerEventArgs e)
diagramSurface.OnPointerMoved(e)
protected override void OnPointerPressed(PointerPressedEventArgs e)
diagramSurface.OnPointerPressed(e)
protected override void OnPointerReleased(PointerReleasedEventArgs e)
diagramSurface.OnPointerReleased(e)
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
diagramSurface.OnPointerWheelChanged(e)
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
diagramSurface.OnPropertyChanged(change)
public Point ScreenToDiagram(Point screen)
result = diagramSurface.ScreenToDiagram(screen)
Converts a screen-space point to diagram coordinates.
- screen
- Screen-space point.
戻り値: Diagram-space point.
public void Select(string nodeKey)
diagramSurface.Select(nodeKey)
Selects one node and clears the previous selection.
- nodeKey
- Node key.
public void Select(ICompositionModelLink link)
diagramSurface.Select(link)
Selects one link and clears the previous selection.
- link
- Link.
public void SelectAll()
diagramSurface.SelectAll()
Selects every visible node and every link.
public void SetDropFeedback(bool isValid)
diagramSurface.SetDropFeedback(isValid)
Updates the validity feedback for the current palette drag.
- isValid
- Whether dropping is allowed.
public void ShowDragPreview(Point screenPosition, string elementName, Color? previewColor)
diagramSurface.ShowDragPreview(screenPosition, elementName, previewColor)
Shows a Designer-cube palette drag preview.
- screenPosition
- Preview screen position.
- elementName
- Element display name.
- previewColor
- Optional compatibility parameter. Semantic theme resources determine the rendered color.
public void ShowDragPreview(Point screenPosition, string elementName, string iconName, Color? previewColor)
diagramSurface.ShowDragPreview(screenPosition, elementName, iconName, previewColor)
Shows a Designer-cube palette drag preview with its shared icon.
- screenPosition
- Preview screen position.
- elementName
- Element display name.
- iconName
- Shared Designer SVG icon name.
- previewColor
- Optional compatibility parameter. Semantic theme resources determine the rendered color.
public void ToggleFitView()
diagramSurface.ToggleFitView()
Fits all diagram nodes into the viewport or, when the fitted scale still stands, brings back the view the fit replaced, as the zoom-to-fit key of the WPF diagram does.
public void ToggleSelection(string nodeKey)
diagramSurface.ToggleSelection(nodeKey)
Toggles a node in the current selection.
- nodeKey
- Node key.
public void ToggleSelection(ICompositionModelLink link)
diagramSurface.ToggleSelection(link)
Toggles a link in the current selection.
- link
- Link.
public void UpdateDragPreview(Point screenPosition)
diagramSurface.UpdateDragPreview(screenPosition)
Moves the current palette drag preview.
- screenPosition
- New screen position.
イベント
public event EventHandler<DiagramElement> ElementDoubleClicked
diagramSurface.ElementDoubleClicked += handler
Occurs when a node is double-clicked.
public event EventHandler ModelModified
diagramSurface.ModelModified += handler
Occurs when the represented model changes.
public event EventHandler<string> SelectionChanged
diagramSurface.SelectionChanged += handler
Occurs when the selection changes; the argument is the key of the primary selected node.
public event EventHandler<DiagramSocketClickedEventArgs> SocketClicked
diagramSurface.SocketClicked += handler
Occurs when a socket is activated.
フィールド
public static readonly DirectProperty<DiagramSurface, DiagramScrollRange> HorizontalScrollProperty
value = DiagramSurface.HorizontalScrollProperty
Identifies the HorizontalScroll property.
public static readonly StyledProperty<bool> IsEditingProperty
value = DiagramSurface.IsEditingProperty
Identifies the IsEditing styled property.
public static readonly StyledProperty<ICompositionModel> ModelProperty
value = DiagramSurface.ModelProperty
Identifies the Model styled property.
public static readonly StyledProperty<Point> PanOffsetProperty
value = DiagramSurface.PanOffsetProperty
Identifies the PanOffset styled property.
public static readonly StyledProperty<double> ScaleProperty
value = DiagramSurface.ScaleProperty
Identifies the Scale styled property.
public static readonly StyledProperty<string> SelectedNodeKeyProperty
value = DiagramSurface.SelectedNodeKeyProperty
Identifies the SelectedNodeKey styled property.
public static readonly StyledProperty<bool> ShowGridProperty
value = DiagramSurface.ShowGridProperty
Identifies the ShowGrid styled property.
public static readonly StyledProperty<bool> ShowOverviewProperty
value = DiagramSurface.ShowOverviewProperty
Identifies the ShowOverview styled property.
public static readonly StyledProperty<bool> SnapToGridProperty
value = DiagramSurface.SnapToGridProperty
Identifies the SnapToGrid styled property.
public static readonly DirectProperty<DiagramSurface, DiagramScrollRange> VerticalScrollProperty
value = DiagramSurface.VerticalScrollProperty
Identifies the VerticalScroll property.