private void AddButton(PreferencePanel panel) { var btn = new PreferencePanelButton(panel); Panel1.Controls.Add(btn); btn.ButtonClick += new PreferencePanelButton.ButtonClickEventHandler(btn_ButtonClick); }
public void AddPanel(PreferencePanel prefPanel) { if (preferenceContainer1 != null) { preferenceContainer1.AddPanel(prefPanel); } }
public void AddPanel(PreferencePanel panel) { if (!ExistButton(panel)) { AddButton(panel); } }
public PreferencePanelButton(PreferencePanel prefPanel) { TextAlign = System.Drawing.ContentAlignment.MiddleLeft; Text = prefPanel.ButtonText; Dock = DockStyle.Top; UseStyleColors = true; Image = prefPanel.ButtonImage; ImageAlign = ContentAlignment.MiddleRight; Size = new System.Drawing.Size(127, 24); MinimumSize = new System.Drawing.Size(10, 24); PrefPanel = prefPanel; }
private bool ExistButton(PreferencePanel panel) { foreach (Control ctrl in Panel1.Controls) { if (ctrl.GetType().Equals(typeof(PreferencePanelButton)) && ctrl.Text == panel.ButtonText) { return(true); } } return(false); }
private void btn_ButtonClick(PreferencePanelButton btn, PreferencePanel Panel) { if (CanAddPanel(Panel)) { if (Panel2.Controls.Count > 0) { Panel2.Controls.RemoveAt(0); } Panel2.Controls.Add(Panel); btn.Selected = true; } Panel.Dock = DockStyle.Fill; Panel.DocumentClose += Panel_DocumentClose; }
private void Panel_DocumentClose(object sender, PreferencePanel prefPanel) { Panel2.Controls.Remove(prefPanel); }