public TabPanel() { InitializeComponent(); // Initialize content/index tab control TabControl = new VerticalTabControl(); TabControl.Vertical = false; TabControl.Dock = DockStyle.Fill; TabControl.BackColor = Color.White; TabControl.BorderColor = Color.FromArgb(191, 191, 191); TabControl.Font = new Font("Verdana", 8, FontStyle.Bold); // Add tab control into the panel this.Controls.Add(TabControl); }
/// <summary> /// Draw horizontal button back on the graphics specified. /// </summary> /// <param name="graphics">Button graphics object.</param> private void DrawHorizontalButtonBack(Graphics graphics) { // Define button radius int radius = (int)Math.Round(this.ClientRectangle.Height / 3.0); // Draw background image VerticalTabControl tabControl = this.Parent as VerticalTabControl; if (tabControl != null && tabControl.BackgroundImage != null) { int height = tabControl.GetButtonHeight() + 1; // Draw image in the background of the tab controls. // Image must be aligne to the bottom-right corner of the tabs area. Rectangle destRect = new Rectangle( tabControl.Right - tabControl.BackgroundImage.Width + tabControl.BackImageOffsetX - this.Left, 0, tabControl.BackgroundImage.Width, height); ImageAttributes imageAttributes = new ImageAttributes(); graphics.DrawImage( tabControl.BackgroundImage, destRect, 0, tabControl.BackImageOffsetY + this.Top, tabControl.BackgroundImage.Width, height, GraphicsUnit.Pixel, imageAttributes); } // Create button border path using (GraphicsPath buttonPath = new GraphicsPath()) { // Left vertical line buttonPath.AddLine( this.ClientRectangle.X, this.ClientRectangle.Bottom, this.ClientRectangle.X, this.ClientRectangle.Y + radius); // Top left arc buttonPath.AddArc( this.ClientRectangle.X, this.ClientRectangle.Y, 2 * radius, 2 * radius, 180, 90); // Top horizontal line buttonPath.AddLine( this.ClientRectangle.X + radius, this.ClientRectangle.Y, this.ClientRectangle.Right - radius, this.ClientRectangle.Y); // Top right arc buttonPath.AddArc( this.ClientRectangle.Right - 1 - 2 * radius, this.ClientRectangle.Y, 2 * radius, 2 * radius, 270, 90); // Right vertical line buttonPath.AddLine( this.ClientRectangle.Right - 1, this.ClientRectangle.Y + radius, this.ClientRectangle.Right - 1, this.ClientRectangle.Bottom); // Bottom horizontal line if (!this.SelectedTab) { buttonPath.AddLine( this.ClientRectangle.X, this.ClientRectangle.Bottom - 1, this.ClientRectangle.Right, this.ClientRectangle.Bottom - 1); } // Fill button background if (this.SelectedTab) { Rectangle brushRect = this.ClientRectangle; using (LinearGradientBrush backBrush = new LinearGradientBrush(brushRect, this.selectedGradientBackColor, this.BackColor, 90)) { Blend blend = new Blend(3); blend.Positions[0] = 0.0f; blend.Positions[1] = 0.8f; blend.Positions[2] = 1.0f; blend.Factors[0] = 0.0f; blend.Factors[1] = 1.0f; blend.Factors[2] = 1.0f; backBrush.Blend = blend; graphics.FillPath(backBrush, buttonPath); } } else { using (SolidBrush backBrush = new SolidBrush((this.SelectedTab) ? this.BackColor : nonSelectedBackColor)) { graphics.FillPath(backBrush, buttonPath); } } // Draw button border using Anti-Aliasing using (Pen pen = new Pen(this.borderColor, 1)) { SmoothingMode oldMode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.DrawPath(pen, buttonPath); graphics.SmoothingMode = oldMode; } } }
/// <summary> /// The constructor, which takes the vertical tab control owner of this object. /// <seealso cref="VerticalTabControl"/> /// <seealso cref="VerticalTabPage"/> /// </summary> /// <param name="tabControl">Owner of the collection.</param> public VerticalTabPageCollection(VerticalTabControl tabControl) { this.tabControl = tabControl; }