public void InsertTabButtonTest() { _tabControl.TabPages.Insert(0, "2"); _tabControl.TabPages.Insert(0, "1"); _tabControl.TabPages.Insert(0, "0"); NuGenTabButton tabButton = _tabControl.TabButtons[0]; NuGenTabButton tabButton2 = _tabControl.TabButtons[1]; NuGenTabButton tabButton3 = _tabControl.TabButtons[2]; for (int i = 0; i < _tabControl.TabPages.Count; i++) { Assert.AreEqual(i.ToString(), _tabControl.TabButtons[i].Text); } }
/// <summary> /// </summary> public void RebuildLayout(Rectangle tabStripBounds) { if (tabStripBounds == Rectangle.Empty) { return; } NuGenTabButton selectedTabButton = null; int currentLeftOffset = tabStripBounds.Left; int defaultWidth = this.TabButtons.Count * this.DefaultTabButtonSize.Width; int tabButtonWidth = this.DefaultTabButtonSize.Width; if (defaultWidth > tabStripBounds.Width) { tabButtonWidth = tabStripBounds.Width / this.TabButtons.Count; } foreach (NuGenTabButton tabButton in this.TabButtons) { tabButton.Width = tabButtonWidth; tabButton.Height = tabStripBounds.Height; tabButton.Top = tabStripBounds.Top; tabButton.Left = currentLeftOffset; currentLeftOffset += tabButton.Width; if (tabButton.Selected) { Debug.Assert(selectedTabButton == null, "selectedTabButton == null"); selectedTabButton = tabButton; } } /* Selected */ if (selectedTabButton != null && selectedTabButton.Enabled) { selectedTabButton.Top += this.SelectedTabButtonOffset.Top; selectedTabButton.Left += this.SelectedTabButtonOffset.Left; selectedTabButton.Width += this.SelectedTabButtonOffset.Width; selectedTabButton.Height += this.SelectedTabButtonOffset.Height; selectedTabButton.BringToFront(); } }