protected override void PaintControlBackground(ItemPaintArgs pa) { bool resetClip = false; eDotNetBarStyle effectiveStyle = this.EffectiveStyle; bool isGlassEnabled = this.IsGlassEnabled; if (isGlassEnabled) { RibbonForm f = this.FindForm() as RibbonForm; if (f != null) { pa.Graphics.SetClip(new Rectangle(0, 0, this.Width, f.GlassHeight - ((effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Metro) && pa.GlassEnabled ? Office2010GlassExcludeTopPart : 1)), System.Drawing.Drawing2D.CombineMode.Exclude); resetClip = true; } } if (isGlassEnabled && (effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Metro)) { ElementStyle style = GetBackgroundStyle(); if (style != null) { Rectangle r = new Rectangle(0, Office2010GlassExcludeTopPart - 2, this.Width, this.Height + 8); using (System.Drawing.Drawing2D.GraphicsPath fillPath = new System.Drawing.Drawing2D.GraphicsPath()) { //if (StyleManager.Style == eStyle.Office2010Black) //{ // fillPath.AddRectangle(r); // using (System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(r, style.BackColor2, style.BackColor, 90)) // pa.Graphics.FillPath(brush, fillPath); //} //else { fillPath.AddEllipse(r); using (System.Drawing.Drawing2D.PathGradientBrush brush = new System.Drawing.Drawing2D.PathGradientBrush(fillPath)) { brush.CenterColor = style.BackColor; brush.SurroundColors = new Color[] { style.BackColor2 }; brush.CenterPoint = new PointF(r.Width / 2, r.Bottom - Office2010GlassExcludeTopPart / 2); System.Drawing.Drawing2D.Blend blend = new System.Drawing.Drawing2D.Blend(); blend.Factors = new float[] { 0f, .85f, 1f, }; blend.Positions = new float[] { 0f, .65f, 1f }; brush.Blend = blend; pa.Graphics.FillPath(brush, fillPath); } } } } } else base.PaintControlBackground(pa); if (resetClip) pa.Graphics.ResetClip(); m_QuickToolbarBounds = Rectangle.Empty; m_CaptionBounds = Rectangle.Empty; m_SystemCaptionItemBounds = Rectangle.Empty; Rendering.BaseRenderer renderer = GetRenderer(); if (renderer != null && this.Parent is RibbonControl) { RibbonControlRendererEventArgs rargs = new RibbonControlRendererEventArgs(pa.Graphics, this.Parent as RibbonControl, pa.GlassEnabled); rargs.ItemPaintArgs = pa; renderer.DrawRibbonControlBackground(rargs); if (m_CaptionVisible) renderer.DrawQuickAccessToolbarBackground(new RibbonControlRendererEventArgs(pa.Graphics, this.Parent as RibbonControl, pa.GlassEnabled)); } if (m_TabGroupsVisible) { PaintTabGroups(pa); } // Paint form caption text if (renderer != null && m_CaptionVisible) { RibbonControlRendererEventArgs rer = new RibbonControlRendererEventArgs(pa.Graphics, this.Parent as RibbonControl, pa.GlassEnabled); rer.ItemPaintArgs = pa; renderer.DrawRibbonFormCaptionText(rer); } #if TRIAL if (NativeFunctions.ColorExpAlt()) { pa.Graphics.Clear(Color.White); TextDrawing.DrawString(pa.Graphics, "Trial Version Expired :-(", this.Font, Color.FromArgb(128, Color.Black), this.ClientRectangle, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter); } //else //{ // TextDrawing.DrawString(pa.Graphics, "Trial Version", this.Font, Color.FromArgb(128, Color.Black), new Rectangle(0, 0, this.Width - 12, this.Height-4), eTextFormat.Right | eTextFormat.Bottom); //} #endif }
/// <summary> /// Paints the background of quick access toolbar. /// </summary> public virtual void PaintQuickAccessToolbarBackground(RibbonControlRendererEventArgs e) { }
protected virtual void PaintCaptionParts(Graphics g) { if (m_RibbonControl == null || !m_RibbonControl.CaptionVisible) return; if (m_DisplayRectangleReductionHorizontal <= 2) return; RibbonControlRendererEventArgs e = new RibbonControlRendererEventArgs(g, m_RibbonControl, this.IsGlassEnabled); e.ItemPaintArgs = m_RibbonControl.RibbonStrip.GetItemPaintArgs(g); BaseRenderer r = m_RibbonControl.RibbonStrip.GetRenderer(); if (r == null) return; Region oldClip = g.Clip; Rectangle formRect = new Rectangle(1, 1, this.Width - 3, this.Height - 3); eDotNetBarStyle effectiveStyle = m_RibbonControl.EffectiveStyle; if (effectiveStyle == eDotNetBarStyle.Office2010) formRect = new Rectangle(2, 2, this.Width - 5, this.Height - 4); else if (effectiveStyle == eDotNetBarStyle.Metro) formRect = new Rectangle(1, 1, this.Width - 3, this.Height - 3); Region formRegion = GetRegion(formRect); int part = m_DisplayRectangleReductionHorizontal; Rectangle excludeRect = new Rectangle(formRect.X, m_RibbonControl.RibbonStrip.CaptionBounds.Height + 5, formRect.Width, this.Height - (m_RibbonControl.RibbonStrip.CaptionBounds.Height + 2)); g.SetClip(formRegion, CombineMode.Replace); g.SetClip(excludeRect, CombineMode.Exclude); g.TranslateTransform(1, 1); r.DrawRibbonControlBackground(e); r.DrawQuickAccessToolbarBackground(e); // Will not be needed with latest Office 2007 style if (effectiveStyle == eDotNetBarStyle.Metro) { if (m_RibbonControl.GetApplicationButton() != null) { ButtonItem appButton = m_RibbonControl.GetApplicationButton() as ButtonItem; g.TranslateTransform(-1, 0); if (appButton != null && appButton.Displayed) { g.SetClip(formRegion, CombineMode.Replace); r.DrawButtonItem(new ButtonItemRendererEventArgs(g, appButton, m_RibbonControl.RibbonStrip.GetItemPaintArgs(g))); if (m_RibbonControl.Expanded) { g.TranslateTransform(0, 1); r.DrawButtonItem(new ButtonItemRendererEventArgs(g, appButton, m_RibbonControl.RibbonStrip.GetItemPaintArgs(g))); } } } g.ResetTransform(); if (m_RibbonControl.TabGroups.Count > 0) { g.SetClip(formRegion, CombineMode.Replace); g.TranslateTransform(m_RibbonControl.Left, 0); m_RibbonControl.RibbonStrip.PaintTabGroups(m_RibbonControl.RibbonStrip.GetItemPaintArgs(g)); g.ResetTransform(); } Office2007ColorTable table = ((Office2007Renderer)r).ColorTable; if (m_RibbonControl.Expanded && !table.RibbonControl.OuterBorder.Start.IsEmpty) { using (Pen pen = new Pen(table.RibbonControl.OuterBorder.Start)) { g.DrawLine(pen, this.Width - 5, m_RibbonControl.RibbonStrip.Height, this.Width - 1, m_RibbonControl.RibbonStrip.Height); g.DrawLine(pen, this.Width - 5, m_RibbonControl.Height - 2, this.Width - 1, m_RibbonControl.Height - 2); g.DrawLine(pen, 1, m_RibbonControl.Height - 2, 5, m_RibbonControl.Height - 2); } } } g.ResetTransform(); // Draw Status bar if any... Bar statusBar = GetStatusBar(); if (statusBar != null && BarFunctions.IsOffice2007Style(statusBar.Style) && !statusBar.IsThemed) { r = statusBar.GetRenderer(); if (r != null) { g.SetClip(formRegion, CombineMode.Replace); //g.FillRectangle(Brushes.Red, new Rectangle(0, statusBar.Top, this.Width, statusBar.Height + 4)); ToolbarRendererEventArgs te = new ToolbarRendererEventArgs(statusBar, g, new Rectangle(0, statusBar.Top, this.Width, statusBar.Height + 4)); te.ItemPaintArgs = statusBar.GetItemPaintArgs(g); te.ItemPaintArgs.CachedPaint = true; r.DrawToolbarBackground(te); } } g.Clip = oldClip; if (oldClip != null) oldClip.Dispose(); formRegion.Dispose(); }
/// <summary> /// Paints form caption background /// </summary> public virtual void PaintCaptionBackground(RibbonControlRendererEventArgs e, Rectangle displayRect) { }
/// <summary> /// Paints form caption text when ribbon control is displaying form caption /// </summary> public virtual void PaintCaptionText(RibbonControlRendererEventArgs e) { }
/// <summary> /// Paints controls background /// </summary> public virtual void PaintBackground(RibbonControlRendererEventArgs e) { }
/// <summary> /// Paints the background of quick access toolbar. /// </summary> public override void PaintQuickAccessToolbarBackground(RibbonControlRendererEventArgs e) { RibbonStrip rs = e.RibbonControl.RibbonStrip; RibbonControl ribbon = e.RibbonControl; if (!rs.CaptionVisible) return; eDotNetBarStyle effectiveStyle = ribbon.EffectiveStyle; Graphics g = e.Graphics; bool rightToLeft = (rs.RightToLeft == System.Windows.Forms.RightToLeft.Yes); bool drawQatBackground = true; // Get appropriate color table Rendering.Office2007QuickAccessToolbarStateColorTable ct = m_ColorTable.QuickAccessToolbar.Active; System.Windows.Forms.Form form = rs.FindForm(); bool isMaximized = false; if (form != null) isMaximized = form.WindowState == System.Windows.Forms.FormWindowState.Maximized; if (form != null && !e.RibbonControl.IsDesignMode && (form != System.Windows.Forms.Form.ActiveForm && form.MdiParent == null || form.MdiParent != null && form.MdiParent.ActiveMdiChild != form)) ct = m_ColorTable.QuickAccessToolbar.Inactive; // Get right most X position of the Quick Access Toolbar int right = 0, sysLeft = 0; Size qatSize = Size.Empty; for (int i = rs.QuickToolbarItems.Count - 1; i >= 0; i--) { BaseItem item = rs.QuickToolbarItems[i]; if (!item.Visible || !item.Displayed && !((RibbonStripContainerItem)rs.GetBaseItemContainer()).MetroBackstageOpen) continue; if (item is QatCustomizeItem) qatSize = item.DisplayRectangle.Size; if (item.ItemAlignment == eItemAlignment.Near && item.Visible && i > 0) { if (rightToLeft) right = item.DisplayRectangle.X; else right = item.DisplayRectangle.Right; break; } else if (item.ItemAlignment == eItemAlignment.Far && item.Visible) { if (rightToLeft) sysLeft = item.DisplayRectangle.Right; else sysLeft = item.DisplayRectangle.X; } } if (right == 0) drawQatBackground = false; if (rs.CaptionContainerItem is CaptionItemContainer && ((CaptionItemContainer)rs.CaptionContainerItem).MoreItems != null) { if (rightToLeft) right = ((CaptionItemContainer)rs.CaptionContainerItem).MoreItems.DisplayRectangle.X; else right = ((CaptionItemContainer)rs.CaptionContainerItem).MoreItems.DisplayRectangle.Right; qatSize = ((CaptionItemContainer)rs.CaptionContainerItem).MoreItems.DisplayRectangle.Size; } Rectangle r = rs.CaptionBounds; if (sysLeft > 0) { if (rightToLeft) rs.SystemCaptionItemBounds = new Rectangle(r.X, r.Y, sysLeft, r.Height); else rs.SystemCaptionItemBounds = new Rectangle(sysLeft, r.Y, r.Right - sysLeft, r.Height); } if (right == 0 || r.Height <= 0 || r.Width <= 0) return; if (!ribbon.QatPositionedBelowRibbon) { BaseItem startButton = ribbon.GetApplicationButton(); if (startButton != null) { int startIndex = rs.QuickToolbarItems.IndexOf(startButton); if (rs.QuickToolbarItems.Count - 1 > startIndex) { BaseItem firstItem = rs.QuickToolbarItems[startIndex + 1]; if (rightToLeft) { r.Width -= r.Right - firstItem.DisplayRectangle.Right; } else { r.Width -= firstItem.DisplayRectangle.X - r.X; r.X = firstItem.DisplayRectangle.X; } } } r.Height = ((CaptionItemContainer)ribbon.RibbonStrip.CaptionContainerItem).MaxItemHeight + 6; } // Create QAT rectangle int reduction = (r.Right - right); if (rightToLeft) { r.Width = reduction; if (rightToLeft) r.X += right; } else { r.Width -= reduction; } if (e.GlassEnabled) { r.Inflate(0, -3); r.Offset(0, 2); } else { r.Inflate(0, -2); if (isMaximized) { r.Y++; r.Height--; } } // Draw it, fill first GraphicsPath path = GetQuickToolbarBackPath(r, rightToLeft); if (path == null) return; // Get total background bounds and save them Rectangle clip = Rectangle.Ceiling(path.GetBounds()); rs.QuickToolbarBounds = clip; // Adjust the bounds of QAT so it is drawn before the QAT Customize Item r.Width -= (qatSize.Width + qatSize.Height / 2); if (rightToLeft) r.X += (qatSize.Width + qatSize.Height / 2) + 3; path.Dispose(); path = GetQuickToolbarBackPath(r, rightToLeft); SmoothingMode sm = g.SmoothingMode; if (!ribbon.QatPositionedBelowRibbon && drawQatBackground && r.Width > 6) { bool glassBorderPainted = false; if (e.GlassEnabled) { g.SmoothingMode = SmoothingMode.HighQuality; if (e.GlassEnabled && isMaximized && effectiveStyle == eDotNetBarStyle.Office2007) { DisplayHelp.FillPath(g, path, Color.FromArgb(72, Color.LightGray), Color.Empty); } if (!ct.GlassBorder.IsEmpty) DisplayHelp.DrawGradientPathBorder(g, path, ct.GlassBorder, 1); g.SmoothingMode = sm; if (e.GlassEnabled) glassBorderPainted = true; } else { if (!ct.OutterBorderColor.IsEmpty) { g.SmoothingMode = SmoothingMode.HighQuality; r.X++; //r.Y++; r.Y--; r.Height += 2; using (GraphicsPath pathOuter = GetQuickToolbarBackPath(r, rightToLeft)) { using (Pen pen = new Pen(ct.OutterBorderColor)) g.DrawPath(pen, pathOuter); } r.X--; //r.Y--; r.Y++; r.Height -= 2; g.SmoothingMode = sm; if (e.GlassEnabled) glassBorderPainted = true; } } //if (!e.GlassEnabled) // Fill painted only if Glass is not enabled //{ Region oldClip = g.Clip; g.SetClip(path, CombineMode.Intersect); Rectangle top = new Rectangle(clip.X, clip.Y, clip.Width, (int)(r.Height * .2)); Rectangle bottom = new Rectangle(clip.X, top.Bottom, clip.Width, clip.Height - top.Height); g.SmoothingMode = SmoothingMode.Default; if (!e.GlassEnabled) { DisplayHelp.FillRectangle(g, top, ct.TopBackground); DisplayHelp.FillRectangle(g, bottom, ct.BottomBackground); } else { if (!ct.GlassBorder.IsEmpty) DisplayHelp.FillRectangle(g, clip, Color.FromArgb(64, Color.White)); } g.SmoothingMode = sm; clip.Height -= 2; clip.Width += 2; clip.Y++; clip.X++; g.SetClip(clip); //if (!ct.InnerBorderColor.IsEmpty) //{ // r.X--; // path = GetQuickToolbarBackPath(r, rightToLeft, true); // using (Pen pen = new Pen(ct.InnerBorderColor)) // g.DrawPath(pen, path); // path.Dispose(); // r.X++; //} g.Clip = oldClip; if (oldClip != null) oldClip.Dispose(); //} if (!ct.MiddleBorderColor.IsEmpty && !(e.GlassEnabled && glassBorderPainted)) { g.SmoothingMode = SmoothingMode.HighQuality; path = GetQuickToolbarBackPath(r, rightToLeft); using (Pen pen = new Pen(ct.MiddleBorderColor)) g.DrawPath(pen, path); path.Dispose(); path = null; g.SmoothingMode = sm; } } if (path != null) path.Dispose(); }
public override void PaintCaptionText(RibbonControlRendererEventArgs e) { RibbonStrip rs = e.RibbonControl.RibbonStrip; if (!rs.CaptionVisible || rs.CaptionBounds.IsEmpty) return; Graphics g = e.Graphics; bool isMaximized = false; bool isFormActive = true; Rendering.Office2007FormStateColorTable formct = m_ColorTable.Form.Active; System.Windows.Forms.Form form = rs.FindForm(); bool renderText = true; if (form is RibbonForm && !((RibbonForm)form).RenderFormText) renderText = false; if (form != null && (form != System.Windows.Forms.Form.ActiveForm && form.MdiParent == null || form.MdiParent != null && form.MdiParent.ActiveMdiChild != form)) { formct = m_ColorTable.Form.Inactive; isFormActive = false; } string text = e.RibbonControl.TitleText; string plainText = text; bool isTitleTextMarkup = e.RibbonControl.RibbonStrip.TitleTextMarkupBody != null; if (isTitleTextMarkup) plainText = e.RibbonControl.RibbonStrip.TitleTextMarkupBody.PlainText; if (form != null) { if (text == "") { text = form.Text; plainText = text; } isMaximized = form.WindowState == System.Windows.Forms.FormWindowState.Maximized; } Rectangle captionRect = rs.CaptionBounds; // Exclude quick access toolbar if any if (!rs.QuickToolbarBounds.IsEmpty) DisplayHelp.ExcludeEdgeRect(ref captionRect, rs.QuickToolbarBounds); else { BaseItem sb = e.RibbonControl.GetApplicationButton(); if (sb != null && sb.Visible && sb.Displayed) DisplayHelp.ExcludeEdgeRect(ref captionRect, sb.Bounds); else DisplayHelp.ExcludeEdgeRect(ref captionRect, new Rectangle(0, 0, 22, 22)); // The system button in top-left corner } if (!rs.SystemCaptionItemBounds.IsEmpty) DisplayHelp.ExcludeEdgeRect(ref captionRect, rs.SystemCaptionItemBounds); // Array of the rectangles after they are split ArrayList rects = new ArrayList(5); ArrayList tempRemoveList = new ArrayList(5); // Exclude Context Tabs Captions if any if (rs.TabGroupsVisible) { foreach (RibbonTabItemGroup group in rs.TabGroups) { foreach (Rectangle r in group.DisplayPositions) { if (rects.Count > 0) { tempRemoveList.Clear(); Rectangle[] arrCopy = new Rectangle[rects.Count]; rects.CopyTo(arrCopy); for (int irc = 0; irc < arrCopy.Length; irc++) { if (arrCopy[irc].IntersectsWith(r)) { tempRemoveList.Add(irc); Rectangle[] splitRects = DisplayHelp.ExcludeRectangle(arrCopy[irc], r); rects.AddRange(splitRects); } } foreach (int idx in tempRemoveList) rects.RemoveAt(idx); } else { if (r.IntersectsWith(captionRect)) { Rectangle[] splitRects = DisplayHelp.ExcludeRectangle(captionRect, r); if (splitRects.Length > 0) { rects.AddRange(splitRects); break; } } } } } } Font font = SystemFonts.CaptionFont; bool disposeFont = true; if (rs.CaptionFont != null) { font.Dispose(); font = rs.CaptionFont; disposeFont = false; } Size textSize = Size.Empty; if (isTitleTextMarkup) { textSize = e.RibbonControl.RibbonStrip.TitleTextMarkupBody.Bounds.Size; } else { textSize = TextDrawing.MeasureString(g, plainText, font); } if (rects.Count > 0) { rs.CaptionTextBounds = (Rectangle[])rects.ToArray(typeof(Rectangle)); if (e.RibbonControl.RightToLeft == System.Windows.Forms.RightToLeft.No) rects.Reverse(); captionRect = Rectangle.Empty; foreach (Rectangle r in rects) { if (r.Width >= textSize.Width) { captionRect = r; break; } else if (r.Width > captionRect.Width) captionRect = r; } } else rs.CaptionTextBounds = new Rectangle[] { captionRect }; if (captionRect.Width > 6 && captionRect.Height > 6 && renderText) { if (e.GlassEnabled && e.ItemPaintArgs != null && e.ItemPaintArgs.ThemeWindow != null && !e.RibbonControl.IsDesignMode) { if (!e.ItemPaintArgs.CachedPaint || isMaximized) PaintGlassText(g, plainText, font, captionRect, isMaximized); } else { if (!isTitleTextMarkup) TextDrawing.DrawString(g, plainText, font, formct.CaptionText, captionRect, eTextFormat.VerticalCenter | eTextFormat.HorizontalCenter | eTextFormat.EndEllipsis | eTextFormat.NoPrefix); else { TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, formct.CaptionText, e.RibbonControl.RightToLeft == System.Windows.Forms.RightToLeft.Yes, captionRect, false); d.AllowMultiLine = false; d.IgnoreFormattingColors = !isFormActive; TextMarkup.BodyElement body = e.RibbonControl.RibbonStrip.TitleTextMarkupBody; if (e.RibbonControl.RibbonStrip.TitleTextMarkupLastArrangeBounds != captionRect) { body.Measure(captionRect.Size, d); body.Arrange(captionRect, d); e.RibbonControl.RibbonStrip.TitleTextMarkupLastArrangeBounds = captionRect; Rectangle mr = body.Bounds; if (mr.Width < captionRect.Width) mr.Offset((captionRect.Width - mr.Width) / 2, 0); if (mr.Height < captionRect.Height) mr.Offset(0, (captionRect.Height - mr.Height) / 2); body.Bounds = mr; } Region oldClip = g.Clip; g.SetClip(captionRect, CombineMode.Intersect); body.Render(d); g.Clip = oldClip; if (oldClip != null) oldClip.Dispose(); } } } if (disposeFont) font.Dispose(); }
private Rendering.Office2007ColorTable m_ColorTable = null; //new Rendering.Office2007ColorTable(); #region Ribbon Control Background /// <summary> /// Paints controls background /// </summary> public override void PaintBackground(RibbonControlRendererEventArgs e) { Graphics g = e.Graphics; RibbonControl rc = e.RibbonControl; Rendering.Office2007RibbonColorTable ct = m_ColorTable.RibbonControl; Rendering.Office2007RibbonTabItemStateColorTable selectedTabColors = null; PaintCaptionBackground(e, rc.DisplayRectangle); if (rc.Expanded && rc.RibbonStrip.HasVisibleTabs) { int cornerSize = ct.CornerSize; // Draw the border which is base for the tabs Rectangle selectedTabRect = Rectangle.Empty; if (rc.SelectedRibbonTabItem == null || !rc.Expanded) selectedTabRect = Rectangle.Empty; else { selectedTabRect = rc.SelectedRibbonTabItem.DisplayRectangle; selectedTabColors = Office2007RibbonTabItemPainter.GetStateColorTable(Office2007RibbonTabItemPainter.GetColorTable(this.ColorTable, rc.SelectedRibbonTabItem), rc.SelectedRibbonTabItem, rc.Expanded); } Rectangle bottomBounds = new Rectangle(rc.ClientRectangle.X, rc.ClientRectangle.Bottom - cornerSize, rc.ClientRectangle.Width - 1, cornerSize); if (!selectedTabRect.IsEmpty) bottomBounds = new Rectangle(rc.ClientRectangle.X, selectedTabRect.Bottom, rc.ClientRectangle.Width - 1, rc.ClientRectangle.Bottom - selectedTabRect.Bottom); //using (GraphicsPath path = GetBottomLinePath(bottomBounds, cornerSize)) //{ // using (SolidBrush brush = new SolidBrush(m_ColorTable.RibbonBar.Default.TopBackground.Start)) // g.FillPath(brush, path); //} // Dark border using (GraphicsPath path = GetBottomLinePath(bottomBounds, cornerSize)) { Region oldRegion = null; if (g.Clip != null) oldRegion = g.Clip as Region; if (!selectedTabRect.IsEmpty) { if (selectedTabColors != null) { using (Pen pen = new Pen(selectedTabColors.Background.End.IsEmpty ? selectedTabColors.Background.Start : selectedTabColors.Background.End, 1)) g.DrawLine(pen, selectedTabRect.X + 1, selectedTabRect.Bottom, selectedTabRect.Right - 1, selectedTabRect.Bottom); } g.SetClip(new Rectangle(selectedTabRect.X + 1, selectedTabRect.Bottom, selectedTabRect.Width - 1, 1), CombineMode.Exclude); if (rc.EffectiveStyle == eDotNetBarStyle.Metro) { ApplicationButton appButton = rc.GetApplicationButton() as ApplicationButton; if (appButton != null && appButton.Displayed) { Rectangle rApp = appButton.Bounds; g.TranslateTransform(0, 1); appButton.Paint(e.ItemPaintArgs); g.TranslateTransform(0, -1); rApp.Inflate(0, 2); rApp.Width-=3; g.SetClip(rApp, CombineMode.Exclude); } } } using (Pen pen = new Pen(ct.OuterBorder.Start, 1)) g.DrawPath(pen, path); if (!selectedTabRect.IsEmpty) { if (oldRegion != null) g.Clip = oldRegion; else g.ResetClip(); } if (oldRegion != null) oldRegion.Dispose(); } // Light border bottomBounds.Y++; if (ct.InnerBorder != null) { using (GraphicsPath path = GetBottomLinePath(bottomBounds, cornerSize)) { using (Pen pen = new Pen(ct.InnerBorder.Start, 1)) g.DrawPath(pen, path); } } } else { int topLineY = rc.ClientRectangle.Bottom - 2; if (!ct.TabDividerBorder.IsEmpty) { using (Pen pen = new Pen(ct.TabDividerBorder, 1)) g.DrawLine(pen, 0, topLineY, rc.ClientRectangle.Right, topLineY); topLineY++; } if (!ct.TabDividerBorderLight.IsEmpty) { using (Pen pen = new Pen(ct.TabDividerBorderLight, 1)) g.DrawLine(pen, 0, topLineY, rc.ClientRectangle.Right, topLineY); } } }
/// <summary> /// Paints form caption background /// </summary> public override void PaintCaptionBackground(RibbonControlRendererEventArgs e, Rectangle displayRect) { Graphics g = e.Graphics; RibbonControl rc = e.RibbonControl; Rendering.Office2007RibbonColorTable ct = m_ColorTable.RibbonControl; // Draw top divider line that sits between the tabs and any items above int topLineY = GetTabYPosition(rc.Items); if (topLineY == -1) topLineY = rc.RibbonStrip.GetAbsoluteCaptionHeight() + 2; if (topLineY > 2) { if (e.GlassEnabled && rc.EffectiveStyle == eDotNetBarStyle.Windows7) topLineY -= 2; else topLineY -= 3; if (!e.GlassEnabled) { if (!ct.TabDividerBorder.IsEmpty) { using (Pen pen = new Pen(ct.TabDividerBorder, 1)) g.DrawLine(pen, 0, topLineY, displayRect.Right + 12, topLineY); // 12 extension when painting from Office2007RibbonForm topLineY++; } if (!ct.TabDividerBorderLight.IsEmpty) { using (Pen pen = new Pen(ct.TabDividerBorderLight, 1)) g.DrawLine(pen, 0, topLineY, displayRect.Right + 12, topLineY); } } else { if (rc.EffectiveStyle != eDotNetBarStyle.Office2010 && rc.EffectiveStyle != eDotNetBarStyle.Metro) { using (Pen pen = new Pen(m_ColorTable.Form.Active.BorderColors[0], 1)) g.DrawLine(pen, 0, topLineY, displayRect.Right + 12, topLineY); // 12 extension when painting from Office2007RibbonForm } } } // Draw Caption if necessary if (rc.RibbonStrip.CaptionVisible) { Rendering.Office2007FormStateColorTable formct = m_ColorTable.Form.Active; System.Windows.Forms.Form form = rc.FindForm(); if (!rc.IsDesignMode && form != null && (form != System.Windows.Forms.Form.ActiveForm && form.MdiParent == null || form.MdiParent != null && form.MdiParent.ActiveMdiChild != form)) { formct = m_ColorTable.Form.Inactive; } Rectangle captionRect = new Rectangle(displayRect.X, displayRect.Y, displayRect.Width, topLineY - 1); if (captionRect.Height <= 0) captionRect.Height = rc.RibbonStrip.GetAbsoluteCaptionHeight(); if (!e.GlassEnabled) { Rectangle drawRect = captionRect; if (form is RibbonForm) drawRect.Width = ((RibbonForm)form).Width; SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = SmoothingMode.Default; if (!formct.CaptionTopBackground.End.IsEmpty && !formct.CaptionBottomBackground.End.IsEmpty) { using (LinearGradientBrush lb = new LinearGradientBrush(drawRect, formct.CaptionTopBackground.Start, formct.CaptionBottomBackground.End, formct.CaptionTopBackground.GradientAngle)) { ColorBlend cb = new ColorBlend(4); cb.Colors = new Color[] { formct.CaptionTopBackground.Start, formct.CaptionTopBackground.End, formct.CaptionBottomBackground.Start, formct.CaptionBottomBackground.End }; cb.Positions = new float[] { 0, .4f, .4f, 1f }; lb.InterpolationColors = cb; g.FillRectangle(lb, drawRect); } } else { using (LinearGradientBrush lb = new LinearGradientBrush(drawRect, formct.CaptionTopBackground.Start, formct.CaptionBottomBackground.Start, formct.CaptionTopBackground.GradientAngle)) { g.FillRectangle(lb, drawRect); } } //// Top Part //Rectangle topCaptionPart = new Rectangle(drawRect.X, drawRect.Y, drawRect.Width, (int)(drawRect.Height * .4)); //DisplayHelp.FillRectangle(g, topCaptionPart, formct.CaptionTopBackground); //Rectangle bottomCaptionPart = new Rectangle(drawRect.X, topCaptionPart.Bottom, drawRect.Width, drawRect.Height - topCaptionPart.Height); //DisplayHelp.FillRectangle(g, bottomCaptionPart, formct.CaptionBottomBackground); g.SmoothingMode = sm; } rc.RibbonStrip.CaptionBounds = captionRect; } }