public override void OnRenderRibbonPanelBackground(RibbonPanelRenderEventArgs e) { if (e.Panel.OverflowMode && !(e.Canvas is RibbonPanelPopup)) { if (e.Panel.Pressed) { DrawPanelOverflowPressed(e); } else if (e.Panel.Selected) { DrawPannelOveflowSelected(e); } else { DrawPanelOverflowNormal(e); } } else { if (e.Panel.Selected && (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007 || e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010)) { DrawPanelSelected(e); } else { DrawPanelNormal(e); } } }
public override void OnRenderRibbonPanelText(RibbonPanelRenderEventArgs e) { if (e.Panel.OverflowMode && !(e.Canvas is RibbonPanelPopup)) { return; } Rectangle textArea = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.ContentBounds.Bottom, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007 || e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010) { using (StringFormat sf = StringFormatFactory.Center()) using (Brush b = new SolidBrush(GetTextColor(e.Panel.Enabled, ColorTable.PanelText))) { e.Graphics.DrawString(e.Panel.Text, e.Ribbon.Font, b, textArea, sf); } } else if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2013) { using (StringFormat sf = StringFormatFactory.Center()) using (Brush b = new SolidBrush(GetTextColor(e.Panel.Enabled, ColorTable.PanelText_2013))) { e.Graphics.DrawString(e.Panel.Text, e.Ribbon.Font, b, textArea, sf); } } }
/// <summary> /// Draws an overflown panel in pressed state /// </summary> /// <param name="e"></param> public void DrawPanelOverflowPressed(RibbonPanelRenderEventArgs e) { Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); Rectangle lightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.Bounds.Top + 1, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); Rectangle glossy = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Top + 17); GraphicsPath dark = RoundRectangle(darkBorder, 3); GraphicsPath light = RoundRectangle(lightBorder, 3); using (LinearGradientBrush b = new LinearGradientBrush(lightBorder, ColorTable.PanelOverflowBackgroundPressed, ColorTable.PanelOverflowBackgroundSelectedSouth, 90)) { b.WrapMode = WrapMode.TileFlipXY; e.Graphics.FillPath(b, dark); } using (GraphicsPath path = RoundRectangle(glossy, 3, Corners.NorthEast | Corners.NorthWest)) { using (LinearGradientBrush b = new LinearGradientBrush( glossy, Color.FromArgb(150, Color.White), Color.FromArgb(50, Color.White), 90 )) { b.WrapMode = WrapMode.TileFlipXY; e.Graphics.FillPath(b, path); } } using (Pen p = new Pen(Color.FromArgb(40, Color.White))) { e.Graphics.DrawPath(p, light); } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, dark); } DrawPanelOverflowImage(e); DrawPressedShadow(e.Graphics, glossy); dark.Dispose(); light.Dispose(); }
/// <summary> /// Draws the image of the panel when collapsed /// </summary> /// <param name="e"></param> public void DrawPanelOverflowImage(RibbonPanelRenderEventArgs e) { int margin = 3; Size imgSquareSize = new Size(32, 32); Rectangle imgSquareR = new Rectangle(new Point( e.Panel.Bounds.Left + (e.Panel.Bounds.Width - imgSquareSize.Width) / 2, e.Panel.Bounds.Top + 5), imgSquareSize); Rectangle imgSquareBottomR = Rectangle.FromLTRB( imgSquareR.Left, imgSquareR.Bottom - 10, imgSquareR.Right, imgSquareR.Bottom); Rectangle textR = Rectangle.FromLTRB( e.Panel.Bounds.Left + margin, imgSquareR.Bottom + margin, e.Panel.Bounds.Right - margin, e.Panel.Bounds.Bottom - margin); using (GraphicsPath imgSq = RoundRectangle(imgSquareR, 5)) { using (GraphicsPath imgSqB = RoundRectangle(imgSquareBottomR, 5, Corners.South)) { using (LinearGradientBrush b = new LinearGradientBrush( imgSquareR, ColorTable.TabContentNorth, ColorTable.TabContentSouth, 90 )) { e.Graphics.FillPath(b, imgSq); } if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007) { using (SolidBrush b = new SolidBrush(ColorTable.PanelTextBackground)) { e.Graphics.FillPath(b, imgSqB); } } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, imgSq); } if (e.Panel.Image != null) { e.Graphics.DrawImage(e.Panel.Image, imgSquareR.Left + (imgSquareR.Width - e.Panel.Image.Width) / 2, imgSquareR.Top + ((imgSquareR.Height - imgSquareBottomR.Height) - e.Panel.Image.Height) / 2, e.Panel.Image.Width, e.Panel.Image.Height); } if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007 || e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010) { using (StringFormat sf = StringFormatFactory.CenterNearTrimChar()) using (SolidBrush b = new SolidBrush(GetTextColor(e.Panel.Enabled, ColorTable.Text))) { e.Graphics.DrawString(e.Panel.Text, e.Ribbon.Font, b, textR, sf); } } else if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2013) { using (StringFormat sf = StringFormatFactory.CenterNearTrimChar()) using (SolidBrush b = new SolidBrush(GetTextColor(e.Panel.Enabled, ColorTable.RibbonItemText_2013))) { e.Graphics.DrawString(e.Panel.Text, e.Ribbon.Font, b, textR, sf); } } if (e.Panel.Text != null) { Rectangle bounds = LargeButtonDropDownArrowBounds(e.Graphics, e.Panel.Owner.Font, e.Panel.Text, textR); if (bounds.Right < e.Panel.Bounds.Right) { Rectangle boundsLight = bounds; boundsLight.Offset(0, 1); Color lt = ColorTable.ArrowLight; Color dk = ColorTable.Arrow; DrawArrow(e.Graphics, boundsLight, lt, RibbonArrowDirection.Down); DrawArrow(e.Graphics, bounds, dk, RibbonArrowDirection.Down); } } } } }
/// <summary> /// Draws an overflown panel in normal state /// </summary> /// <param name="e"></param> public void DrawPanelOverflowNormal(RibbonPanelRenderEventArgs e) { Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); Rectangle lightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.Bounds.Top + 1, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); GraphicsPath dark = RoundRectangle(darkBorder, 3); GraphicsPath light = RoundRectangle(lightBorder, 3); using (Pen p = new Pen(ColorTable.PanelLightBorder)) { e.Graphics.DrawPath(p, light); } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, dark); } DrawPanelOverflowImage(e); dark.Dispose(); light.Dispose(); }
/// <summary> /// Draws an overflown panel in selected state /// </summary> /// <param name="e"></param> public void DrawPannelOveflowSelected(RibbonPanelRenderEventArgs e) { Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); Rectangle lightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.Bounds.Top + 1, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); GraphicsPath dark = RoundRectangle(darkBorder, 3); GraphicsPath light = RoundRectangle(lightBorder, 3); using (Pen p = new Pen(ColorTable.PanelLightBorder)) { e.Graphics.DrawPath(p, light); } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, dark); } using (LinearGradientBrush b = new LinearGradientBrush( lightBorder, ColorTable.PanelOverflowBackgroundSelectedNorth, Color.Transparent, 90)) { e.Graphics.FillPath(b, light); } DrawPanelOverflowImage(e); dark.Dispose(); light.Dispose(); }
/// <summary> /// Draws a panel in normal state (unselected) /// </summary> /// <param name="e"></param> public void DrawPanelNormal(RibbonPanelRenderEventArgs e) { #region Office_2007 if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007) { Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); Rectangle lightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.Bounds.Top + 1, e.Panel.Bounds.Right + 1, e.Panel.Bounds.Bottom); Rectangle textArea = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.ContentBounds.Bottom, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); GraphicsPath dark = RoundRectangle(darkBorder, 3); GraphicsPath light = RoundRectangle(lightBorder, 3); GraphicsPath txt = RoundRectangle(textArea, 3, Corners.SouthEast | Corners.SouthWest); using (Pen p = new Pen(ColorTable.PanelLightBorder)) { e.Graphics.DrawPath(p, light); } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, dark); } using (SolidBrush b = new SolidBrush(ColorTable.PanelTextBackground)) { e.Graphics.FillPath(b, txt); } txt.Dispose(); dark.Dispose(); light.Dispose(); } #endregion #region Office_2010 if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010) { Rectangle innerLightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right - 2, e.Panel.Bounds.Bottom); Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom); Rectangle outerLightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); // Panel divider highlight using (LinearGradientBrush blendBrush = new LinearGradientBrush(innerLightBorder, Color.FromArgb(30, ColorTable.PanelLightBorder), ColorTable.PanelLightBorder, 90)) { using (Pen p = new Pen(blendBrush)) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawLine(p, innerLightBorder.Left, innerLightBorder.Top, innerLightBorder.Left, innerLightBorder.Bottom); e.Graphics.DrawLine(p, innerLightBorder.Right, innerLightBorder.Top, innerLightBorder.Right, innerLightBorder.Bottom); e.Graphics.DrawLine(p, outerLightBorder.Right, outerLightBorder.Top, outerLightBorder.Right, outerLightBorder.Bottom); e.Graphics.SmoothingMode = sm; } } // Panel divider shading using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(30, ColorTable.PanelDarkBorder), ColorTable.PanelDarkBorder, LinearGradientMode.Vertical)) { blendBrush.WrapMode = WrapMode.TileFlipX; //This is here to stop an annoying single pixel being drawn at the top of the line. using (Pen p = new Pen(blendBrush)) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawLine(p, darkBorder.Right, darkBorder.Top, darkBorder.Right, darkBorder.Bottom); e.Graphics.SmoothingMode = sm; } } // Panel bottom border (draw over selected panel highlight) using (Pen p = new Pen(ColorTable.TabContentSouth)) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawLine(p, innerLightBorder.Left, innerLightBorder.Bottom, innerLightBorder.Right, innerLightBorder.Bottom); e.Graphics.SmoothingMode = sm; } } #endregion #region Office_2013 if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2013) //Michael Spradlin - 05/03/2013 Office 2013 Style Changes { using (Pen p = new Pen(ColorTable.PanelBorder_2013)) { e.Graphics.DrawLine(p, new Point(e.Panel.Bounds.Right, e.Panel.Bounds.Top), new Point(e.Panel.Bounds.Right, e.Panel.Bounds.Bottom)); } } #endregion if (e.Panel.ButtonMoreVisible) { if(e.Panel.ButtonMorePressed) { DrawButtonPressed(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon); } else if(e.Panel.ButtonMoreSelected) { DrawButtonSelected(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon); } DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled); } }
/// <summary> /// Renders the background of the specified ribbon panel /// </summary> /// <param name="e">Event data and paint tools</param> public virtual void OnRenderRibbonPanelBackground(RibbonPanelRenderEventArgs e) { }
/// <summary> /// Draws a panel in selected state /// </summary> /// <param name="e"></param> public void DrawPanelSelected(RibbonPanelRenderEventArgs e) { Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); Rectangle lightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.Bounds.Top + 1, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); Rectangle textArea = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.ContentBounds.Bottom, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); GraphicsPath dark = RoundRectangle(darkBorder, 3); GraphicsPath light = RoundRectangle(lightBorder, 3); GraphicsPath txt = RoundRectangle(textArea, 3, Corners.SouthEast | Corners.SouthWest); using (Pen p = new Pen(ColorTable.PanelLightBorder)) { e.Graphics.DrawPath(p, light); } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, dark); } using (SolidBrush b = new SolidBrush(ColorTable.PanelBackgroundSelected)) { e.Graphics.FillPath(b, light); } using (SolidBrush b = new SolidBrush(ColorTable.PanelTextBackgroundSelected)) { e.Graphics.FillPath(b, txt); } if (e.Panel.ButtonMoreVisible) { if (e.Panel.ButtonMorePressed) { DrawButtonPressed(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast); } else if (e.Panel.ButtonMoreSelected) { DrawButtonSelected(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast); } DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled); } txt.Dispose(); dark.Dispose(); light.Dispose(); }
public override void OnRenderRibbonPanelText(RibbonPanelRenderEventArgs e) { if (e.Panel.OverflowMode && !(e.Canvas is RibbonPanelPopup)) { return; } Rectangle textArea = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.ContentBounds.Bottom, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; using (Brush b = new SolidBrush(GetTextColor(e.Panel.Enabled, ColorTable.PanelText))) { e.Graphics.DrawString(e.Panel.Text, e.Ribbon.Font, b, textArea, sf); } }
/// <summary> /// Draws a panel in normal state (unselected) /// </summary> /// <param name="e"></param> public void DrawPanelNormal(RibbonPanelRenderEventArgs e) { if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007 | e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010) //Michael Spradlin - 05/03/2013 Office 2013 Style Changes { Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); Rectangle lightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.Bounds.Top + 1, e.Panel.Bounds.Right + 1, e.Panel.Bounds.Bottom); Rectangle textArea = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.ContentBounds.Bottom, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); GraphicsPath dark = RoundRectangle(darkBorder, 3); GraphicsPath light = RoundRectangle(lightBorder, 3); GraphicsPath txt = RoundRectangle(textArea, 3, Corners.SouthEast | Corners.SouthWest); using (Pen p = new Pen(Theme.ColorTable.PanelLightBorder)) { e.Graphics.DrawPath(p, light); } using (Pen p = new Pen(Theme.ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, dark); } using (SolidBrush b = new SolidBrush(Theme.ColorTable.PanelTextBackground)) { e.Graphics.FillPath(b, txt); } txt.Dispose(); dark.Dispose(); light.Dispose(); } else if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2013) //Michael Spradlin - 05/03/2013 Office 2013 Style Changes { using (Pen p = new Pen(Theme.ColorTable.PanelBorder_2013)) { e.Graphics.DrawLine(p, new Point(e.Panel.Bounds.Right, e.Panel.Bounds.Top), new Point(e.Panel.Bounds.Right, e.Panel.Bounds.Bottom)); } } if (e.Panel.ButtonMoreVisible) { DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled); } }
public override void OnRenderRibbonPanelBackground(RibbonPanelRenderEventArgs e) { if (e.Panel.OverflowMode && !(e.Canvas is RibbonPanelPopup)) { if (e.Panel.Pressed) { DrawPanelOverflowPressed(e); } else if (e.Panel.Selected) { DrawPannelOveflowSelected(e); } else { DrawPanelOverflowNormal(e); } } else { if (e.Panel.Selected) { if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007 | e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010) //Michael Spradlin - 05/03/2013 Office 2013 Style Changes { DrawPanelSelected(e); } else if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2013) //Michael Spradlin - 05/03/2013 Office 2013 Style Changes { //DO NOT DRAW ANYTHING } } else { DrawPanelNormal(e); } } }
/// <summary> /// Renders the text of the specified panel /// </summary> /// <param name="e">Event data and paint tools</param> public virtual void OnRenderRibbonPanelText(RibbonPanelRenderEventArgs e) { }
/// <summary> /// Renders the background of the specified ribbon panel /// </summary> /// <param name="e">Event data and paint tools</param> public virtual void OnRenderRibbonPanelBackground(RibbonPanelRenderEventArgs e) { }
/// <summary> /// Draws a panel in selected state /// </summary> /// <param name="e"></param> public void DrawPanelSelected(RibbonPanelRenderEventArgs e) { #region Office_2007 if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007) { Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); Rectangle lightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.Bounds.Top + 1, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); Rectangle textArea = Rectangle.FromLTRB( e.Panel.Bounds.Left + 1, e.Panel.ContentBounds.Bottom, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom - 1); GraphicsPath dark = RoundRectangle(darkBorder, 3); GraphicsPath light = RoundRectangle(lightBorder, 3); GraphicsPath txt = RoundRectangle(textArea, 3, Corners.SouthEast | Corners.SouthWest); using (Pen p = new Pen(ColorTable.PanelLightBorder)) { e.Graphics.DrawPath(p, light); } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, dark); } using (SolidBrush b = new SolidBrush(ColorTable.PanelBackgroundSelected)) { e.Graphics.FillPath(b, light); } using (SolidBrush b = new SolidBrush(ColorTable.PanelTextBackgroundSelected)) { e.Graphics.FillPath(b, txt); } if (e.Panel.ButtonMoreVisible) { if (e.Panel.ButtonMorePressed) { DrawButtonPressed(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon); } else if (e.Panel.ButtonMoreSelected) { DrawButtonSelected(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon); } DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled); } txt.Dispose(); dark.Dispose(); light.Dispose(); } #endregion #region Office_2010 if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010) { Rectangle innerLightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right - 2, e.Panel.Bounds.Bottom); Rectangle darkBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right - 1, e.Panel.Bounds.Bottom); Rectangle outerLightBorder = Rectangle.FromLTRB( e.Panel.Bounds.Left, e.Panel.Bounds.Top, e.Panel.Bounds.Right, e.Panel.Bounds.Bottom); //Glow appears as a tall elipse, rather than circle Rectangle glowR = new Rectangle( e.Panel.Bounds.Left + (int)(0.1 * e.Panel.Bounds.Width), e.Panel.Bounds.Top, e.Panel.Bounds.Width - (int)(0.2 * e.Panel.Bounds.Width), (2 * e.Panel.Bounds.Height) - 1); //Highlight glow in panel using (GraphicsPath radialPath = new GraphicsPath()) { radialPath.AddArc(glowR, 180, 180); radialPath.CloseFigure(); PathGradientBrush gr = new PathGradientBrush(radialPath); gr.CenterPoint = new PointF( Convert.ToSingle(innerLightBorder.Left + innerLightBorder.Width / 2), Convert.ToSingle(innerLightBorder.Bottom)); gr.CenterColor = ColorTable.PanelBackgroundSelected; gr.SurroundColors = new Color[] { Color.Transparent }; gr.SetSigmaBellShape(1.0f, 1.0f); SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.FillPath(gr, radialPath); e.Graphics.SmoothingMode = sm; gr.Dispose(); } // Panel divider left highlight using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(90, Color.White), Color.FromArgb(220, Color.White), LinearGradientMode.Vertical)) { Blend blend = new Blend(); blend.Factors = new float[] { 0f, 1f, 1f }; blend.Positions = new float[] { 0f, 0.5f, 1f }; blendBrush.Blend = blend; blendBrush.WrapMode = WrapMode.TileFlipX; //This is here to stop an annoying single pixel being drawn at the top of the line. using (Pen p = new Pen(blendBrush)) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawLine(p, innerLightBorder.Right, innerLightBorder.Top, innerLightBorder.Right, innerLightBorder.Bottom); e.Graphics.SmoothingMode = sm; } } // Panel divider right highlight using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(30, ColorTable.PanelLightBorder), ColorTable.PanelLightBorder, LinearGradientMode.Vertical)) { using (Pen p = new Pen(blendBrush)) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawLine(p, outerLightBorder.Right, outerLightBorder.Top, outerLightBorder.Right, outerLightBorder.Bottom); e.Graphics.SmoothingMode = sm; } } // Panel divider shading using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(30, ColorTable.PanelDarkBorder), ColorTable.PanelDarkBorder, LinearGradientMode.Vertical)) { blendBrush.WrapMode = WrapMode.TileFlipX; //This is here to stop an annoying single pixel being drawn at the top of the line. using (Pen p = new Pen(blendBrush)) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawLine(p, darkBorder.Right, darkBorder.Top, darkBorder.Right, darkBorder.Bottom); e.Graphics.SmoothingMode = sm; } } // Panel bottom border highlight /* For some reason this is not drawn except under certain circustances, like moving the mouse to a combobox, * or quickly outside the bounds of the Ribbon. Don't know exactly why, but probably clipping or the order of events being firing. * Have performed drawing tests with the ribbon, tab, panel drawn transparent and nothing appears to be drawing over the top. * Until resolved, will just leave the code in case some other change fixes it.*/ using (Pen p = new Pen(Color.FromArgb(220, Color.White))) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawLine(p, innerLightBorder.Left, innerLightBorder.Bottom, innerLightBorder.Right, innerLightBorder.Bottom); //Enabling the line below shows that the line is drawn, but only the right hand half is shown. The left hand half is clipped/missing. //e.Graphics.DrawLine(p, innerLightBorder.Left, innerLightBorder.Bottom, innerLightBorder.Right, innerLightBorder.Bottom - 1); e.Graphics.SmoothingMode = sm; } if (e.Panel.ButtonMoreVisible) { if (e.Panel.ButtonMorePressed) { DrawButtonPressed(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon); } else if (e.Panel.ButtonMoreSelected) { DrawButtonSelected(e.Graphics, e.Panel.ButtonMoreBounds, Corners.SouthEast, e.Ribbon); } DrawButtonMoreGlyph(e.Graphics, e.Panel.ButtonMoreBounds, e.Panel.ButtonMoreEnabled && e.Panel.Enabled); } } #endregion #region Office_2013 #endregion }
/// <summary> /// Renders the text of the specified panel /// </summary> /// <param name="e">Event data and paint tools</param> public virtual void OnRenderRibbonPanelText(RibbonPanelRenderEventArgs e) { }
/// <summary> /// Draws the image of the panel when collapsed /// </summary> /// <param name="e"></param> public void DrawPanelOverflowImage(RibbonPanelRenderEventArgs e) { int margin =3; Size imgSquareSize = new Size(32, 32); Rectangle imgSquareR = new Rectangle(new Point( e.Panel.Bounds.Left + (e.Panel.Bounds.Width - imgSquareSize.Width) / 2, e.Panel.Bounds.Top+ 5), imgSquareSize); Rectangle imgSquareBottomR = Rectangle.FromLTRB( imgSquareR.Left, imgSquareR.Bottom - 10, imgSquareR.Right, imgSquareR.Bottom); Rectangle textR = Rectangle.FromLTRB( e.Panel.Bounds.Left + margin, imgSquareR.Bottom + margin, e.Panel.Bounds.Right - margin, e.Panel.Bounds.Bottom - margin); GraphicsPath imgSq = RoundRectangle(imgSquareR, 5); GraphicsPath imgSqB = RoundRectangle(imgSquareBottomR, 5, Corners.South); using (LinearGradientBrush b = new LinearGradientBrush( imgSquareR, ColorTable.TabContentNorth, ColorTable.TabContentSouth, 90 )) { e.Graphics.FillPath(b, imgSq); } using (SolidBrush b = new SolidBrush(ColorTable.PanelTextBackground)) { e.Graphics.FillPath(b, imgSqB); } using (Pen p = new Pen(ColorTable.PanelDarkBorder)) { e.Graphics.DrawPath(p, imgSq); } if (e.Panel.Image != null) { e.Graphics.DrawImage(e.Panel.Image, imgSquareR.Left + (imgSquareR.Width - e.Panel.Image.Width) / 2, imgSquareR.Top + ((imgSquareR.Height - imgSquareBottomR.Height) - e.Panel.Image.Height) / 2, e.Panel.Image.Width, e.Panel.Image.Height); } using (SolidBrush b = new SolidBrush(GetTextColor(e.Panel.Enabled))) { StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Near; sf.Trimming = StringTrimming.Character; e.Graphics.DrawString(e.Panel.Text, e.Ribbon.Font, b, textR, sf); } Rectangle bounds = LargeButtonDropDownArrowBounds(e.Graphics, e.Panel.Owner.Font, e.Panel.Text, textR); if (bounds.Right < e.Panel.Bounds.Right) { Rectangle boundsLight = bounds; boundsLight.Offset(0, 1); Color lt = ColorTable.ArrowLight; Color dk = ColorTable.Arrow; DrawArrow(e.Graphics, boundsLight, lt, RibbonArrowDirection.Down); DrawArrow(e.Graphics, bounds, dk, RibbonArrowDirection.Down); } imgSq.Dispose(); imgSqB.Dispose(); }