public DiagramViewModel( IModelService modelService, IDiagramService diagramService, IDiagramShapeUiFactory diagramShapeUiFactory, double minZoom, double maxZoom, double initialZoom) : base(modelService, diagramService) { DiagramShapeUiFactory = diagramShapeUiFactory; DiagramViewportViewModel = new DiagramViewportViewModel( ModelService, DiagramService, diagramShapeUiFactory, minZoom, maxZoom, initialZoom); RelatedNodeListBoxViewModel = new RelatedNodeListBoxViewModel(ModelService, DiagramService); RelatedNodeListBoxViewModel.ItemSelected += OnRelatedNodeSelected; RelatedNodeListBoxViewModel.Items.CollectionChanged += OnRelatedNodeCollectionChanged; PopupTextViewModel = new AutoHidePopupTextViewModel(); PreviewMouseDownCommand = new DelegateCommand(OnAnyMouseDownEvent); MouseDownCommand = new DelegateCommand(OnUnhandledMouseDownEvent); DiagramService.DiagramChanged += OnDiagramChanged; SubscribeToViewportEvents(); _lastDiagram = DiagramService.LatestDiagram; }
private void OnRelatedNodeSelectorRequested(RelatedNodeMiniButtonViewModel ownerButton, IReadOnlyList <IModelNode> modelNodes) { DiagramViewportViewModel.PinFocus(); var viewModelItems = modelNodes.OrderBy(i => i, _modelNodeComparer).Select(_relatedNodeItemViewModelFactory.Create); RelatedNodeListBoxViewModel.Show(ownerButton, viewModelItems); }
private void OnDiagramShapeRemoveRequested(DiagramShapeViewModelBase diagramShapeViewModel) { DiagramViewportViewModel.StopFollowingDiagramNodes(); if (RelatedEntityListBoxViewModel.OwnerDiagramShape == diagramShapeViewModel) { HideRelatedEntityListBox(); } }
public void FollowDiagramNodes(IReadOnlyCollection <ModelNodeId> nodeIds) { var autoMoveMode = _lastDiagram.Nodes.Count > nodeIds.Count ? ViewportAutoMoveMode.Contain : ViewportAutoMoveMode.Center; DiagramViewportViewModel.SetFollowDiagramNodesMode(autoMoveMode); DiagramViewportViewModel.FollowDiagramNodes(nodeIds); }
public void FollowDiagramNodes(IReadOnlyList <IDiagramNode> diagramNodes) { var autoMoveMode = Diagram.Nodes.Count > diagramNodes.Count ? ViewportAutoMoveMode.Contain : ViewportAutoMoveMode.Center; DiagramViewportViewModel.SetFollowDiagramNodesMode(autoMoveMode); DiagramViewportViewModel.FollowDiagramNodes(diagramNodes); }
private void OnRemoveDiagramNodeRequested(DiagramNodeViewModel diagramNodeViewModel) { DiagramViewportViewModel.StopFollowingDiagramNodes(); if (RelatedNodeListBoxViewModel.OwnerDiagramShape == diagramNodeViewModel) { HideRelatedNodeListBox(); } RemoveDiagramNodeRequested?.Invoke(diagramNodeViewModel.DiagramNode); }
public void Dispose() { RelatedEntityListBoxViewModel.ItemSelected -= OnRelatedEntitySelected; RelatedEntityListBoxViewModel.Items.CollectionChanged -= OnRelatedEntityCollectionChanged; RelatedEntityListBoxViewModel.Dispose(); UnsubscribeFromDiagramEvents(); UnsubscribeFromViewportEvents(); DiagramViewportViewModel.Dispose(); }
public override void Dispose() { base.Dispose(); RelatedNodeListBoxViewModel.ItemSelected -= OnRelatedNodeSelected; RelatedNodeListBoxViewModel.Items.CollectionChanged -= OnRelatedNodeCollectionChanged; RelatedNodeListBoxViewModel.Dispose(); DiagramEventSource.DiagramChanged -= OnDiagramChanged; UnsubscribeFromViewportEvents(); DiagramViewportViewModel.Dispose(); }
public DiagramViewModel(IArrangedDiagram diagram, double minZoom, double maxZoom, double initialZoom) : base(diagram) { DiagramViewportViewModel = new DiagramViewportViewModel(diagram, minZoom, maxZoom, initialZoom); RelatedEntityListBoxViewModel = new RelatedEntityListBoxViewModel(diagram); RelatedEntityListBoxViewModel.ItemSelected += OnRelatedEntitySelected; RelatedEntityListBoxViewModel.Items.CollectionChanged += OnRelatedEntityCollectionChanged; PopupTextViewModel = new AutoHidePopupTextViewModel(); PreviewMouseDownCommand = new DelegateCommand(OnAnyMouseDownEvent); MouseDownCommand = new DelegateCommand(OnUnhandledMouseDownEvent); SubscribeToDiagramEvents(); SubscribeToViewportEvents(); }
private void HideRelatedNodeListBox() { DiagramViewportViewModel.UnpinDecoration(); RelatedNodeListBoxViewModel.Hide(); }
private void OnRelatedNodeSelectorRequested(RelatedNodeMiniButtonViewModel ownerButton, IReadOnlyList <IModelNode> modelNodes) { DiagramViewportViewModel.PinDecoration(); RelatedNodeListBoxViewModel.Show(ownerButton, modelNodes); }
public bool IsDiagramContentVisible() => DiagramViewportViewModel.IsDiagramContentVisible();
public void EnsureRectIsVisible(Rect rect) => DiagramViewportViewModel.EnsureRectIsVisible(rect);
public void ZoomToRect(Rect rect) => DiagramViewportViewModel.ZoomToRect(rect);
public void ExpandAllNodes() => DiagramViewportViewModel.ExpandAllDiagramNodes();
public void KeepDiagramCentered() { DiagramViewportViewModel.SetFollowDiagramNodesMode(ViewportAutoMoveMode.Center); DiagramViewportViewModel.FollowDiagramNodes(_lastDiagram.Nodes.Select(i => i.Id).ToArray()); }
private void HideRelatedNodeListBox() { DiagramViewportViewModel.UnpinFocus(); RelatedNodeListBoxViewModel.Hide(); }
public void KeepDiagramCentered() { DiagramViewportViewModel.SetFollowDiagramNodesMode(ViewportAutoMoveMode.Center); DiagramViewportViewModel.FollowDiagramNodes(Diagram.Nodes); }
private void OnShowRelatedEntitySelectorRequested(ShowRelatedNodeButtonViewModel diagramNodeButtonViewModel, IEnumerable <IModelEntity> modelEntities) { DiagramViewportViewModel.PinDecoration(); RelatedEntityListBoxViewModel.Show(diagramNodeButtonViewModel, modelEntities); }
public void ZoomToContent() => DiagramViewportViewModel.ZoomToContent();
public void StopFollowingDiagramNodes() { DiagramViewportViewModel.StopFollowingDiagramNodes(); }
public void CollapseAllNodes() => DiagramViewportViewModel.CollapseAllDiagramNodes();