public TabStripItemChangedEventArgs(FATabStripItem item, FATabStripItemChangeTypes type) { changeType = type; itm = item; }
protected override void OnPaint(PaintEventArgs e) { SetDefaultSelected(); Rectangle borderRc = base.ClientRectangle; borderRc.Width--; borderRc.Height--; if (RightToLeft == RightToLeft.No) { DEF_START_POS = 10; } else { DEF_START_POS = stripButtonRect.Right; } e.Graphics.DrawRectangle(SystemPens.ControlDark, borderRc); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; RectangleF selectedButton = Rectangle.Empty; #region Draw Pages for (int i = 0; i < this.Items.Count; i++) { FATabStripItem currentItem = Items[i]; if (!currentItem.Visible && !DesignMode) { continue; } OnCalcTabPage(e.Graphics, currentItem); currentItem.IsDrawn = false; if (!AllowDraw(currentItem)) { continue; } OnDrawTabPage(e.Graphics, currentItem); } #endregion #region Draw UnderPage Line if (RightToLeft == RightToLeft.No) { if (Items.DrawnCount == 0 || Items.VisibleCount == 0) { e.Graphics.DrawLine(SystemPens.ControlDark, new Point(0, DEF_HEADER_HEIGHT), new Point(ClientRectangle.Width, DEF_HEADER_HEIGHT)); } else if (SelectedItem != null && SelectedItem.IsDrawn) { Point end = new Point((int)SelectedItem.StripRect.Left - 9, DEF_HEADER_HEIGHT); e.Graphics.DrawLine(SystemPens.ControlDark, new Point(0, DEF_HEADER_HEIGHT), end); end.X += (int)SelectedItem.StripRect.Width + 10; e.Graphics.DrawLine(SystemPens.ControlDark, end, new Point(ClientRectangle.Width, DEF_HEADER_HEIGHT)); } } else { if (Items.DrawnCount == 0 || Items.VisibleCount == 0) { e.Graphics.DrawLine(SystemPens.ControlDark, new Point(0, DEF_HEADER_HEIGHT), new Point(ClientRectangle.Width, DEF_HEADER_HEIGHT)); } else if (SelectedItem != null && SelectedItem.IsDrawn) { Point end = new Point((int)SelectedItem.StripRect.Left, DEF_HEADER_HEIGHT); e.Graphics.DrawLine(SystemPens.ControlDark, new Point(0, DEF_HEADER_HEIGHT), end); end.X += (int)SelectedItem.StripRect.Width + 20; e.Graphics.DrawLine(SystemPens.ControlDark, end, new Point(ClientRectangle.Width, DEF_HEADER_HEIGHT)); } } #endregion #region Draw Menu and Close Glyphs if (AlwaysShowMenuGlyph || Items.DrawnCount > Items.VisibleCount) { menuGlyph.DrawGlyph(e.Graphics); } if (AlwaysShowClose || (SelectedItem != null && SelectedItem.CanClose)) { closeButton.DrawCross(e.Graphics); } #endregion }
public TabStripItemClosingEventArgs(FATabStripItem item) { _item = item; }
private void OnDrawTabPage(Graphics g, FATabStripItem currentItem) { bool isFirstTab = Items.IndexOf(currentItem) == 0; Font currentFont = this.Font; if (currentItem == SelectedItem) { currentFont = new Font(this.Font, FontStyle.Bold); } SizeF textSize = g.MeasureString(currentItem.Title, currentFont, new SizeF(200, 10), sf); textSize.Width += 20; RectangleF buttonRect = currentItem.StripRect; GraphicsPath path = new GraphicsPath(); int mtop = 3; #region Draw Not Right-To-Left Tab if (RightToLeft == RightToLeft.No) { if (currentItem == SelectedItem || isFirstTab) { path.AddLine(buttonRect.Left - 10, buttonRect.Bottom - 1, buttonRect.Left + (buttonRect.Height / 2) - 4, mtop + 4); } else { path.AddLine(buttonRect.Left, buttonRect.Bottom - 1, buttonRect.Left, buttonRect.Bottom - (buttonRect.Height / 2) - 2); path.AddLine(buttonRect.Left, buttonRect.Bottom - (buttonRect.Height / 2) - 3, buttonRect.Left + (buttonRect.Height / 2) - 4, mtop + 3); } path.AddLine(buttonRect.Left + (buttonRect.Height / 2) + 2, mtop, buttonRect.Right - 3, mtop); path.AddLine(buttonRect.Right, mtop + 2, buttonRect.Right, buttonRect.Bottom - 1); path.AddLine(buttonRect.Right - 4, buttonRect.Bottom - 1, buttonRect.Left, buttonRect.Bottom - 1); path.CloseFigure(); LinearGradientBrush brush = null; if (currentItem == SelectedItem) { brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Window, LinearGradientMode.Vertical); } else { brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical); } g.FillPath(brush, path); g.DrawPath(SystemPens.ControlDark, path); if (currentItem == SelectedItem) { g.DrawLine(new Pen(brush), buttonRect.Left - 9, buttonRect.Height + 2, buttonRect.Left + buttonRect.Width - 1, buttonRect.Height + 2); } PointF textLoc = new PointF(buttonRect.Left + buttonRect.Height - 4, buttonRect.Top + (buttonRect.Height / 2) - (textSize.Height / 2) - 3); RectangleF textRect = buttonRect; textRect.Location = textLoc; textRect.Width = (float)buttonRect.Width - (textRect.Left - buttonRect.Left) - 4; textRect.Height = textSize.Height + currentFont.Size / 2; if (currentItem == SelectedItem) { //textRect.Y -= 2; g.DrawString(currentItem.Title, currentFont, new SolidBrush(this.ForeColor), textRect, sf); } else { g.DrawString(currentItem.Title, currentFont, new SolidBrush(this.ForeColor), textRect, sf); } } #endregion #region Draw Right-To-Left Tab if (RightToLeft == RightToLeft.Yes) { if (currentItem == SelectedItem || isFirstTab) { path.AddLine(buttonRect.Right + 10, buttonRect.Bottom - 1, buttonRect.Right - (buttonRect.Height / 2) + 4, mtop + 4); } else { path.AddLine(buttonRect.Right, buttonRect.Bottom - 1, buttonRect.Right, buttonRect.Bottom - (buttonRect.Height / 2) - 2); path.AddLine(buttonRect.Right, buttonRect.Bottom - (buttonRect.Height / 2) - 3, buttonRect.Right - (buttonRect.Height / 2) + 4, mtop + 3); } path.AddLine(buttonRect.Right - (buttonRect.Height / 2) - 2, mtop, buttonRect.Left + 3, mtop); path.AddLine(buttonRect.Left, mtop + 2, buttonRect.Left, buttonRect.Bottom - 1); path.AddLine(buttonRect.Left + 4, buttonRect.Bottom - 1, buttonRect.Right, buttonRect.Bottom - 1); path.CloseFigure(); LinearGradientBrush brush = null; if (currentItem == SelectedItem) { brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Window, LinearGradientMode.Vertical); } else { brush = new LinearGradientBrush(buttonRect, SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical); } g.FillPath(brush, path); g.DrawPath(SystemPens.ControlDark, path); if (currentItem == SelectedItem) { g.DrawLine(new Pen(brush), buttonRect.Right + 9, buttonRect.Height + 2, buttonRect.Right - buttonRect.Width + 1, buttonRect.Height + 2); } PointF textLoc = new PointF(buttonRect.Left + 2, buttonRect.Top + (buttonRect.Height / 2) - (textSize.Height / 2) - 2); RectangleF textRect = buttonRect; textRect.Location = textLoc; textRect.Width = (float)buttonRect.Width - (textRect.Left - buttonRect.Left) - 10; textRect.Height = textSize.Height + currentFont.Size / 2; if (currentItem == SelectedItem) { textRect.Y -= 1; g.DrawString(currentItem.Title, currentFont, new SolidBrush(this.ForeColor), textRect, sf); } else { g.DrawString(currentItem.Title, currentFont, new SolidBrush(this.ForeColor), textRect, sf); } g.FillRectangle(Brushes.Red, textRect); } #endregion currentItem.IsDrawn = true; }
private void OnMenuItemClicked(object sender, ToolStripItemClickedEventArgs e) { FATabStripItem clickedItem = (FATabStripItem)e.ClickedItem.Tag; SelectedItem = clickedItem; }
internal void UnSelectItem(FATabStripItem tabItem) { tabItem.Selected = false; }
internal void SelectItem(FATabStripItem tabItem) { tabItem.Dock = DockStyle.Fill; tabItem.Selected = true; }
public void AddTab(FATabStripItem tabItem) { Items.Add(tabItem); tabItem.Dock = DockStyle.Fill; }