public DiagramViewportViewModel(
            IModelService modelService,
            IDiagramService diagramService,
            IDiagramShapeUiFactory diagramShapeUiFactory,
            double minZoom,
            double maxZoom,
            double initialZoom)
            : base(modelService, diagramService)
        {
            MinZoom = minZoom;
            MaxZoom = maxZoom;

            _diagramNodeToViewModelMap      = new Map <ModelNodeId, DiagramNodeViewModel>();
            _diagramConnectorToViewModelMap = new Map <ModelRelationshipId, DiagramConnectorViewModel>();

            _diagramShapeUiFactory = diagramShapeUiFactory;
            _diagramShapeUiFactory.Initialize(modelService, this);

            ViewportCalculator         = new AutoMoveViewportViewModel(modelService, diagramService, minZoom, maxZoom, initialZoom);
            DiagramNodeViewModels      = new ThreadSafeObservableCollection <DiagramNodeViewModel>();
            DiagramConnectorViewModels = new ThreadSafeObservableCollection <DiagramConnectorViewModel>();
            MiniButtonPanelViewModel   = new MiniButtonPanelViewModel();

            DiagramNodeDoubleClickedCommand = new DelegateCommand <IDiagramNode>(i => DiagramNodeInvoked?.Invoke(i));

            ViewportCalculator.TransformChanged += OnViewportTransformChanged;
            DiagramService.DiagramChanged       += OnDiagramChanged;

            AddDiagram(diagramService.LatestDiagram);
        }
        private void RemoveConnector(IDiagramConnector diagramConnector)
        {
            if (!TryGetDiagramConnectorViewModel(diagramConnector.Id, out var diagramConnectorViewModel))
            {
                return;
            }

            MiniButtonPanelViewModel.Unfocus(diagramConnectorViewModel);
            _diagramConnectorToViewModelMap.Remove(diagramConnector.Id);
            DiagramConnectorViewModels.Remove(diagramConnectorViewModel);

            diagramConnectorViewModel.Dispose();
        }
Пример #3
0
        private void RemoveNode(IDiagramNode diagramNode)
        {
            if (!TryGetDiagramNodeViewModel(diagramNode.Id, out var diagramNodeViewModel))
            {
                return;
            }

            diagramNodeViewModel.SizeChanged -= OnDiagramNodeSizeChanged;
            diagramNodeViewModel.ShowRelatedNodesRequested    -= OnShowRelatedNodesRequested;
            diagramNodeViewModel.RelatedNodeSelectorRequested -= OnEntitySelectorRequested;
            diagramNodeViewModel.RemoveRequested -= OnRemoveDiagramNodeRequested;

            MiniButtonPanelViewModel.Unfocus(diagramNodeViewModel);
            _diagramNodeToViewModelMap.Remove(diagramNode.Id);
            DiagramNodeViewModels.Remove(diagramNodeViewModel);

            diagramNodeViewModel.Dispose();
        }
        public override void Dispose()
        {
            base.Dispose();

            ViewportCalculator.TransformChanged -= OnViewportTransformChanged;
            DiagramService.DiagramChanged       -= OnDiagramChanged;

            ViewportCalculator.Dispose();
            MiniButtonPanelViewModel.Dispose();

            foreach (var diagramNodeViewModel in DiagramNodeViewModels)
            {
                diagramNodeViewModel.Dispose();
            }

            foreach (var diagramConnectorViewModel in DiagramConnectorViewModels)
            {
                diagramConnectorViewModel.Dispose();
            }
        }
 public void UnpinDecoration() => MiniButtonPanelViewModel.UnpinDecoration();