private void hsButton_Click(object sender, EventArgs e) { Control.ControlCollection controls = hostPanel.Controls; if (controls.Count == 1) { BaseGaugePage page = (BaseGaugePage)controls[0]; if (!(page is BasePageNoGrid)) { if (!_gridHidden) { page.gridPanel.Visible = false; page.splitter1.Visible = false; hsButton.Text = "show"; _gridHidden = true; } else { page.splitter1.Visible = true; page.gridPanel.Visible = true; hsButton.Text = "hide"; _gridHidden = false; } } } }
private void samplesTree_AfterSelect(object sender, TreeViewEventArgs e) { hsButton.Visible = false; Control.ControlCollection controls = hostPanel.Controls; if (controls.Count == 1) { BaseGaugePage oldPage = (BaseGaugePage)controls[0]; controls.Clear(); oldPage.Dispose(); } if (e.Node.Tag != null) { string className = (string)e.Node.Tag; Assembly asm = Assembly.GetExecutingAssembly(); Type classType = asm.GetType("GaugeDemo." + className); ConstructorInfo ci = classType.GetConstructor(new Type[0]); BaseGaugePage page = (BaseGaugePage)ci.Invoke(null); if (!(page is BasePageNoGrid)) { hsButton.Visible = true; if (_gridHidden) { page.gridPanel.Visible = false; page.splitter1.Visible = false; } } page.captionLabel.Text = e.Node.Text; page.Dock = DockStyle.Fill; controls.Add(page); } }