DiagramViewModel
ViewModel for diagram viewer/editor.
Inherits: NotifiableObject
Properties
public SizeF CanvasSize { get; set; }
value = diagramViewModel.CanvasSize
diagramViewModel.CanvasSize = value
Canvas size, updated from DiagramPage.SizeChanged.
public DelegateCommand ClearSelectionCommand { get; }
value = diagramViewModel.ClearSelectionCommand
Gets the command wrapping ClearSelection.
public CompositionDiagramElement Composition { get; set; }
value = diagramViewModel.Composition
diagramViewModel.Composition = value
Gets or sets the Composition observable property.
public DelegateCommand CopyCommand { get; }
value = diagramViewModel.CopyCommand
Gets the command wrapping Copy.
public DelegateCommand CutCommand { get; }
value = diagramViewModel.CutCommand
Gets the command wrapping Cut.
public DelegateCommand DeleteCommand { get; }
value = diagramViewModel.DeleteCommand
Gets the command wrapping Delete.
public DiagramCanvasDrawable Drawable { get; }
value = diagramViewModel.Drawable
The drawable for GraphicsView.
public DiagramEditorState EditorState { get; }
value = diagramViewModel.EditorState
Gets the editor state.
public string ErrorMessage { get; set; }
value = diagramViewModel.ErrorMessage
diagramViewModel.ErrorMessage = value
Gets or sets the ErrorMessage observable property.
public DelegateCommand FitToViewCommand { get; }
value = diagramViewModel.FitToViewCommand
Gets the command wrapping FitToView.
public bool HasComposition { get; }
value = diagramViewModel.HasComposition
Whether a composition is loaded.
public bool IsDirty { get; set; }
value = diagramViewModel.IsDirty
diagramViewModel.IsDirty = value
Gets or sets the IsDirty observable property.
public bool IsEditing { get; set; }
value = diagramViewModel.IsEditing
diagramViewModel.IsEditing = value
Gets or sets the IsEditing observable property.
public float PanX { get; set; }
value = diagramViewModel.PanX
diagramViewModel.PanX = value
Gets or sets the PanX observable property.
public float PanY { get; set; }
value = diagramViewModel.PanY
diagramViewModel.PanY = value
Gets or sets the PanY observable property.
public DelegateCommand PasteCommand { get; }
value = diagramViewModel.PasteCommand
Gets the command wrapping Paste.
public DelegateCommand RedoCommand { get; }
value = diagramViewModel.RedoCommand
Gets the command wrapping Redo.
public DelegateCommand ResetViewCommand { get; }
value = diagramViewModel.ResetViewCommand
Gets the command wrapping ResetView.
public DelegateCommand SelectAllCommand { get; }
value = diagramViewModel.SelectAllCommand
Gets the command wrapping SelectAll.
public DiagramElement SelectedElement { get; set; }
value = diagramViewModel.SelectedElement
diagramViewModel.SelectedElement = value
Gets or sets the SelectedElement observable property.
public ISelectionModel Selection { get; }
value = diagramViewModel.Selection
Gets the selection model.
public DelegateCommand UndoCommand { get; }
value = diagramViewModel.UndoCommand
Gets the command wrapping Undo.
public float Zoom { get; set; }
value = diagramViewModel.Zoom
diagramViewModel.Zoom = value
Gets or sets the Zoom observable property.
public DelegateCommand ZoomInCommand { get; }
value = diagramViewModel.ZoomInCommand
Gets the command wrapping ZoomIn.
public DelegateCommand ZoomOutCommand { get; }
value = diagramViewModel.ZoomOutCommand
Gets the command wrapping ZoomOut.
Methods
public void CancelLinkCreation()
diagramViewModel.CancelLinkCreation()
Cancel link creation.
public void CancelNodeDrag()
diagramViewModel.CancelNodeDrag()
Cancel node drag and restore original position.
public void CancelPaletteDrag()
diagramViewModel.CancelPaletteDrag()
Cancel palette drag.
public bool CompleteLinkCreation(SocketKey targetSocketKey)
result = diagramViewModel.CompleteLinkCreation(targetSocketKey)
Complete link creation to target socket.
public bool CompletePaletteDrag(float screenX, float screenY)
result = diagramViewModel.CompletePaletteDrag(screenX, screenY)
Complete palette drag and create new node.
public void ContinueNodeDrag(float diagramX, float diagramY)
diagramViewModel.ContinueNodeDrag(diagramX, diagramY)
Continue dragging a node or multiple nodes.
public void DeleteLink(string fromNodeKey, string fromSocketId, string toNodeKey, string toSocketId)
diagramViewModel.DeleteLink(fromNodeKey, fromSocketId, toNodeKey, toSocketId)
Delete a link between two sockets.
public IEnumerable<SocketKey> GetCompatibleSockets()
result = diagramViewModel.GetCompatibleSockets()
Get all compatible sockets for the current link source.
public static DiagramFileData LoadFromFile(string filePath)
result = DiagramViewModel.LoadFromFile(filePath)
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.
Returns: Diagram file data, or null if invalid.
public static DiagramFileData LoadFromStream(Stream stream)
result = DiagramViewModel.LoadFromStream(stream)
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.
Returns: Diagram file data, or null if invalid.
public void NotifyClipboardChanged()
diagramViewModel.NotifyClipboardChanged()
Notify clipboard command state changes.
public void NotifyUndoRedoChanged()
diagramViewModel.NotifyUndoRedoChanged()
Notify that undo/redo state may have changed.
public void OnPan(float deltaX, float deltaY)
diagramViewModel.OnPan(deltaX, deltaY)
Handle pan gesture delta.
public void OnPinch(float scale, float focusX, float focusY)
diagramViewModel.OnPinch(scale, focusX, focusY)
Handle pinch gesture.
public void OnTap(float screenX, float screenY)
diagramViewModel.OnTap(screenX, screenY)
Handle tap at screen coordinates.
public void OnTapWithModifier(float screenX, float screenY, bool addToSelection)
diagramViewModel.OnTapWithModifier(screenX, screenY, addToSelection)
Handle tap with modifier for multi-select.
public void SaveToFile(string filePath)
diagramViewModel.SaveToFile(filePath)
Save the diagram to a file.
- filePath
- The file path to save to.
public void SaveToStream(Stream stream)
diagramViewModel.SaveToStream(stream)
Save the diagram to a stream.
- stream
- The stream to write to.
public string SaveToString()
result = diagramViewModel.SaveToString()
Save the diagram to a JSON string.
Returns: JSON representation of the diagram.
public void SelectNodesInRect(RectF screenRect)
diagramViewModel.SelectNodesInRect(screenRect)
Select all nodes within a screen-space rectangle (rubber band selection).
public void SetInvalidateCallback(Action invalidate)
diagramViewModel.SetInvalidateCallback(invalidate)
Set the canvas invalidation callback.
public void StartLinkCreation(SocketKey socketKey, float screenX, float screenY)
diagramViewModel.StartLinkCreation(socketKey, screenX, screenY)
Start creating a link from a socket.
public void StartNodeDrag(string nodeKey, float diagramX, float diagramY)
diagramViewModel.StartNodeDrag(nodeKey, diagramX, diagramY)
Start dragging a node (or multiple if the node is in a multi-selection).
public void StartPaletteDrag(PaletteItem item, float screenX, float screenY)
diagramViewModel.StartPaletteDrag(item, screenX, screenY)
Start dragging an element from the palette.
private bool TryCreateElement(PaletteItem item, float x, float y)
result = diagramViewModel.TryCreateElement(item, x, y)
Try to create a new element at the specified position.
public void UpdateLinkCreation(float screenX, float screenY)
diagramViewModel.UpdateLinkCreation(screenX, screenY)
Update link creation endpoint.
public void UpdateLinkHover(SocketKey hoverSocket)
diagramViewModel.UpdateLinkHover(hoverSocket)
Update link hover validation state.
public void UpdatePaletteDrag(float screenX, float screenY, bool isOverCanvas)
diagramViewModel.UpdatePaletteDrag(screenX, screenY, isOverCanvas)
Update palette drag position.
public bool ValidateLink(SocketKey source, SocketKey target, string error)
result = diagramViewModel.ValidateLink(source, target, error)
Validate if a link can be created between two sockets.
- source
- Source socket.
- target
- Target socket.
- error
- Error message if invalid.
Returns: True if link is valid.
private bool WouldCreateCycle(string fromNodeKey, string toNodeKey)
result = diagramViewModel.WouldCreateCycle(fromNodeKey, toNodeKey)
Check if adding a link would create a cycle in the graph.