예제 #1
0
        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;
        }
예제 #2
0
        private void OnRelatedNodeSelectorRequested(RelatedNodeMiniButtonViewModel ownerButton, IReadOnlyList <IModelNode> modelNodes)
        {
            DiagramViewportViewModel.PinFocus();
            var viewModelItems = modelNodes.OrderBy(i => i, _modelNodeComparer).Select(_relatedNodeItemViewModelFactory.Create);

            RelatedNodeListBoxViewModel.Show(ownerButton, viewModelItems);
        }
예제 #3
0
 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);
        }
예제 #5
0
        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);
        }
예제 #7
0
        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();
        }
예제 #9
0
        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();
        }
예제 #10
0
 private void HideRelatedNodeListBox()
 {
     DiagramViewportViewModel.UnpinDecoration();
     RelatedNodeListBoxViewModel.Hide();
 }
예제 #11
0
 private void OnRelatedNodeSelectorRequested(RelatedNodeMiniButtonViewModel ownerButton, IReadOnlyList <IModelNode> modelNodes)
 {
     DiagramViewportViewModel.PinDecoration();
     RelatedNodeListBoxViewModel.Show(ownerButton, modelNodes);
 }
예제 #12
0
 public bool IsDiagramContentVisible() => DiagramViewportViewModel.IsDiagramContentVisible();
예제 #13
0
 public void EnsureRectIsVisible(Rect rect) => DiagramViewportViewModel.EnsureRectIsVisible(rect);
예제 #14
0
 public void ZoomToRect(Rect rect) => DiagramViewportViewModel.ZoomToRect(rect);
예제 #15
0
 public void ExpandAllNodes() => DiagramViewportViewModel.ExpandAllDiagramNodes();
예제 #16
0
 public void KeepDiagramCentered()
 {
     DiagramViewportViewModel.SetFollowDiagramNodesMode(ViewportAutoMoveMode.Center);
     DiagramViewportViewModel.FollowDiagramNodes(_lastDiagram.Nodes.Select(i => i.Id).ToArray());
 }
예제 #17
0
 private void HideRelatedNodeListBox()
 {
     DiagramViewportViewModel.UnpinFocus();
     RelatedNodeListBoxViewModel.Hide();
 }
예제 #18
0
 public void KeepDiagramCentered()
 {
     DiagramViewportViewModel.SetFollowDiagramNodesMode(ViewportAutoMoveMode.Center);
     DiagramViewportViewModel.FollowDiagramNodes(Diagram.Nodes);
 }
예제 #19
0
 private void OnShowRelatedEntitySelectorRequested(ShowRelatedNodeButtonViewModel diagramNodeButtonViewModel, IEnumerable <IModelEntity> modelEntities)
 {
     DiagramViewportViewModel.PinDecoration();
     RelatedEntityListBoxViewModel.Show(diagramNodeButtonViewModel, modelEntities);
 }
예제 #20
0
 public void ZoomToContent() => DiagramViewportViewModel.ZoomToContent();
예제 #21
0
 public void StopFollowingDiagramNodes()
 {
     DiagramViewportViewModel.StopFollowingDiagramNodes();
 }
예제 #22
0
 public void CollapseAllNodes() => DiagramViewportViewModel.CollapseAllDiagramNodes();