public MainForm() { // // Required for Windows Form Designer support // InitializeComponent(); // Analyse current graphics resolution Graphics g = this.CreateGraphics(); if(g != null) { if(g.DpiX != 96 || g.DpiY != 96) { this.scaleRatioX = g.DpiX/96f; this.scaleRatioY = g.DpiY/96f; } } g.Dispose(); // Load settings from XML data file LoadSettings(); // Initialize content/index tab control tabControlContent = new VerticalTabControl(); tabControlContent.Vertical = false; tabControlContent.Dock = DockStyle.Fill; tabControlContent.BackColor = Color.White; tabControlContent.BorderColor = Color.FromArgb(191,191,191); tabControlContent.Font = new Font("Verdana", 8, FontStyle.Bold); // Add Content page tabControlContent.TabPages.Add("Contents"); tabControlContent.TabPages[0].Controls.Add(this.treeSamples); this.treeSamples.Dock = DockStyle.Fill; // Add Index page tabControlContent.TabPages.Add("Index"); tabControlContent.TabPages[1].Controls.Add(this.panelIndex); this.panelIndex.Dock = DockStyle.Fill; // Add event handler when selected tab changes tabControlContent.SelectedIndexChanged += new System.EventHandler(this.tabControlContent_SelectedIndexChanged); // Add tab control into the panel this.panelTree.Controls.Add(tabControlContent); // Initialize sample tab control tabControlSample.Vertical = false; tabControlSample.BackColor = Color.White; tabControlSample.BorderColor = Color.FromArgb(191,191,191); tabControlSample.Font = new Font("Verdana", 8, FontStyle.Bold); tabControlSample.ForeColor = Color.FromArgb(117,117,117); // Position sample tab control so that top of the tabs aligned with the // bottom of content tabs int tabHeight = tabControlContent.GetButtonHeight() + 1; tabControlSample.Height += tabControlSample.Top - tabHeight; tabControlSample.Top = tabControlContent.Top + tabHeight; // Set sample tab control image tabControlSample.BackgroundImage = (Image)pictureBoxHeaderRight.Image.Clone(); tabControlSample.BackImageOffsetX = pictureBoxHeaderRight.Right - (tabControlSample.Right + panelContent.Left) + 4; tabControlSample.BackImageOffsetY = panelContent.Top + tabControlSample.Top; // Add Content page tabControlSample.TabPages.Add("Sample"); tabControlSample.TabPages[0].Font = new Font("Verdana", 9); tabControlSample.TabPages[0].ForeColor = Color.FromArgb(26,59,105); // Add event handler when selected sample tab changes tabControlSample.SelectedIndexChanged += new System.EventHandler(this.tabControlSample_SelectedIndexChanged); // Set sample title image and position labelSampleTitle.Top = tabControlSample.Top + panelContent.Top - labelSampleTitle.Height; labelSampleTitle.BackImage = (Image)pictureBoxHeaderRight.Image.Clone(); // Align sample title with the splitter labelSampleTitle.Left = splitterVertical.Right + 5; if(labelSampleTitle.Left < 264) { labelSampleTitle.Left = 264; } labelSampleTitle.Width = this.Width - labelSampleTitle.Left - 4; // Update size of the components to fit specified images panelHeader.Height = pictureBoxHeaderLeft.Image.Height; //panelFooter.Height = pictureBoxFooterRight.Image.Height; // Scale Prev/Next buttons if(this.scaleRatioX != 1f || this.scaleRatioY != 1f) { buttonSamplePrevious.Width = (int)(buttonSamplePrevious.Width * this.scaleRatioX); buttonSamplePrevious.Height = (int)(buttonSamplePrevious.Height *this.scaleRatioY); buttonSampleNext.Width = (int)(buttonSampleNext.Width * this.scaleRatioX); buttonSampleNext.Height = (int)(buttonSampleNext.Height * this.scaleRatioY); } // Position Prev/Next buttons buttonSamplePrevious.Top = labelSampleTitle.Bottom + 1; buttonSampleNext.Top = labelSampleTitle.Bottom + 1; buttonSampleNext.Left = this.Width - buttonSampleNext.Width - 15; buttonSamplePrevious.Left = buttonSampleNext.Left - buttonSamplePrevious.Width - 5; }
/// <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; }
/// <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; }
/// <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; } } }