private void childForm_FormClosed(object sender, FormClosedEventArgs e) { if (sender is DisplayChildForm) { DisplayChildForm childForm = (DisplayChildForm)sender; Diagram diagram = childForm.Display.Diagram; Debug.Assert(diagram != null); // Clean up UnregisterChildFormEvents(childForm); childForm.Display.Diagram = null; childForm.Display.DiagramSetController = null; displayChildForms.Remove(diagram.Name); // Endable menu item foreach (ToolStripMenuItem item in diagramsToolStripMenuItem.DropDownItems) { if (item.Tag == diagram) { item.Enabled = true; break; } } } }
private void ShowDisplayChildForm(Diagram diagram) { DisplayChildForm childForm = new DisplayChildForm(); RegisterChildFormEvents(childForm); childForm.MdiParent = this; childForm.Display.DiagramSetController = diagramSetController; childForm.Display.Diagram = diagram; childForm.Show(); displayChildForms.Add(diagram.Name, childForm); }
private void UnregisterChildFormEvents(DisplayChildForm childForm) { childForm.FormClosed -= childForm_FormClosed; childForm.Disposed -= childForm_Disposed; }