/// <summary> /// Adds the functionality to control a panel from the toolbar /// </summary> /// <param name="panelIndex">The index of the panel to add with respect to the form</param> public void AddPanel(int panelIndex) { MyToolStripButton PanelViewButton = new MyToolStripButton(panelIndex); PanelViewButton.ButtonClicked += ShowHidePanel; PanelViewButton.Text = parent.VisiblePanels[panelIndex].Name; PanelViewButton.Checked = parent.VisiblePanels[panelIndex].MyVisible; PanelViewButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; PanelViewButton.Image = parent.VisiblePanels[panelIndex].PanelIcon; PanelList.Add(PanelViewButton); ShowPanels.DropDownItems.Add(PanelViewButton); }
/// <summary> /// Adds a panel to the tab control and re-draws the control. /// </summary> /// <param name="PanelToAdd">The panel to be added to the control.</param> public void AddPanelToTabControl(MyPanel PanelToAdd) { if (!PanelToAdd.InContentPanel) { PanelsToDisplay.Add(PanelToAdd); PanelToAdd.RemoveToolbarButtons(); PanelToAdd.PanelIndex = PanelsToDisplay.Count - 1; PanelToAdd.InContentPanel = true; //Add tool strip button to close the panel. MyToolStripButton ButtonToAdd; ButtonToAdd = new MyToolStripButton(PanelsToDisplay.Count - 1); ButtonToAdd.Text = PanelToAdd.Name; ButtonToAdd.ButtonClicked += tempButton_CustomCheckedChanged; closePanels.DropDownItems.Add(ButtonToAdd); DisplayControls(); } }
void SetupContextMenu() { closePanels = new ToolStripDropDownButton("Close"); thisContextMenu = new ContextMenuStrip(); thisContextMenu.Items.Add(closePanels); MyToolStripButton tempButton; int index = 0; foreach (MyPanel p in PanelsToDisplay) { tempButton = new MyToolStripButton(index++); tempButton.Text = p.Name; tempButton.ButtonClicked += tempButton_CustomCheckedChanged; closePanels.DropDownItems.Add(tempButton); } this.ContextMenuStrip = thisContextMenu; ContextMenuStrip.Width = 100; }
void SetupComponents() { MyToolStripButton TempButton; //Dock Type DockTypeDropDown = new ToolStripDropDownButton(); DockTypeDropDown.Text = "Item Dock Location"; DockTypeDropDown.ToolTipText = "Select where this item is docked on your screen"; foreach (var DockType in (DockTypes[])Enum.GetValues(typeof(DockTypes))) { TempButton = new MyToolStripButton(DockType); TempButton.Text = Convert.ToString(DockType); TempButton.CheckOnClick = true; if (_parent.DockType == DockType) { TempButton.Checked = true; } TempButton.ButtonClicked += ContextMenuClick; DockTypeDropDown.DropDownItems.Add(TempButton); } //AutoSize AutoSizeDropDown = new ToolStripDropDownButton(); AutoSizeDropDown.Text = "Item Autosize Properties"; AutoSizeDropDown.ToolTipText = "Select how this item can be stretched to fill the screen"; foreach (var AutoSize in (AutosizeTypes[])Enum.GetValues(typeof(AutosizeTypes))) { TempButton = new MyToolStripButton(AutoSize); TempButton.Text = Convert.ToString(AutoSize); TempButton.CheckOnClick = true; if (_parent.AutoSizeType == AutoSize) { TempButton.Checked = true; } TempButton.ButtonClicked += ContextMenuClick; AutoSizeDropDown.DropDownItems.Add(TempButton); } AutoSizeDropDown.Width = 100; //Fill Style FillStyleDropDown = new ToolStripDropDownButton(); FillStyleDropDown.Text = "Item Fill Properties"; FillStyleDropDown.ToolTipText = "Select whether this item fills the screen or is finite-size"; foreach (var FillStyle in (FillStyles[])Enum.GetValues(typeof(FillStyles))) { TempButton = new MyToolStripButton(FillStyle); TempButton.Text = Convert.ToString(FillStyle); TempButton.CheckOnClick = true; if (_parent.FillStyle == FillStyle) { TempButton.Checked = true; } TempButton.ButtonClicked += ContextMenuClick; FillStyleDropDown.DropDownItems.Add(TempButton); } FillStyleDropDown.Width = 100; this.Items.Add(DockTypeDropDown); this.Items.Add(AutoSizeDropDown); this.Items.Add(FillStyleDropDown); }