IDiagramModelAdapter
Provides a non-generic, UI-independent view over a composition model behavior.
Implementa: IDisposable
Propiedades
public bool CanRedo { get; }
value = iDiagramModelAdapter.CanRedo
Gets whether an undone adapter operation can be redone.
public bool CanUndo { get; }
value = iDiagramModelAdapter.CanUndo
Gets whether an adapter operation can be undone.
public IReadOnlyList<ICompositionModelLink> Links { get; }
value = iDiagramModelAdapter.Links
Gets a current snapshot of diagram links.
public ICompositionModel Model { get; }
value = iDiagramModelAdapter.Model
Gets the underlying composition model.
public IReadOnlyList<ICompositionModelNode> Nodes { get; }
value = iDiagramModelAdapter.Nodes
Gets a current snapshot of diagram nodes.
Métodos
public string AddElement(DiagramElement element, PointF location)
result = iDiagramModelAdapter.AddElement(element, location)
Adds an element as one undoable operation.
- element
- Element to add.
- location
- Diagram-space location.
Devuelve: New node key.
public ICompositionModelNode FindNode(string key)
result = iDiagramModelAdapter.FindNode(key)
Finds a node by its stable model key.
- key
- Node key.
Devuelve: The node, or when it is absent.
public ValueTask<IReadOnlyList<string>> ImportFragmentAsync(ICompositionModel fragment, PointF offset, CancellationToken cancellationToken)
result = iDiagramModelAdapter.ImportFragmentAsync(fragment, offset, cancellationToken)
Imports every node and internal link from a canonical fragment in one transaction.
- fragment
- Deserialized canonical fragment model.
- offset
- Coordinate offset.
- cancellationToken
- CancellationToken
Devuelve: New target node keys.
public void MoveNodes(IReadOnlyDictionary<string, PointF> originalLocations, PointF delta, double gridSize)
iDiagramModelAdapter.MoveNodes(originalLocations, delta, gridSize)
Moves a group while preserving its relative coordinates and snapping the anchor.
- originalLocations
- Original locations keyed by node key.
- delta
- Requested group displacement.
- gridSize
- Snap grid size, or zero to disable snapping.
public void Remove(IEnumerable<string> nodeKeys, IEnumerable<ICompositionModelLink> links)
iDiagramModelAdapter.Remove(nodeKeys, links)
Removes nodes with every link connected to them, and links of their own, in one model transaction that is one step to undo.
- nodeKeys
- Node keys to remove.
- links
- Links to remove besides those of the nodes.
public PointF SnapDisplacement(IReadOnlyDictionary<string, PointF> originalLocations, PointF delta, double gridSize)
result = iDiagramModelAdapter.SnapDisplacement(originalLocations, delta, gridSize)
Finds how far a group lands from where it was when its anchor is snapped, as Double) places it.
- originalLocations
- Original locations keyed by node key.
- delta
- Requested group displacement.
- gridSize
- Snap grid size, or zero to disable snapping.
Devuelve: The displacement with the anchor snapped.
public bool TryConnect(string firstNodeKey, string firstSocketId, string secondNodeKey, string secondSocketId, DiagramConnectionResults result)
result = iDiagramModelAdapter.TryConnect(firstNodeKey, firstSocketId, secondNodeKey, secondSocketId, result)
Validates and creates a directed output-to-input connection.
- firstNodeKey
- First endpoint node key.
- firstSocketId
- First endpoint socket identifier.
- secondNodeKey
- Second endpoint node key.
- secondSocketId
- Second endpoint socket identifier.
- result
- Connection validation result.
Devuelve: when the connection was created.
public bool TryRelink(ICompositionModelLink link, string firstNodeKey, string firstSocketId, string secondNodeKey, string secondSocketId, DiagramConnectionResults result)
result = iDiagramModelAdapter.TryRelink(link, firstNodeKey, firstSocketId, secondNodeKey, secondSocketId, result)
Replaces both endpoints of an existing link in one model transaction.
- link
- Existing link.
- firstNodeKey
- First new endpoint node key.
- firstSocketId
- First new endpoint socket identifier.
- secondNodeKey
- Second new endpoint node key.
- secondSocketId
- Second new endpoint socket identifier.
- result
- Connection validation result.
Devuelve: when the link was replaced.
public DiagramConnectionResults ValidateConnection(string firstNodeKey, string firstSocketId, string secondNodeKey, string secondSocketId, ICompositionModelLink ignoredLink)
result = iDiagramModelAdapter.ValidateConnection(firstNodeKey, firstSocketId, secondNodeKey, secondSocketId, ignoredLink)
Validates a directed output-to-input connection without changing the model.
- firstNodeKey
- First endpoint node key.
- firstSocketId
- First endpoint socket identifier.
- secondNodeKey
- Second endpoint node key.
- secondSocketId
- Second endpoint socket identifier.
- ignoredLink
- Existing link ignored while validating a relink operation.
Devuelve: Validation result. Connected means valid.
Eventos
public event EventHandler Changed
iDiagramModelAdapter.Changed += handler
Occurs after model data relevant to the diagram changes.