/// <summary> /// Draws the tab border /// </summary> /// <param name="g"></param> /// <param name="path"></param> /// <param name="ct"></param> protected override void DrawTabBorder(Graphics g, GraphicsPath path, SuperTabItemStateColorTable ct) { base.DrawTabBorder(g, path, ct); // Draw the Backstage selection marker if (ct.SelectionMarker.IsEmpty == false) DrawSelMarker(g, ct); }
/// <summary> /// Draws the tab border /// </summary> /// <param name="g">Graphics</param> /// <param name="path">Tab path</param> /// <param name="ct">Color table</param> protected virtual void DrawTabBorder( Graphics g, GraphicsPath path, SuperTabItemStateColorTable ct) { using (Pen pen = new Pen(ct.InnerBorder, 2)) { Region rgn = g.Clip; g.SetClip(path); g.DrawPath(pen, path); g.DrawPath(pen, path); g.DrawPath(pen, path); g.DrawPath(pen, path); g.Clip = rgn; if (rgn != null) rgn.Dispose(); } using (Pen pen = new Pen(ct.OuterBorder)) g.DrawPath(pen, path); }
internal void DrawTabItemGradientBackground( Graphics g, GraphicsPath path, SuperTabItemStateColorTable tabColors, Rectangle r) { int angle = tabColors.Background.GradientAngle; if (tabColors.Background.AdaptiveGradient != false) { switch (_TabItem.TabAlignment) { case eTabStripAlignment.Left: angle -= 90; break; case eTabStripAlignment.Bottom: angle += 180; break; case eTabStripAlignment.Right: angle += 90; break; } } using (LinearGradientBrush lbr = (LinearGradientBrush)tabColors.Background.GetBrush(r, angle)) { if (lbr != null) { lbr.WrapMode = WrapMode.TileFlipXY; g.FillPath(lbr, path); SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = SmoothingMode.None; int n = (_TabItem.IsSelected == true) ? 3 : 1; switch (_TabItem.TabAlignment) { case eTabStripAlignment.Top: g.FillRectangle(lbr, r.X, r.Bottom, r.Width, n); break; case eTabStripAlignment.Left: g.FillRectangle(lbr, r.Right, r.Top, n, r.Height); break; case eTabStripAlignment.Bottom: g.FillRectangle(lbr, r.X, r.Top - n + 1, r.Width, n); break; case eTabStripAlignment.Right: g.FillRectangle(lbr, r.X - n + 1, r.Top, n, r.Height); break; } g.SmoothingMode = sm; } } }
internal void DrawTabItemSolidBackground( Graphics g, GraphicsPath path, SuperTabItemStateColorTable tabColors, Rectangle r) { using (Brush br = tabColors.Background.GetBrush(r)) { if (br != null) { g.FillPath(br, path); using (Pen pen = new Pen(tabColors.Background.Colors[0])) { int n = (_TabItem.IsSelected == true) ? 3 : 1; for (int i = 0; i < n; i++) { switch (_TabItem.TabAlignment) { case eTabStripAlignment.Top: g.DrawLine(pen, r.X, r.Bottom + i, r.Right, r.Bottom + i); break; case eTabStripAlignment.Left: g.DrawLine(pen, r.Right + i, r.Top, r.Right + i, r.Bottom); break; case eTabStripAlignment.Bottom: g.DrawLine(pen, r.X, r.Top - i, r.Right, r.Top - i); break; case eTabStripAlignment.Right: g.DrawLine(pen, r.X - i, r.Top, r.X - i, r.Bottom); break; } } } } } }
public void ResetNormal() { Normal = new SuperTabItemStateColorTable(); }
/// <summary> /// DrawTabItemBackground /// </summary> /// <param name="g"></param> /// <param name="path"></param> /// <param name="tabColors"></param> protected override void DrawTabItemBackground(Graphics g, GraphicsPath path, SuperTabItemStateColorTable tabColors) { Rectangle r = Rectangle.Round(path.GetBounds()); if (r.Width > 0 && r.Height > 0) { if (tabColors.Background.Colors != null) { if (tabColors.Background.Colors.Length == 1) { DrawTabItemSolidBackground(g, path, tabColors, r); if (TabItem.IsSelected == true && TabItem.EffectiveStyle != eDotNetBarStyle.Metro) DrawTabItemHighLight(g, path, tabColors, r); } else { DrawTabItemGradientBackground(g, path, tabColors, r); } } } }
public object Clone() { SuperTabItemStateColorTable sct = new SuperTabItemStateColorTable(); sct.Background = (SuperTabLinearGradientColorTable)Background.Clone(); sct.Text = Text; sct.OuterBorder = OuterBorder; sct.InnerBorder = InnerBorder; sct.CloseMarker = CloseMarker; sct.SelectionMarker = SelectionMarker; return (sct); }
/// <summary> /// Draws the tab text /// </summary> /// <param name="g"></param> /// <param name="colors"></param> protected virtual void DrawTabText(Graphics g, SuperTabItemStateColorTable colors) { if (TabStripItem.DisplaySelectedTextOnly == false || TabItem.IsSelected == true) { Rectangle r = TabItem.TextBounds; Font font = TabItem.GetTabFont(); if (TabItem.IsVertical == false) { if (TabItem.TextMarkupBody != null) { r = AlignText(r); TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, colors.Text, TabItem.IsRightToLeft); TabItem.TextMarkupBody.Arrange(new Rectangle(r.Location, TabItem.TextMarkupBody.Bounds.Size), d); RenderMarkup(g, r, d); } else { eTextFormat strFormat; r = AlignText(r, out strFormat); TextDrawing.DrawString(g, TabItem.Text, font, colors.Text, r, strFormat); } } else { if (TabItem.TextMarkupBody != null) { Rectangle t = TabItem.TextMarkupBody.Bounds; r = SetTransform(g, r); r = AlignText(r); TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, colors.Text, TabItem.IsRightToLeft); TabItem.TextMarkupBody.Bounds = r; RenderMarkup(g, r, d); TabItem.TextMarkupBody.Bounds = t; } else { eTextFormat strFormat; r = SetTransform(g, r); r = AlignText(r, out strFormat); TextDrawing.DrawStringLegacy(g, TabItem.Text, font, colors.Text, r, strFormat); } ResetTransform(g); } if (TabDisplay.ShowFocusRectangle && TabItem.IsSelected) ControlPaint.DrawFocusRectangle(g, GetFocusRectangle(TabItem.DisplayRectangle)); } }
public void ResetDisabled() { Disabled = new SuperTabItemStateColorTable(); }
private void SetNewColorTable( ref SuperTabItemStateColorTable sct, SuperTabItemStateColorTable newSct) { if (sct != null) sct.ColorTableChanged -= SctColorTableChanged; sct = newSct; if (sct != null) sct.ColorTableChanged += SctColorTableChanged; OnColorTableChanged(); }
public void ResetSelectedMouseOver() { SelectedMouseOver = new SuperTabItemStateColorTable(); }
public void ResetMouseOver() { MouseOver = new SuperTabItemStateColorTable(); }
public void ResetSelected() { Selected = new SuperTabItemStateColorTable(); }
/// <summary> /// Draws the tab contents /// </summary> /// <param name="g">Graphics</param> /// <param name="colors">State color table</param> protected virtual void DrawTabContent(Graphics g, SuperTabItemStateColorTable colors) { // Draw image and text DrawTabImage(g); DrawTabText(g, colors); // Draw the close button if (TabStripItem.CloseButtonOnTabsVisible && TabItem.CloseButtonVisible) { if (TabStripItem.CloseButtonOnTabsAlwaysDisplayed == true || TabItem.IsMouseOver == true) DrawCloseButton(g, colors); } }
/// <summary> /// Creates the close button bitmap /// </summary> /// <param name="g">Graphics</param> /// <param name="colors">State color table</param> /// <returns>Close bitmap</returns> public virtual Bitmap CreateCloseButtonBitmap(Graphics g, SuperTabItemStateColorTable colors) { Bitmap bmp = new Bitmap(16, 16, g); using (Graphics gBmp = Graphics.FromImage(bmp)) { gBmp.CompositingQuality = CompositingQuality.HighQuality; gBmp.SmoothingMode = g.SmoothingMode; using (Pen pen = new Pen(colors.CloseMarker)) { gBmp.DrawLine(pen, new Point(4, 4), new Point(10, 9)); gBmp.DrawLine(pen, new Point(10, 4), new Point(4, 9)); } } return (bmp); }
/// <summary> /// Draws the tab close button /// </summary> /// <param name="g">Graphics</param> /// <param name="colors">State color table</param> protected virtual void DrawCloseButton(Graphics g, SuperTabItemStateColorTable colors) { Rectangle r = TabItem.CloseButtonBounds; if (TabItem.CloseButtonMouseOver == true || TabItem.CloseButtonPressed == true) { if (TabItem.CloseButtonMouseOver == true && TabItem.CloseButtonPressed == true) { if (TabStripItem.TabCloseButtonPressed != null) g.DrawImageUnscaled(TabStripItem.TabCloseButtonPressed, r); else g.DrawImageUnscaled(GetCloseButtonPressedBitmap(g), r); } else { if (TabStripItem.TabCloseButtonHot != null) g.DrawImageUnscaled(TabStripItem.TabCloseButtonHot, r); else g.DrawImageUnscaled(GetCloseButtonHotBitmap(g), r); } } else { if (TabStripItem.TabCloseButtonNormal != null) g.DrawImageUnscaled(TabStripItem.TabCloseButtonNormal, r); else g.DrawImageUnscaled(GetCloseButtonBitmap(g, colors), r); } }
internal virtual void ApplyPredefinedColor(eTabState tabState, SuperTabItemStateColorTable sct) { if (TabItem.PredefinedColor != eTabItemColor.Default) { SuperTabItemColorTable ct = SuperTabStyleColorFactory.GetPredefinedTabColors(TabItem.PredefinedColor, ColorFactory.Empty); SuperTabItemStateColorTable ict = ct.Default.Normal; switch (tabState) { case eTabState.SelectedMouseOver: ict = ct.Default.SelectedMouseOver; break; case eTabState.MouseOver: ict = ct.Default.MouseOver; break; case eTabState.Selected: ict = ct.Default.Selected; break; } sct.Text = ict.Text; sct.InnerBorder = ict.InnerBorder; sct.OuterBorder = ict.OuterBorder; sct.Background = ict.Background; sct.CloseMarker = ict.CloseMarker; sct.SelectionMarker = ict.SelectionMarker; } }
/// <summary> /// Gets the tab close button bitmap /// </summary> /// <param name="g">Graphics</param> /// <param name="colors">State color table</param> /// <returns>Button bitmap</returns> public Bitmap GetCloseButtonBitmap(Graphics g, SuperTabItemStateColorTable colors) { if (_CloseMarkerColor != colors.CloseMarker || _CloseButtonBitmap == null) { if (_CloseButtonBitmap != null) _CloseButtonBitmap.Dispose(); _CloseButtonBitmap = CreateCloseButtonBitmap(g, colors); _CloseMarkerColor = colors.CloseMarker; } return (_CloseButtonBitmap); }
private void ApplyTabColors( SuperTabItemStateColorTable sct, SuperTabItemStateColorTable tct) { if (tct.Background.IsEmpty == false) { if (tct.Background.IsEmpty == false) { if (tct.Background.Colors != null) sct.Background.Colors = tct.Background.Colors; if (tct.Background.Positions != null) sct.Background.Positions = tct.Background.Positions; if (tct.Background.AdaptiveGradient.HasValue) sct.Background.AdaptiveGradient = tct.Background.AdaptiveGradient; } sct.Background.GradientAngle = tct.Background.GradientAngle; } if (tct.InnerBorder != Color.Empty) sct.InnerBorder = tct.InnerBorder; if (tct.OuterBorder != Color.Empty) sct.OuterBorder = tct.OuterBorder; if (tct.Text != Color.Empty) sct.Text = tct.Text; if (tct.CloseMarker != Color.Empty) sct.CloseMarker = tct.CloseMarker; if (tct.SelectionMarker != Color.Empty) sct.SelectionMarker = tct.SelectionMarker; }
/// <summary> /// DrawTabItemHighLight /// </summary> /// <param name="g"></param> /// <param name="path"></param> /// <param name="tabColors"></param> /// <param name="r"></param> private void DrawTabItemHighLight( Graphics g, GraphicsPath path, SuperTabItemStateColorTable tabColors, Rectangle r) { Region clip = g.Clip; g.SetClip(path, CombineMode.Intersect); using (GraphicsPath path2 = new GraphicsPath()) { Rectangle t = r; t.Inflate(r.Width / 3, r.Height / 3); path2.AddEllipse(t); using (PathGradientBrush pbr = new PathGradientBrush(path2)) { pbr.CenterPoint = new PointF(r.X + r.Width / 2, r.Bottom - (r.Height / 4)); pbr.CenterColor = ControlPaint.LightLight(tabColors.Background.Colors[0]); pbr.SurroundColors = new Color[] {Color.Empty}; g.FillPath(pbr, path2); } } g.Clip = clip; }
/// <summary> /// Draws the tab background /// </summary> /// <param name="g">Graphics</param> /// <param name="path">Tab path</param> /// <param name="tabColors">StateColorTable</param> protected virtual void DrawTabItemBackground( Graphics g, GraphicsPath path, SuperTabItemStateColorTable tabColors) { Rectangle r = Rectangle.Round(path.GetBounds()); if (r.Width > 0 && r.Height > 0) { if (tabColors.Background.Colors != null) { if (tabColors.Background.Colors.Length == 1) DrawTabItemSolidBackground(g, path, tabColors, r); else DrawTabItemGradientBackground(g, path, tabColors, r); } } }
/// <summary> /// Draws the Backstage SelectedItem marker /// </summary> /// <param name="g"></param> /// <param name="ct"></param> private void DrawSelMarker(Graphics g, SuperTabItemStateColorTable ct) { Rectangle r = TabItem.DisplayRectangle; Point[] pts; switch (TabStripItem.TabAlignment) { case eTabStripAlignment.Top: r.X += (r.Width - MarkerWidth) / 2; r.Y = r.Bottom - MarkerHeight + 2; r.Width = MarkerWidth; r.Height = MarkerHeight; pts = new Point[] { new Point(r.X, r.Bottom), new Point(r.X + MarkerWidth / 2, r.Y), new Point(r.Right, r.Bottom)}; break; case eTabStripAlignment.Left: r.X = r.Right - MarkerHeight + 2; r.Y += (r.Height - MarkerWidth) / 2; r.Width = MarkerHeight; r.Height = MarkerWidth; pts = new Point[] { new Point(r.Right, r.Bottom), new Point(r.X, r.Y + MarkerWidth / 2), new Point(r.Right, r.Y)}; break; case eTabStripAlignment.Bottom: r.X += (r.Width - MarkerWidth) / 2; r.Y -= 3; r.Width = MarkerWidth; r.Height = MarkerHeight; pts = new Point[] { new Point(r.X, r.Y), new Point(r.X + MarkerWidth / 2, r.Bottom), new Point(r.Right, r.Y)}; break; default: r.X -= 3; r.Y += (r.Height - MarkerWidth) / 2; r.Width = MarkerHeight; r.Height = MarkerWidth; pts = new Point[] { new Point(r.X, r.Y), new Point(r.Right, r.Y + MarkerWidth / 2), new Point(r.X, r.Bottom)}; break; } using (Brush br = new SolidBrush(ct.SelectionMarker)) g.FillPolygon(br, pts); }
public SuperTabColorStates() { _Normal = new SuperTabItemStateColorTable(); _Normal.ColorTableChanged += SctColorTableChanged; _Selected = new SuperTabItemStateColorTable(); _Selected.ColorTableChanged += SctColorTableChanged; _MouseOver = new SuperTabItemStateColorTable(); _MouseOver.ColorTableChanged += SctColorTableChanged; _SelectedMouseOver = new SuperTabItemStateColorTable(); _SelectedMouseOver.ColorTableChanged += SctColorTableChanged; _Disabled = new SuperTabItemStateColorTable(); _Disabled.ColorTableChanged += SctColorTableChanged; }