void label_IsPressedChanged(object sender, EventArgs e) { TabLabel label = (TabLabel)sender; if (label.IsPressed == true) { PageData pageData = (PageData)label.Tag; pageData.Page.Visible = true; // The StorageDatabaseManager UserControl does not fire the TabPag_Paint event in some cases // When maximizing the CSStorageServerManager.exe, and then clicking the Database Manager tab, the database manager is clipped to the previous smaller size. // Calling the TabPage_Paint event clips tothe proper size // The purpose of the TabPage_Paint event is to draw the control (i.e Control Panel, Event Log, etc.) with rounded corners. StorageDatabaseManager s = pageData.Page as StorageDatabaseManager; if (s != null) { TabPage_Paint(s, null); } if (null != __SelectedLabel) { __SelectedLabel.IsPressed = false; } if (null != SelectedPage) { SelectedPage.Page.Visible = false; } __SelectedLabel = label; SelectedPage = pageData; } }
private void AddTabButton(PageData pageData) { TabLabel label = new TabLabel( ); label.Size = new Size(PagesLocation.X - 9, 50); label.Location = new Point(10, 20 + (60 * Pages.IndexOf(pageData))); label.Text = pageData.Text; label.Tag = pageData; label.BackColor = Color.Red; label.TextAlign = ContentAlignment.MiddleCenter; label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; label.Cursor = Cursors.Hand; Rectangle r = label.ClientRectangle; System.Drawing.Drawing2D.GraphicsPath path = RoundRectangle(r, 8 /*this.CornerRadius*/, Corners.BottomLeft | Corners.TopLeft); label.Region = new Region(path); label.IsPressedChanged += new EventHandler(label_IsPressedChanged); if (_labels.Count == 0) { label.IsPressed = true; } LeftPanel.Controls.Add(label); _labels.Add(label); }