/// <summary> /// Handles event from WinPart when that /// WinPart is closing. /// </summary> private void CloseWinPart(object sender, EventArgs e) { WinPart part = (WinPart)sender; part.CloseWinPart -= new EventHandler(CloseWinPart); part.Visible = false; Panel1.Controls.Remove(part); part.Dispose(); if (DocumentCount == 0) { this.DocumentsToolStripDropDownButton.Enabled = false; this.Text = "Project Tracker"; } else { // Find the first WinPart control and set // the main form's Text property accordingly. // This works because the first WinPart // is the active one. foreach (Control ctl in Panel1.Controls) { if (ctl is WinPart) { this.Text = "Project Tracker - " + ((WinPart)ctl).ToString(); break; } } } }
/// <summary> /// Make the specified WinPart the /// active, displayed control. /// </summary> /// <param name="part">The WinPart control to display.</param> private void ShowWinPart(WinPart part) { part.Dock = DockStyle.Fill; part.Visible = true; part.BringToFront(); this.Text = "Project Tracker - " + part.ToString(); }
/// <summary> /// Add a new WinPart control to the /// list of available documents and /// make it the active WinPart. /// </summary> /// <param name="part">The WinPart control to add and display.</param> private void AddWinPart(WinPart part) { part.CloseWinPart += new EventHandler(CloseWinPart); part.BackColor = toolStrip1.BackColor; Panel1.Controls.Add(part); this.DocumentsToolStripDropDownButton.Enabled = true; ShowWinPart(part); }
/// <summary> /// Make selected WinPart the active control. /// </summary> private void DocumentClick(object sender, EventArgs e) { WinPart ctl = (WinPart)((ToolStripItem)sender).Tag; ShowWinPart(ctl); }