private void AdjustVisibility(bool diagramVisible, bool deferRebuildWatermark) { DiagramView diagramView = myDiagramView; if (!diagramVisible) { Diagram diagram = diagramView.Diagram; if (diagram != null) { myDisassociating = true; try { MultiDiagramDocView.DeactivateMouseActions(diagramView); diagram.Disassociate(diagramView); } finally { myDisassociating = false; } SetSelectedComponents(null); } if (!deferRebuildWatermark) { RebuildWatermark(); } } diagramView.Visible = diagramVisible; myWatermarkLabel.Visible = !diagramVisible; }
private void Disassociate() { DiagramView diagramView = myDiagramView; Diagram diagram = diagramView.Diagram; if (diagram != null) { myDisassociating = true; try { MultiDiagramDocView.DeactivateMouseActions(diagramView); diagram.Disassociate(diagramView); } finally { myDisassociating = false; } } }
/// <summary> /// Activate the specified <paramref name="diagram"/> /// </summary> /// <param name="diagram">The <see cref="Diagram"/> to activate</param> /// <returns>true if the diagram is successfully activated</returns> public bool ActivateDiagram(Diagram diagram) { if (diagram != null) // Sanity check { bool calledShow = false; Store spyOnStore = myStore; Store testStore = diagram.Store; if (spyOnStore == null) { // Either the window has never been shown, or it is not currently // active. Pre-check the store against the current selection to // see if showing the window will actually initialize to the correct store. IMonitorSelectionService selectionService; ModelingDocData docData; if (null != (selectionService = (IMonitorSelectionService)ExternalServiceProvider.GetService(typeof(IMonitorSelectionService))) && null != (docData = selectionService.CurrentDocument as ModelingDocData) && testStore == (spyOnStore = docData.Store)) { calledShow = true; Show(); spyOnStore = myStore; // Sanity check in case something went wrong } else { return(false); } } if (testStore == spyOnStore) { DiagramView diagramView = myDiagramView; Diagram oldDiagram = diagramView.Diagram; bool reselectOldDiagram = false; if (oldDiagram != null) { reselectOldDiagram = oldDiagram == diagram; if (!reselectOldDiagram) { myDisassociating = true; try { oldDiagram.Disassociate(diagramView); } finally { myDisassociating = false; } } } if (!reselectOldDiagram) { MultiDiagramDocView.DeactivateMouseActions(diagram.ActiveDiagramView); diagram.Associate(diagramView); } AdjustVisibility(true, false); if (!calledShow) { calledShow = true; Show(); } if (reselectOldDiagram && diagramView.Selection.PrimaryItem != null) { OnSelectionChanging(EventArgs.Empty); OnSelectionChanged(EventArgs.Empty); } else { SetSelectedComponents(new object[] { diagram }); } DiagramClientView clientView; if (calledShow && !(clientView = diagramView.DiagramClientView).Focused) { clientView.Focus(); } return(true); } } return(false); }