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(); }
private void RemoveFromViewModels(DiagramShapeViewModelBase diagramShapeViewModel) { if (diagramShapeViewModel is DiagramNodeViewModel) { var diagramNodeViewModel = (DiagramNodeViewModel)diagramShapeViewModel; DiagramNodeViewModels.Remove(diagramNodeViewModel); diagramNodeViewModel.Dispose(); } else if (diagramShapeViewModel is DiagramConnectorViewModel) { var diagramConnectorViewModel = (DiagramConnectorViewModel)diagramShapeViewModel; DiagramConnectorViewModels.Remove(diagramConnectorViewModel); diagramConnectorViewModel.Dispose(); } else { throw new Exception($"Unexpected DiagramShapeViewModelBase: {diagramShapeViewModel.GetType().Name}"); } }