// // // // ***************************************************************** // **** NewGraphWindow_Click() **** // ***************************************************************** private void NewGraphWindow_Click(object sender, EventArgs e) { if (GraphDisplay == null) { Graphs.GraphHolder holder = new Graphs.GraphHolder(); GraphDisplay = holder; holder.FormClosed += new FormClosedEventHandler(GraphDisplay_FormClosed); holder.IsMdiContainer = true; if (m_ClusterList.Count < holder.m_NumberOfColumns) { holder.m_NumberOfColumns = m_ClusterList.Count; } GraphDisplay.Show(); List <Form> m_GraphForms = new List <Form>(); foreach (Cluster cluster in m_ClusterList) { List <IEngine> engineList = cluster.m_Header.GetEngines(); foreach (IEngine eng in engineList) { if (eng is Graphs.ZGraphControl) { Graphs.ZGraphControl zcontrol = (Graphs.ZGraphControl)eng; if (zcontrol.ParentForm != null) { zcontrol.ParentForm.MdiParent = holder; ((FrontEnds.PopUps.IPopUp)zcontrol.ParentForm).ShowMe(cluster.m_Header); } } } } } }
} // implements IPopUp // #endregion //Properties #region Public Methods // ***************************************************************** // **** Public Methods **** // ***************************************************************** // // // **** ShowMe **** // /// <summary> /// Show the control. Implements IPopUp. /// Called by the GUI thread. /// </summary> /// <param name="spawnControl">Control onto which popup is painted.</param> public void ShowMe(Control spawnControl) { // Tell control we are showing it. if (m_IEngineControl.GetType() == typeof(Graphs.ZGraphControl)) { Graphs.ZGraphControl zGraphControl = (Graphs.ZGraphControl)m_IEngineControl; Clusters.Header header = this.ParentHeader; // grab Cluster header. Form displayForm = header.ParentForm; // grab the form that cluster is in. Clusters.ClusterDisplay display = (Clusters.ClusterDisplay)displayForm; if (display.GraphDisplay != null) // user has spawned a GraphDisplay. { this.MdiParent = display.GraphDisplay; // embed this into GraphDisplay. } zGraphControl.ShowMe(this); } // Disable the "exit" button. this.m_MenuManager = new SystemMenuManager(this, true, SystemMenuManager.MenuItemState.Disabled); Control parentForm = spawnControl.TopLevelControl; this.SuspendLayout(); this.Visible = false; // // Find a good position for the popup. // Rectangle parentRect = parentForm.RectangleToScreen(parentForm.ClientRectangle); int x = parentRect.Left; // parent inside edge coordinate. int y = parentRect.Top; // parent inside edge coordinate. Rectangle spawnRect = parentForm.RectangleToClient(spawnControl.ClientRectangle); int posX = spawnControl.Location.X + x; // Starting guess position... int posY = spawnControl.Location.Y + y; // // Make sure that the popup remains inside the parent form. if (posX + this.Width > parentRect.Right) { posX = parentRect.Right - this.Width; } if (posY + this.Height > parentRect.Bottom) { posY = parentRect.Bottom - this.Height; } // now set locateion posX = Math.Max(0, posX); // keep it from going off the screen to the left. posY = Math.Max(0, posY); this.Location = new Point(MarginSpace + posX, MarginSpace + posY); m_IEngineControl.Regenerate(this, null); // updates values displayed, if needed this.Visible = true; this.ResumeLayout(); }// ShowMe()