DiagramSurface

StockSharp.Xaml.Diagram.Controls

Hosts diagram presenters and keeps them synchronized with a composition model.

继承自: Panel

实现: IDisposable

构造函数

DiagramSurface
public DiagramSurface()
diagramSurface = DiagramSurface()

Initializes a new instance of the DiagramSurface class.

属性

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

Gets whether the most recently undone editor operation can be redone.

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

Gets whether the most recent editor operation can be undone.

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

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

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

Gets or sets whether model mutation is enabled.

Model
public ICompositionModel Model { get; set; }
value = diagramSurface.Model
diagramSurface.Model = value

Gets or sets the composition model.

NodePresenters
public IReadOnlyCollection<DiagramNodePresenter> NodePresenters { get; }
value = diagramSurface.NodePresenters

Gets the current node presenter instances.

PanOffset
public Point PanOffset { get; set; }
value = diagramSurface.PanOffset
diagramSurface.PanOffset = value

Gets or sets the viewport translation.

Scale
public double Scale { get; set; }
value = diagramSurface.Scale
diagramSurface.Scale = value

Gets or sets the viewport scale.

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

Gets the primary selected diagram element.

SelectedElements
public IReadOnlyList<DiagramElement> SelectedElements { get; }
value = diagramSurface.SelectedElements

Gets all selected diagram elements.

SelectedNodeKey
public string SelectedNodeKey { get; set; }
value = diagramSurface.SelectedNodeKey
diagramSurface.SelectedNodeKey = value

Gets or sets the primary selected node key.

SelectedNodeKeys
public IReadOnlySet<string> SelectedNodeKeys { get; }
value = diagramSurface.SelectedNodeKeys

Gets selected node keys.

ShowGrid
public bool ShowGrid { get; set; }
value = diagramSurface.ShowGrid
diagramSurface.ShowGrid = value

Gets or sets whether the grid is visible.

ShowOverview
public bool ShowOverview { get; set; }
value = diagramSurface.ShowOverview
diagramSurface.ShowOverview = value

Gets or sets whether the 250 by 150 overview is visible.

SnapToGrid
public bool SnapToGrid { get; set; }
value = diagramSurface.SnapToGrid
diagramSurface.SnapToGrid = value

Gets or sets whether moves snap to the grid.

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

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

Gets or sets the viewport scale through the legacy property name.

方法

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

AddToSelection
public void AddToSelection(string nodeKey)
diagramSurface.AddToSelection(nodeKey)

Adds a node to the current selection.

nodeKey
Node key.
ArrangeOverride
protected override Size ArrangeOverride(Size finalSize)
result = diagramSurface.ArrangeOverride(finalSize)
BeginNodeDragForTest
internal void BeginNodeDragForTest()
diagramSurface.BeginNodeDragForTest()

Enter the node-drag interaction, so a test can assert what it silences.

CenterView
public void CenterView()
diagramSurface.CenterView()

Centers all diagram nodes without changing the current scale.

ClearDiagram
public void ClearDiagram()
diagramSurface.ClearDiagram()

Removes every node and connected link in one model operation.

ClearDropTargetHighlight
public void ClearDropTargetHighlight()
diagramSurface.ClearDropTargetHighlight()

Clears potential drop target feedback.

ClearSelection
public void ClearSelection()
diagramSurface.ClearSelection()

Clears node, link and socket selection.

DeleteSelected
public void DeleteSelected()
diagramSurface.DeleteSelected()

Deletes the selected nodes with their links, and the selected links, as one step to undo.

DiagramToScreen
public Point DiagramToScreen(Point diagram)
result = diagramSurface.DiagramToScreen(diagram)

Converts a diagram-space point to screen coordinates.

diagram
Diagram-space point.

返回值: Screen-space point.

Dispose
public void Dispose()
diagramSurface.Dispose()

Disposes of items in the pool that implement IDisposable.

EndInteractionForTest
internal void EndInteractionForTest()
diagramSurface.EndInteractionForTest()

Leave whatever interaction is running.

FitToView
public void FitToView()
diagramSurface.FitToView()

Fits all diagram nodes into the current viewport.

FitView
public void FitView()
diagramSurface.FitView()

Fits all diagram nodes into the current viewport.

GetContentBounds
public Rect GetContentBounds()
result = diagramSurface.GetContentBounds()

Gets the measured diagram-space bounds of all visible cubes.

返回值: Diagram-space content bounds.

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

GetNodeAtPosition
public string GetNodeAtPosition(Point screenPosition)
result = diagramSurface.GetNodeAtPosition(screenPosition)

Returns the topmost node at a screen position.

screenPosition
Screen-space position.

返回值: Node key, or .

HideDragPreview
public void HideDragPreview()
diagramSurface.HideDragPreview()

Hides the palette drag preview.

HighlightDropTarget
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.
ImportClipboardAsync
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.

MeasureOverride
protected override Size MeasureOverride(Size availableSize)
result = diagramSurface.MeasureOverride(availableSize)
OnAttachedToVisualTree
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
diagramSurface.OnAttachedToVisualTree(e)
OnCreateAutomationPeer
protected override AutomationPeer OnCreateAutomationPeer()
result = diagramSurface.OnCreateAutomationPeer()
OnDetachedFromVisualTree
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
diagramSurface.OnDetachedFromVisualTree(e)
OnKeyDown
protected override void OnKeyDown(KeyEventArgs e)
diagramSurface.OnKeyDown(e)
OnPointerCaptureLost
protected override void OnPointerCaptureLost(PointerCaptureLostEventArgs e)
diagramSurface.OnPointerCaptureLost(e)
OnPointerExited
protected override void OnPointerExited(PointerEventArgs e)
diagramSurface.OnPointerExited(e)
OnPointerMoved
protected override void OnPointerMoved(PointerEventArgs e)
diagramSurface.OnPointerMoved(e)
OnPointerPressed
protected override void OnPointerPressed(PointerPressedEventArgs e)
diagramSurface.OnPointerPressed(e)
OnPointerReleased
protected override void OnPointerReleased(PointerReleasedEventArgs e)
diagramSurface.OnPointerReleased(e)
OnPointerWheelChanged
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
diagramSurface.OnPointerWheelChanged(e)
OnPropertyChanged
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
diagramSurface.OnPropertyChanged(change)
Redo
public void Redo()
diagramSurface.Redo()

Redoes the most recently undone editor operation.

ResetView
public void ResetView()
diagramSurface.ResetView()

Restores the default viewport.

ScreenToDiagram
public Point ScreenToDiagram(Point screen)
result = diagramSurface.ScreenToDiagram(screen)

Converts a screen-space point to diagram coordinates.

screen
Screen-space point.

返回值: Diagram-space point.

Select
public void Select(string nodeKey)
diagramSurface.Select(nodeKey)

Selects one node and clears the previous selection.

nodeKey
Node key.
SelectAll
public void SelectAll()
diagramSurface.SelectAll()

Selects every visible node and every link.

SetDropFeedback
public void SetDropFeedback(bool isValid)
diagramSurface.SetDropFeedback(isValid)

Updates the validity feedback for the current palette drag.

isValid
Whether dropping is allowed.
ShowDragPreview
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.
ShowDragPreview
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.
ToggleFitView
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.

ToggleSelection
public void ToggleSelection(string nodeKey)
diagramSurface.ToggleSelection(nodeKey)

Toggles a node in the current selection.

nodeKey
Node key.
Undo
public void Undo()
diagramSurface.Undo()

Undoes the most recent editor operation.

UpdateDragPreview
public void UpdateDragPreview(Point screenPosition)
diagramSurface.UpdateDragPreview(screenPosition)

Moves the current palette drag preview.

screenPosition
New screen position.
ZoomIn
public void ZoomIn()
diagramSurface.ZoomIn()

Increases the viewport scale.

ZoomOut
public void ZoomOut()
diagramSurface.ZoomOut()

Decreases the viewport scale.

事件

ElementDoubleClicked
public event EventHandler<DiagramElement> ElementDoubleClicked
diagramSurface.ElementDoubleClicked += handler

Occurs when a node is double-clicked.

ModelModified
public event EventHandler ModelModified
diagramSurface.ModelModified += handler

Occurs when the represented model changes.

SelectionChanged
public event EventHandler<string> SelectionChanged
diagramSurface.SelectionChanged += handler

Occurs when the selection changes; the argument is the key of the primary selected node.

SocketClicked
public event EventHandler<DiagramSocketClickedEventArgs> SocketClicked
diagramSurface.SocketClicked += handler

Occurs when a socket is activated.

字段

HorizontalScrollProperty
public static readonly DirectProperty<DiagramSurface, DiagramScrollRange> HorizontalScrollProperty
value = DiagramSurface.HorizontalScrollProperty

Identifies the HorizontalScroll property.

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

Identifies the IsEditing styled property.

ModelProperty
public static readonly StyledProperty<ICompositionModel> ModelProperty
value = DiagramSurface.ModelProperty

Identifies the Model styled property.

PanOffsetProperty
public static readonly StyledProperty<Point> PanOffsetProperty
value = DiagramSurface.PanOffsetProperty

Identifies the PanOffset styled property.

ScaleProperty
public static readonly StyledProperty<double> ScaleProperty
value = DiagramSurface.ScaleProperty

Identifies the Scale styled property.

SelectedNodeKeyProperty
public static readonly StyledProperty<string> SelectedNodeKeyProperty
value = DiagramSurface.SelectedNodeKeyProperty

Identifies the SelectedNodeKey styled property.

ShowGridProperty
public static readonly StyledProperty<bool> ShowGridProperty
value = DiagramSurface.ShowGridProperty

Identifies the ShowGrid styled property.

ShowOverviewProperty
public static readonly StyledProperty<bool> ShowOverviewProperty
value = DiagramSurface.ShowOverviewProperty

Identifies the ShowOverview styled property.

SnapToGridProperty
public static readonly StyledProperty<bool> SnapToGridProperty
value = DiagramSurface.SnapToGridProperty

Identifies the SnapToGrid styled property.

VerticalScrollProperty
public static readonly DirectProperty<DiagramSurface, DiagramScrollRange> VerticalScrollProperty
value = DiagramSurface.VerticalScrollProperty

Identifies the VerticalScroll property.