private void MoveTabOneStepDown() { if (_tabToOpen >= 0) { ToolboxTab opentab = GetTab(_tabToOpen); ToolboxTab movetab = GetTab(_tabToOpen + 1); SelectedTab.Shrink(_moveStep); for (int i = _tabToOpen + 1; i <= _selectedTabIndex; i++) { ToolboxTab t = GetTab(i); t.MoveDown(_moveStep); } opentab.Growth(_moveStep); int endpoint = GetTabTopFromBottom(_tabToOpen + 1); if (movetab.Top >= endpoint) { EndAllMovements(); if (TabChanged != null) { ToolBoxEventArgs ea = new ToolBoxEventArgs( SelectedTab.Caption, "", "", SelectedTabIndex, -1, null); TabChanged(this, ea); } // opentab.ReDraw(); // SelectedTab.ReDraw(); } } }
private void OnSelectTab(object sender, EventArgs e) { EndAllMovements(); ToolboxTab tab = sender as ToolboxTab; tab.LayoutItems(); _tabToOpen = _tabs.IndexOf(tab); tab.SuspendMouseEvents = true; if (_moveTickInterval <= 0) { EndAllMovements(); } else { if (_tabToOpen < _selectedTabIndex) { _scrollUpButton.Visible = false; _scrollDownButton.Visible = false; _moveTabDown = true; StartTimer(_moveTickInterval); } else if (_tabToOpen > _selectedTabIndex) { _scrollUpButton.Visible = false; _scrollDownButton.Visible = false; _moveTabUp = true; StartTimer(_moveTickInterval); } } }
/// <summary> /// Add a new item to the Toolbox /// </summary> /// <param name="caption">the caption of the new item</param> /// <param name="id">the id to be used to identify the item</param> /// <param name="descr">the description to use in the tooltip</param> /// <param name="imageIndex">the index inside the tab's ImageList to use</param> /// <param name="tag">an optional object that has to be associated to this item</param> /// <param name="menu">the menu to associate to this item. It overrides the tab context menu</param> /// <param name="tabIndex">the index of the tab the item has to be added to</param> /// <returns></returns> public int AddItem(string caption, string id, string descr, int imageIndex, object tag, ContextMenu menu, int tabIndex) { ToolboxTab tab = GetTab(tabIndex); return(tab.AddItem(caption, id, descr, imageIndex, tag, menu)); }
private void MoveTabOneStepUp() { if (_tabToOpen >= 0) { ToolboxTab seltab = SelectedTab; ToolboxTab tab = GetTab(_tabToOpen); if (tab != null) { seltab.Shrink(_moveStep); for (int i = _selectedTabIndex + 1; i <= _tabToOpen; i++) { ToolboxTab t = GetTab(i); t.MoveUp(_moveStep); } tab.Growth(_moveStep); int endpoint = GetTabTop(_tabToOpen); if (tab.Top <= endpoint) { EndAllMovements(); if (TabChanged != null) { ToolBoxEventArgs ea = new ToolBoxEventArgs( SelectedTab.Caption, "", "", SelectedTabIndex, -1, null); TabChanged(this, ea); } } //SelectedTab.ReDraw(); //tab.ReDraw(); } } }
/// <summary> /// Add a new tab to the toolbox. The new tab will reference the default ImageList /// </summary> /// <param name="caption">the caption of the new tab</param> /// <param name="menu">the default context menu to use inside this tab</param> /// <returns>the index of the new tab inside the Toolbox</returns> public int AddTab(string caption, ContextMenu menu) { ToolboxTab tab = new ToolboxTab(caption, _defaultImageList, _panel); InitializeTab(tab, menu); return(SelectedTabIndex); }
/// <summary> /// Remove an item /// </summary> /// <param name="tabindex">the index of the tab the item to remove belongs to</param> /// <param name="itemindex">the index of the item to remove</param> public void RemoveItem(int tabindex, int itemindex) { if (tabindex >= 0 && tabindex < TabsCount) { ToolboxTab tab = GetTab(tabindex); tab.RemoveItem(itemindex); } }
/// <summary> /// Removes all the items from the tab with a specified index /// </summary> /// <param name="index">The index of the tab to clear</param> public void ClearTab(int index) { if (index >= 0 && index < _tabs.Count) { ToolboxTab tab = GetTab(index); if (tab != null) { tab.Clear(); } } }
private void LayoutTabs() { int w = TabWidth; int opentabheight = SelectedTabHeight - _vMargin; for (int i = 0; i < _tabs.Count; i++) { ToolboxTab tab = (ToolboxTab)_tabs[i]; int offset = 0; int h = 0; if (i == SelectedTabIndex || i == SelectedTabIndex + 1) { offset = _scrollButtonWidth + _scrollButtonOffset; } if (i == SelectedTabIndex) { h = opentabheight; tab.OpenTabBackColor = _openTabBackColor; tab.OpenTabForeColor = _openTabForeColor; } else { tab.OpenTabBackColor = _buttonColor; tab.OpenTabForeColor = ForeColor; } if (i <= _selectedTabIndex) { tab.Location(_hMargin, GetTabTop(i)); } else { tab.Location(_hMargin, GetTabTopFromBottom(i)); } tab.Size(w, h, offset); } if (SelectedTabIndex >= 0) { _scrollUpButton.Visible = true; _scrollDownButton.Visible = true; _scrollUpButton.Left = ScrollButtonLeft; _scrollDownButton.Left = ScrollButtonLeft; _scrollUpButton.Top = SelectedTabIndex * (ToolboxTab.ButtonHeight + _vMargin) + _vMargin; _scrollDownButton.Top = _scrollUpButton.Top + SelectedTabHeight + ToolboxTab.ButtonHeight; } else { _scrollUpButton.Visible = false; _scrollDownButton.Visible = false; } }
/// <summary> /// Returns the index of the tab with a specific caption /// </summary> /// <param name="caption">the caption of the tab to return</param> /// <returns>the index of the tab, -1 if the tab is not found</returns> public int GetTabIndex(string caption) { int index = -1; for (int i = 0; i < _tabs.Count; i++) { ToolboxTab tab = GetTab(i); if (tab != null && tab.Caption == caption) { index = i; break; } } return(index); }
private void ScrollDownItems() { ToolboxTab tab = SelectedTab; if (tab != null && tab.ItemsCount > 0) { if (tab.ScrollDownItems()) { tab.ReDraw(); } else { EndAllMovements(); } } }
/// <summary> /// Remove a Tab /// </summary> /// <param name="index">the index of the tab to remove</param> public void RemoveTab(int index) { EndAllMovements(); if (index >= 0 && index < TabsCount) { ToolboxTab tab = GetTab(index); tab.Remove(); _tabs.Remove(tab); if (SelectedTabIndex >= TabsCount) { SelectedTabIndex = TabsCount - 1; } else { LayoutTabs(); } } }
private void InitializeTab(ToolboxTab tab, ContextMenu menu) { tab.ItemHoverBorder = _itemHoverBorder; tab.ItemHooverBrush = _itemHooverBrush; tab.AllowSelection = _allowSelection; tab.TabSelected += new EventHandler(OnSelectTab); tab.ItemActivate += new EventHandler(OnItemActivate); tab.ItemSelected += new EventHandler(OnSelectItem); tab.ItemDrag += new EventHandler(OnItemDrag); tab.ButtonColor = _buttonColor; tab.BackgroundBrush = _backgroundBrush; tab.SelectionBrush = _selectionBrush; tab.ItemSelectionBorder = _itemSelectionBorder; tab.TextBrush = _textBrush; tab.ToolTip = _toolTip; tab.ContextMenu = menu; SelectedTabIndex = _tabs.Add(tab); LayoutTabs(); }