/// <summary> /// Call to draw the scroll buttons on the tab /// </summary> /// <param name="e"></param> public virtual void OnRenderTabScrollButtons(RibbonTabRenderEventArgs e) { }
/// <summary> /// Draws a complete tab /// </summary> /// <param name="e"></param> public void DrawCompleteTab(RibbonTabRenderEventArgs e) { DrawTabActive(e); //Background gradient using (GraphicsPath path = RoundRectangle(e.Tab.TabContentBounds, 6)) { Color north = ColorTable.TabContentNorth; Color south = ColorTable.TabContentSouth; if (e.Tab.Contextual) { north = ColorTable.DropDownBg; south = north; } using (LinearGradientBrush b = new LinearGradientBrush( new Point(0, e.Tab.TabContentBounds.Top + 30), new Point(0, e.Tab.TabContentBounds.Bottom - 10), north, south)) { b.WrapMode = WrapMode.TileFlipXY; e.Graphics.FillPath(b, path); } } //Glossy effect Rectangle glossy = Rectangle.FromLTRB(e.Tab.TabContentBounds.Left, e.Tab.TabContentBounds.Top, e.Tab.TabContentBounds.Right, e.Tab.TabContentBounds.Top + 18); using (GraphicsPath path = RoundRectangle(glossy, 6, Corners.NorthWest | Corners.NorthEast)) { using (Brush b = new SolidBrush(Color.FromArgb(30, Color.White))) { e.Graphics.FillPath(b, path); } } //Tab border using (GraphicsPath path = CreateCompleteTabPath(e.Tab)) { using (Pen p = new Pen(ColorTable.TabBorder)) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.DrawPath(p, path); } } if (e.Tab.Selected) { //Selected glow using (GraphicsPath path = CreateTabPath(e.Tab)) { Pen p = new Pen(Color.FromArgb(150, Color.Gold)); p.Width = 2; e.Graphics.DrawPath(p, path); p.Dispose(); } } }
/// <summary> /// Renders the text of the tab specified on the event /// </summary> /// <param name="e">Event data and paint tools</param> public virtual void OnRenderRibbonTabText(RibbonTabRenderEventArgs e) { }
public override void OnRenderRibbonTabText(RibbonTabRenderEventArgs e) { StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.Trimming = StringTrimming.EllipsisCharacter; sf.LineAlignment = StringAlignment.Center; sf.FormatFlags |= StringFormatFlags.NoWrap; Rectangle r = Rectangle.FromLTRB( e.Tab.TabBounds.Left + e.Ribbon.TabTextMargin.Left, e.Tab.TabBounds.Top + e.Ribbon.TabTextMargin.Top, e.Tab.TabBounds.Right - e.Ribbon.TabTextMargin.Right, e.Tab.TabBounds.Bottom - e.Ribbon.TabTextMargin.Bottom); using (Brush b = new SolidBrush(GetTextColor(true))) { e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; e.Graphics.DrawString(e.Tab.Text, e.Ribbon.Font, b, r, sf); } }
public override void OnRenderTabScrollButtons(RibbonTabRenderEventArgs e) { if (e.Tab.ScrollLeftVisible) { if (e.Tab.ScrollLeftSelected) { DrawButtonSelected(e.Graphics, e.Tab.ScrollLeftBounds, Corners.West); } else { DrawButton(e.Graphics, e.Tab.ScrollLeftBounds, Corners.West); } DrawArrowShaded(e.Graphics, e.Tab.ScrollLeftBounds, Direction.Right, true); } if (e.Tab.ScrollRightVisible) { if (e.Tab.ScrollRightSelected) { DrawButtonSelected(e.Graphics, e.Tab.ScrollRightBounds, Corners.East); } else { DrawButton(e.Graphics, e.Tab.ScrollRightBounds, Corners.East); } DrawArrowShaded(e.Graphics, e.Tab.ScrollRightBounds, Direction.Left, true); } }
public override void OnRenderRibbonTab(RibbonTabRenderEventArgs e) { if (e.Tab.Active) { DrawCompleteTab(e); } else if (e.Tab.Pressed) { DrawTabPressed(e); } else if (e.Tab.Selected) { DrawTabSelected(e); } else { DrawTabNormal(e); } }
/// <summary> /// Draws a selected tab /// </summary> /// <param name="e"></param> public void DrawTabSelected(RibbonTabRenderEventArgs e) { Rectangle outerR = Rectangle.FromLTRB( e.Tab.TabBounds.Left, e.Tab.TabBounds.Top, e.Tab.TabBounds.Right - 1, e.Tab.TabBounds.Bottom); Rectangle innerR = Rectangle.FromLTRB( outerR.Left + 1, outerR.Top + 1, outerR.Right - 1, outerR.Bottom); Rectangle glossyR = Rectangle.FromLTRB( innerR.Left + 1, innerR.Top + 1, innerR.Right - 1, innerR.Top + e.Tab.TabBounds.Height / 2); GraphicsPath outer = RoundRectangle(outerR, 3, Corners.NorthEast | Corners.NorthWest); GraphicsPath inner = RoundRectangle(innerR, 3, Corners.NorthEast | Corners.NorthWest); GraphicsPath glossy = RoundRectangle(glossyR, 3, Corners.NorthEast | Corners.NorthWest); using (Pen p = new Pen(ColorTable.TabBorder)) { e.Graphics.DrawPath(p, outer); } using (Pen p = new Pen(Color.FromArgb(200, Color.White))) { e.Graphics.DrawPath(p, inner); } using (GraphicsPath radialPath = new GraphicsPath()) { radialPath.AddRectangle(innerR); //radialPath.AddEllipse(innerR); radialPath.CloseFigure(); PathGradientBrush gr = new PathGradientBrush(radialPath); gr.CenterPoint = new PointF( Convert.ToSingle(innerR.Left + innerR.Width / 2), Convert.ToSingle(innerR.Top - 5)); gr.CenterColor = Color.Transparent; gr.SurroundColors = new Color[] { ColorTable.TabSelectedGlow }; Blend blend = new Blend(3); blend.Factors = new float[] { 0.0f, 0.9f, 0.0f }; blend.Positions = new float[] { 0.0f, 0.8f, 1.0f }; gr.Blend = blend; e.Graphics.FillPath(gr, radialPath); gr.Dispose(); } using (SolidBrush b = new SolidBrush(Color.FromArgb(100, Color.White))) { e.Graphics.FillPath(b, glossy); } outer.Dispose(); inner.Dispose(); glossy.Dispose(); }
/// <summary> /// Draws a pressed tab /// </summary> /// <param name="e"></param> public void DrawTabPressed(RibbonTabRenderEventArgs e) { }
/// <summary> /// Draws a complete tab /// </summary> /// <param name="e"></param> public void DrawTabNormal(RibbonTabRenderEventArgs e) { RectangleF lastClip = e.Graphics.ClipBounds; Rectangle clip = Rectangle.FromLTRB( e.Tab.TabBounds.Left, e.Tab.TabBounds.Top, e.Tab.TabBounds.Right, e.Tab.TabBounds.Bottom); Rectangle r = Rectangle.FromLTRB( e.Tab.TabBounds.Left - 1, e.Tab.TabBounds.Top - 1, e.Tab.TabBounds.Right, e.Tab.TabBounds.Bottom); e.Graphics.SetClip(clip); using (Brush b = new SolidBrush(ColorTable.RibbonBackground)) { e.Graphics.FillRectangle(b, r); } e.Graphics.SetClip(lastClip); }
/// <summary> /// Draws an active tab /// </summary> /// <param name="e"></param> public void DrawTabActive(RibbonTabRenderEventArgs e) { DrawTabNormal(e); Rectangle glossy = new Rectangle(e.Tab.TabBounds.Left, e.Tab.TabBounds.Top, e.Tab.TabBounds.Width, 4); Rectangle shadow = e.Tab.TabBounds; shadow.Offset(2, 1); Rectangle tab = e.Tab.TabBounds; tab.Inflate(0, 1); using (GraphicsPath path = RoundRectangle(shadow, 6, Corners.NorthWest | Corners.NorthEast)) { using (PathGradientBrush b = new PathGradientBrush(path)) { b.WrapMode = WrapMode.Clamp; ColorBlend cb = new ColorBlend(3); cb.Colors = new Color[]{Color.Transparent, Color.FromArgb(50, Color.Black), Color.FromArgb(100, Color.Black)}; cb.Positions = new float[] { 0f, .1f, 1f }; b.InterpolationColors = cb; e.Graphics.FillPath(b, path); } } using (GraphicsPath path = RoundRectangle(tab, 6, Corners.North)) { Color north = ColorTable.TabNorth; Color south = ColorTable.TabSouth; if (e.Tab.Contextual) { north = e.Tab.Context.GlowColor; south = Color.FromArgb(10, north); } using (LinearGradientBrush b = new LinearGradientBrush( e.Tab.TabBounds, ColorTable.TabNorth, ColorTable.TabSouth, 90)) { e.Graphics.FillPath(b, path); } } using (GraphicsPath path = RoundRectangle(glossy, 6, Corners.North)) { using (Brush b = new SolidBrush(Color.FromArgb(180, Color.White))) { e.Graphics.FillPath(b, path); } } }