private void ArrangeButtonsForMultiRowStyle() { if (_leftScrollButton != null) { this.Controls.Remove(_leftScrollButton); this.Controls.Remove(_rightScrollButton); _leftScrollButton = _rightScrollButton = null; } int x = 2; int y = 3; int i = 0; foreach (Control c in Controls) { TabBarButton button = c as TabBarButton; if (button == null) { continue; } SetButtonText(button, i, (ConnectionTag)button.Tag); if (x + button.Width >= this.Width) { x = 2; y += UNITHEIGHT; } button.Left = x; button.Width = GetNecessaryButtonWidth((ConnectionTag)button.Tag); x += button.Width + BUTTON_MARGIN; button.Top = y; button.Visible = true; button.Height = UNITHEIGHT - 4; button.Invalidate(); i++; } this.Height = y + UNITHEIGHT; }
public void SetActiveTab(ConnectionTag active) { foreach (ConnectionTag ct in GEnv.Connections) { TabBarButton b = ct.Button as TabBarButton; if (b == null) { continue; } if (active == ct) { b.BackColor = _activeTabColor; b.Font = _activeTabFont; b.Selected = true; if (GApp.Options.TabBarStyle == TabBarStyle.ScrollButton) { if (!b.Visible) { int index = GEnv.Connections.IndexOf(ct); if (index != -1) { EnsureButtonVisible(index); } } } } else { b.BackColor = SystemColors.Control; b.Font = _basicFont; b.Selected = false; } b.Invalidate(); } }