protected override Rectangle GetTextRectangle(ButtonItem button, ItemPaintArgs pa, eTextFormat stringFormat, CompositeImage image) { Rectangle r = base.GetTextRectangle(button, pa, stringFormat, image); if (image == null && string.IsNullOrEmpty(button.Symbol)) r.Inflate(-3, 0); return r; }
public override void PaintButtonText(ButtonItem button, ItemPaintArgs pa, Color textColor, CompositeImage image) { Rectangle r = button.DisplayRectangle; r.Inflate(-1, -1); r.Width--; Office2007ButtonItemColorTable colorTable = GetColorTable(button, eButtonContainer.RibbonStrip); Color shadowColor = Color.FromArgb(32, Color.Black); if (colorTable.Default != null && colorTable.Default.OuterBorder != null && !colorTable.Default.OuterBorder.IsEmpty) shadowColor = colorTable.Default.OuterBorder.Start; if (pa.GlassEnabled) { ThemeTextFormat textFormat = ThemeTextFormat.Center | ThemeTextFormat.VCenter | ThemeTextFormat.HidePrefix | ThemeTextFormat.SingleLine; Office2007RibbonControlPainter.PaintShadowTextOnGlass(pa.Graphics, button.Text, pa.Font, r, textFormat,textColor, shadowColor , true); } else { eTextFormat format = eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.HidePrefix; // Shadow r.Offset(1, 1); TextDrawing.DrawString(pa.Graphics, button.Text, pa.Font, shadowColor, r, format); r.Offset(-1, -1); TextDrawing.DrawString(pa.Graphics, button.Text, pa.Font, textColor, r, format); } }
protected override Rectangle GetTextRectangle(ButtonItem button, ItemPaintArgs pa, eTextFormat stringFormat, CompositeImage image) { Rectangle r = base.GetTextRectangle(button, pa, stringFormat, image); r.Offset(0, 12); //r.Height -= 18; return r; }
public static CompositeImage GetButtonImage(BubbleButton button, Size size) { CompositeImage image=null; if(button.Image!=null) { if(button.Image.Size==size || button.ImageLarge==null) image=new CompositeImage(button.Image,false,size); else if(button.ImageLarge!=null && (button.ImageLarge.Size==size || button.ImageLarge.Size.Height/size.Height<2)) image=new CompositeImage(button.ImageLarge,false,size); else image=new CompositeImage(button.Image,false,size); } else if(button.ImageCached!=null) { if(button.ImageCached.Size==size || button.ImageLargeCached==null) image=new CompositeImage(button.ImageCached,false,size); else if(button.ImageLargeCached!=null && button.ImageLargeCached.Size.Height/size.Height<=2) image=new CompositeImage(button.ImageLargeCached,false,size); else image=new CompositeImage(button.ImageCached,false,size); } // else if(button.Icon!=null) // { // // } return image; }
public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { bool isOnMenu = IsOnMenu(button, pa); if(isOnMenu) base.PaintButtonBackground(button,pa, image); else PaintButtonCheck(button,pa,image,button.DisplayRectangle); }
/// <summary> /// Paints state of the button, either hot, pressed or checked /// </summary> /// <param name="button"></param> /// <param name="pa"></param> /// <param name="image"></param> public override void PaintButtonMouseOver(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r) { if (IsOffice2003Rendering(button, pa)) { base.PaintButtonMouseOver(button, pa, image, r); return; } //PaintState(button, pa, image, r, button.IsMouseDown); }
public override void PaintButtonImage(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle imagebounds) { if (!string.IsNullOrEmpty(button.Text)) return; Rectangle r = button.DisplayRectangle; r.X = r.X + (r.Width - imagebounds.Width) / 2; r.Y = r.Y + (r.Height - imagebounds.Height) / 2; r.Width = imagebounds.Width; r.Height = imagebounds.Height; base.PaintButtonImage(button, pa, image, r); }
public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { Office2007ButtonItemColorTable colors = GetColorTable(button, eButtonContainer.RibbonStrip); Office2007ButtonItemStateColorTable stateColors = colors.Default; if (button.IsMouseDown) stateColors = colors.Pressed; else if (button.IsMouseOver) stateColors = colors.MouseOver; Rectangle bounds = button.DisplayRectangle; bounds.Width--; Graphics g = pa.Graphics; using (GraphicsPath borderPath = DisplayHelp.GetRoundedRectanglePath(bounds, 2, 2, 0, 0)) { DisplayHelp.FillPath(g, borderPath, stateColors.Background); if (stateColors.BottomBackgroundHighlight != null && !stateColors.BottomBackgroundHighlight.IsEmpty) { Rectangle ellipse = new Rectangle(bounds.X - 12, bounds.Y + bounds.Height / 2 - 4, bounds.Width + 24, bounds.Height + 4); using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ellipse); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.CenterColor = stateColors.BottomBackgroundHighlight.Start; brush.SurroundColors = new Color[] { stateColors.BottomBackgroundHighlight.End }; brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, bounds.Bottom - 1); g.FillRectangle(brush, bounds); } } } if (stateColors.InnerBorder != null && !stateColors.InnerBorder.IsEmpty) { Rectangle innerBorder = bounds; innerBorder.Y += 1; innerBorder.Width -= 1; innerBorder.X++; DisplayHelp.DrawGradientRectangle(g, innerBorder, stateColors.InnerBorder, 1); //using (GraphicsPath innerBorderPath = DisplayHelp.GetRoundedRectanglePath(innerBorder, 1, 1, 0, 0)) //{ // DisplayHelp.DrawGradientPathBorder(g, innerBorderPath, stateColors.InnerBorder, 1); //} using (Pen pen = new Pen(ColorScheme.GetColor(10, 0xffffff))) { g.DrawLine(pen, innerBorder.X + 1, innerBorder.Y + 1, innerBorder.X + 1, innerBorder.Bottom - 1); g.DrawLine(pen, innerBorder.Right - 2, innerBorder.Y + 1, innerBorder.Right - 2, innerBorder.Bottom - 1); } } DisplayHelp.DrawGradientPathBorder(g, borderPath, stateColors.OuterBorder, 1); } }
internal void PaintImage(ItemPaintArgs p, Image image, eLabelPartAlignment imageAlign) { if (image == null) return; Graphics g = p.Graphics; Rectangle imageRect = GetAlignedRect(this.DisplayRectangle, image.Size, imageAlign); CompositeImage ci = new CompositeImage(image, false); ci.DrawImage(g, imageRect); ci.Dispose(); _ImageRenderBounds = imageRect; }
public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { Office2007ButtonItemColorTable colors = GetColorTable(button, eButtonContainer.RibbonStrip); Office2007ButtonItemStateColorTable stateColors = colors.Default; if (button.IsMouseDown) stateColors = colors.Pressed; else if (button.IsMouseOver) stateColors = colors.MouseOver; Rectangle bounds = button.DisplayRectangle; bounds.Width--; //bounds.Height--; Graphics g = pa.Graphics; if (pa.ContainerControl.FindForm() is RibbonForm) bounds.Width -= RibbonFormWidthOffset; //using (GraphicsPath borderPath = DisplayHelp.GetRoundedRectanglePath(bounds, 0, 2, 2, 0)) { //DisplayHelp.FillPath(g, borderPath, stateColors.Background); DisplayHelp.FillRectangle(g, bounds, stateColors.Background); if (stateColors.BottomBackgroundHighlight != null && !stateColors.BottomBackgroundHighlight.IsEmpty) { Rectangle ellipse = new Rectangle(bounds.X - 12, bounds.Y + bounds.Height / 2 - 4, bounds.Width + 24, bounds.Height + 4); using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ellipse); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.CenterColor = stateColors.BottomBackgroundHighlight.Start; brush.SurroundColors = new Color[] { stateColors.BottomBackgroundHighlight.End }; brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, bounds.Bottom - 1); g.FillRectangle(brush, bounds); } } } if (stateColors.InnerBorder != null && !stateColors.InnerBorder.IsEmpty) { Rectangle innerBorder = bounds; innerBorder.Inflate(-1, -1); using (GraphicsPath innerBorderPath = new GraphicsPath()) { innerBorderPath.AddRectangle(innerBorder); DisplayHelp.DrawGradientPath(g, innerBorderPath, innerBorder, stateColors.InnerBorder, 1); } } if (stateColors.OuterBorder != null && !stateColors.OuterBorder.IsEmpty) DisplayHelp.DrawRectangle(g, stateColors.OuterBorder.Start, bounds); //DisplayHelp.DrawGradientPathBorder(g, borderPath, stateColors.OuterBorder, 1); } }
public override void PaintButtonCheck(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r) { if (IsOffice2003Rendering(button, pa)) { base.PaintButtonCheck(button, pa, image, r); return; } bool isOnMenu = IsOnMenu(button, pa); if (isOnMenu) base.PaintButtonCheck(button, pa, image, r); //else // PaintState(button, pa, image, r, button.IsMouseDown); }
public override Rectangle GetImageRectangle(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { Rectangle imageRect = Rectangle.Empty; bool isOnMenu = IsOnMenu(button, pa); // Calculate image position if (image != null) { imageRect.Width = image.Width + 16; imageRect.Height = image.Height + 16; imageRect.X = button.DisplayRectangle.X + (button.DisplayRectangle.Width - imageRect.Width) / 2; imageRect.Y = button.DisplayRectangle.Y + 3; } return imageRect; }
public override void PaintButtonImage(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle imagebounds) { if (imagebounds.Width <= 0 || imagebounds.Height <= 0) return; // Paint image background RibbonOverflowButtonItem overflow = button as RibbonOverflowButtonItem; if (overflow == null || overflow.RibbonBar==null) { base.PaintButtonImage(button, pa, image, imagebounds); return; } ElementStyle backStyle = overflow.RibbonBar.GetPaintBackgroundStyle(); ElementStyle titleStyle = overflow.RibbonBar.TitleStyle; int cornerSize = 3; if (backStyle.BackColorBlend.Count > 0) DisplayHelp.FillRoundedRectangle(pa.Graphics, imagebounds, cornerSize, backStyle.BackColorBlend[0].Color, backStyle.BackColorBlend[backStyle.BackColorBlend.Count-1].Color, overflow.RibbonBar.BackgroundStyle.BackColorGradientAngle); else DisplayHelp.FillRoundedRectangle(pa.Graphics, imagebounds, cornerSize, backStyle.BackColor, backStyle.BackColor2, backStyle.BackColorGradientAngle); if(!button.Expanded) DisplayHelp.FillRectangle(pa.Graphics, new Rectangle(imagebounds.X+1, imagebounds.Bottom - 8, imagebounds.Width-2, 7), titleStyle.BackColor, titleStyle.BackColor2, titleStyle.BackColorGradientAngle); if (!backStyle.BorderColor.IsEmpty) { using (GraphicsPath path = new GraphicsPath()) { path.AddLine(imagebounds.X, imagebounds.Bottom - 8, imagebounds.Right, imagebounds.Bottom - 8); ElementStyleDisplay.AddCornerArc(path, imagebounds, cornerSize, eCornerArc.BottomRight); ElementStyleDisplay.AddCornerArc(path, imagebounds, cornerSize, eCornerArc.BottomLeft); path.CloseAllFigures(); using (SolidBrush brush = new SolidBrush(Color.FromArgb(192, backStyle.BorderColor))) pa.Graphics.FillPath(brush, path); } } DisplayHelp.DrawRoundGradientRectangle(pa.Graphics, imagebounds, backStyle.BorderColor, backStyle.BorderColor2, backStyle.BorderGradientAngle, 1, cornerSize); imagebounds.X += (imagebounds.Width - image.Width) / 2; imagebounds.Y += 4; imagebounds.Width = image.Width; imagebounds.Height = image.Height; image.DrawImage(pa.Graphics, imagebounds); }
private void btnSaveShapeToScript_Click(object sender, EventArgs e) { SaveFileDialog save = new SaveFileDialog(); save.FileName = "Shape" + counter.ToString() + ".txt"; save.Filter = "Text File | *.txt"; if (save.ShowDialog() == DialogResult.OK) { CompositeImage ci = new CompositeImage(save.FileName); StreamWriter writer = new StreamWriter(save.OpenFile()); for (int i = 0; i < shapeList.Count(); i++) { writer.WriteLine(shapeList[i].ToString()); ci.addShape(shapeList[i]); } writer.Dispose(); writer.Close(); } }
public void saveAs() { SaveFileDialog save = new SaveFileDialog(); save.FileName = "Shape" + counter.ToString() + ".txt"; save.Filter = "Text File | *.txt"; if (save.ShowDialog() == DialogResult.OK) { CompositeImage ci = new CompositeImage(save.FileName); saveFilepath = save.FileName; StreamWriter writer = new StreamWriter(save.OpenFile()); for (int i = 0; i < shapeList.Count(); i++) { writer.WriteLine(shapeList[i].ToString()); ci.addShape(shapeList[i]); } writer.Dispose(); writer.Close(); counter++; saved = true; } }
protected override void PaintState(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r, bool isMouseDown) { }
public override eTextFormat GetStringFormat(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { eTextFormat sf = base.GetStringFormat(button, pa, image); sf &= ~(sf & eTextFormat.EndEllipsis); return sf; }
public abstract void PaintButtonImage(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle imagebounds);
public abstract void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image);
public override void PaintButtonCheck(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r) { bool isOnMenu = IsOnMenu(button, pa); if(isOnMenu) { base.PaintButtonCheck(button,pa,image,r); return; } // TODO: Cleanup code here, tabs were drawn for every state that code is still left if(!button.IsMouseOver && !button.Checked) return; Color topColor=pa.Colors.BarBackground2; Color bottomColor=pa.Colors.BarBackground; Color borderColor=pa.Colors.BarFloatingBorder; int angle=pa.Colors.BarBackgroundGradientAngle; if(button.IsMouseOver && !button.Checked) { topColor=pa.Colors.ItemHotBackground2; bottomColor=pa.Colors.ItemHotBackground; angle=pa.Colors.ItemHotBackgroundGradientAngle; } else if(button.Checked) { topColor=Color.White;//pa.Colors.BarBackground2; bottomColor=pa.Colors.BarBackground; //pa.Colors.BarBackground; //topColor=pa.Colors.ItemPressedBackground; //bottomColor=pa.Colors.ItemPressedBackground2; angle=pa.Colors.ItemPressedBackgroundGradientAngle; } Color lightColor=ControlPaint.LightLight(bottomColor); Color darkColor=Color.FromArgb(100,ControlPaint.Dark(topColor)); int cornerDiameter=4; Graphics g=pa.Graphics; GraphicsPath path=GetTabPath(r,cornerDiameter); path.CloseAllFigures(); // Background using(LinearGradientBrush brush=DisplayHelp.CreateLinearGradientBrush(r,topColor,bottomColor,angle)) { brush.GammaCorrection=true; g.FillPath(brush,path); } path.Dispose(); // Border light using(path=GetTabPathLight(r,cornerDiameter-1)) { using(Pen pen=new Pen(darkColor/*lightColor*/,1)) g.DrawPath(pen,path); } // Border dark using(path=GetTabPathDark(r,cornerDiameter-1)) { using(Pen pen=new Pen(darkColor,1)) g.DrawPath(pen,path); } // Border using(path=GetTabPath(r,cornerDiameter)) { using(Pen pen=new Pen(borderColor,1)) g.DrawPath(pen,path); } }
public abstract void PaintButtonMouseOver(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r);
/// <summary> /// Paints state of the button, either hot, pressed or checked /// </summary> /// <param name="button"></param> /// <param name="pa"></param> /// <param name="image"></param> public override void PaintButtonMouseOver(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r) { PaintButtonCheck(button,pa,image,r); }
public abstract void PaintButtonText(ButtonItem button, ItemPaintArgs pa, Color textColor, CompositeImage image);
protected virtual void PaintState(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r, bool isMouseDown) { if (r.IsEmpty) return; bool isOnMenu = pa.IsOnMenu; Office2007ColorTable colorTable = this.ColorTable; Graphics g = pa.Graphics; IShapeDescriptor shape = GetButtonShape(button, pa); eButtonContainer buttonCont = GetButtonContainerQualifier(pa, button); Office2007ButtonItemColorTable buttonColorTable = GetColorTable(button, buttonCont); Region oldClip = g.Clip; try { g.SetClip(r, CombineMode.Intersect); Office2007ButtonItemStateColorTable stateColors = buttonColorTable.Default; if (IsOnMenu(button, pa)) { Rectangle sideRect = new Rectangle(button.DisplayRectangle.Left, button.DisplayRectangle.Top, button.ImageDrawRect.Right, button.DisplayRectangle.Height); if (pa.RightToLeft) sideRect = new Rectangle(button.DisplayRectangle.Right - button.ImageDrawRect.Width, button.DisplayRectangle.Top, button.ImageDrawRect.Width, button.DisplayRectangle.Height); PaintMenuItemSide(button, pa, sideRect); } if (!IsItemEnabled(button, pa)) { if (!isOnMenu) PaintStateBackground(button, g, buttonColorTable.Disabled, r, shape, pa.IsDefaultButton, true); g.Clip = oldClip; return; } bool mouseOver = false; bool expanded = false; if (!button.DesignMode) { if (button.IsMouseOver && button.HotTrackingStyle != eHotTrackingStyle.Image && button.HotTrackingStyle != eHotTrackingStyle.None) { stateColors = buttonColorTable.MouseOver; mouseOver = true; } if (isMouseDown && button.HotTrackingStyle != eHotTrackingStyle.Image && button.HotTrackingStyle != eHotTrackingStyle.None) { if (buttonColorTable.Pressed != null) stateColors = buttonColorTable.Pressed; } else if (button.Checked && !button.IsMouseOver && !IsOnMenu(button, pa)) { stateColors = buttonColorTable.Checked; } else if (button.Expanded && button.HotTrackingStyle != eHotTrackingStyle.Image && !(!mouseOver && pa.IsOnMenu)) { stateColors = buttonColorTable.Expanded; expanded = true; } } else { if (button.Checked && !IsOnMenu(button, pa)) { stateColors = buttonColorTable.Checked; } else if (button.Expanded && button.HotTrackingStyle != eHotTrackingStyle.Image) { stateColors = buttonColorTable.Expanded; expanded = true; } } Rectangle subRect = GetTotalSubItemsRect(button); bool isSplitButton = (mouseOver || expanded) && !button.AutoExpandOnClick && !subRect.IsEmpty && !IsOnMenu(button, pa); eDotNetBarStyle effectiveStyle = button.EffectiveStyle; subRect.Offset(button.DisplayRectangle.Location); if (isSplitButton && !button.Checked && (effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Windows7 || effectiveStyle == eDotNetBarStyle.Metro)) { Rectangle[] rects = DisplayHelp.ExcludeRectangle(r, subRect); if (rects.Length > 0 && (button.IsMouseOverExpand || button.Expanded)) rects = DisplayHelp.ExcludeRectangle(r, rects[0]); if (rects.Length > 0) { PaintStateBackground(button, g, buttonColorTable.MouseOverSplitInactive, r, shape, pa.IsDefaultButton, !pa.IsOnNavigationBar); if (rects[0].X == r.X && rects[0].Right < r.Right) // Left aligned shape = (effectiveStyle == eDotNetBarStyle.Metro) ? _DefaultMetroShape : _DefaultOffice2007LeftShape; else if (rects[0].X > r.X && rects[0].Right == r.Right) // Right aligned shape = (effectiveStyle == eDotNetBarStyle.Metro) ? _DefaultMetroShape : _DefaultOffice2007RightShape; else if (rects[0].Y == r.Y && rects[0].Bottom < r.Bottom) // Top aligned shape = (effectiveStyle == eDotNetBarStyle.Metro) ? _DefaultMetroShape : _DefaultOffice2007TopShape; else if (rects[0].Y > r.Y && rects[0].Bottom == r.Bottom) // Bottom aligned shape = (effectiveStyle == eDotNetBarStyle.Metro) ? _DefaultMetroShape : _DefaultOffice2007BottomShape; PaintStateBackground(button, g, stateColors, rects[0], shape, pa.IsDefaultButton, !pa.IsOnNavigationBar); } else PaintStateBackground(button, g, stateColors, r, shape, pa.IsDefaultButton, !pa.IsOnNavigationBar); } else PaintStateBackground(button, g, stateColors, r, shape, pa.IsDefaultButton, !pa.IsOnNavigationBar); if (isSplitButton && !(effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Windows7 || effectiveStyle == eDotNetBarStyle.Metro)) { using (Brush brush = GetOverlayInactiveBrush()) { Rectangle backRect = button.DisplayRectangle; backRect.Inflate(-1, -1); if (!button.IsMouseOverExpand && !expanded) { subRect.Inflate(-1, -1); g.SetClip(subRect, CombineMode.Intersect); GraphicsPath backPath = shape.GetShape(backRect); if (backPath != null) { g.FillPath(brush, backPath); backPath.Dispose(); } } else if (!mouseOver || button.IsMouseOverExpand) { g.SetClip(subRect, CombineMode.Exclude); GraphicsPath backPath = shape.GetShape(backRect); if (backPath != null) { g.FillPath(brush, backPath); backPath.Dispose(); } } } } g.Clip = oldClip; } finally { if (oldClip != null) oldClip.Dispose(); } }
public override void PaintButtonText(ButtonItem button, ItemPaintArgs pa, Color textColor, CompositeImage image) { base.PaintButtonText(button,pa,textColor,image); }
public abstract Rectangle GetMouseOverRectangle(ButtonItem button, ItemPaintArgs pa, CompositeImage image);
public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { if (IsOffice2003Rendering(button, pa)) { base.PaintButtonBackground(button, pa, image); return; } if (button is ApplicationButton && m_ColorTable.RibbonControl.StartButtonDefault != null) { Image backImage = m_ColorTable.RibbonControl.StartButtonDefault; if (button.IsMouseDown || button.Expanded) backImage = m_ColorTable.RibbonControl.StartButtonPressed; else if (button.IsMouseOver) backImage = m_ColorTable.RibbonControl.StartButtonMouseOver; if (backImage != null) { if (Office2007ColorTable.CloneImagesOnAccess) backImage = backImage.Clone() as Image; pa.Graphics.DrawImageUnscaled(backImage, new Point(button.LeftInternal + (button.WidthInternal - backImage.Width) / 2, button.TopInternal + (button.HeightInternal - backImage.Height) / 2)); if (Office2007ColorTable.CloneImagesOnAccess) backImage.Dispose(); } } PaintState(button, pa, image, button.DisplayRectangle, button.IsMouseDown); }
public abstract eTextFormat GetStringFormat(ButtonItem button, ItemPaintArgs pa, CompositeImage image);
private static eTextFormat GetStringFormat(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { eTextFormat stringFormat = pa.ButtonStringFormat; bool isOnMenu = IsOnMenu(button, pa); if (!isOnMenu) { if (image == null || button.ImagePosition == eImagePosition.Top || button.ImagePosition == eImagePosition.Bottom) stringFormat |= eTextFormat.HorizontalCenter; } return stringFormat; }
public override void PaintButtonText(ButtonItem button, ItemPaintArgs pa, Color textColor, CompositeImage image) { eDotNetBarStyle effectiveStyle = button.EffectiveStyle; if (!((effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Metro) && pa.GlassEnabled)) { base.PaintButtonText(button, pa, textColor, image); return; } Rectangle r = GetTextRectangle(button, pa, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter, image); //r.Offset(0, 3); //r.Height -= 2; ThemeTextFormat textFormat = ThemeTextFormat.Center | ThemeTextFormat.VCenter | ThemeTextFormat.HidePrefix | ThemeTextFormat.SingleLine; bool renderGlow = true; //if (effectiveStyle == eDotNetBarStyle.Office2010 && StyleManager.Style == eStyle.Office2010Black) // renderGlow = false; Office2007RibbonControlPainter.PaintTextOnGlass(pa.Graphics, button.Text, pa.Font, r, textFormat, textColor, true, renderGlow, 10); }
protected override void PaintState(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r, bool isMouseDown) { if (r.IsEmpty || !IsItemEnabled(button, pa) || r.Width == 0 || r.Height == 0) return; RibbonTabItem tab = button as RibbonTabItem; if (tab == null || IsOnMenu(button, pa)) { base.PaintState(button, pa, image, r, isMouseDown); return; } bool isOnMenu = pa.IsOnMenu; Office2007RibbonTabItemColorTable tabColorTable = GetColorTable(tab); if (tabColorTable == null) return; bool ribbonExpanded = pa.ControlExpanded; Office2007RibbonTabItemStateColorTable stateColors = GetStateColorTable(tabColorTable, tab, ribbonExpanded); if (stateColors == null) return; Graphics g = pa.Graphics; int cornerSize = tabColorTable.CornerSize; Region oldClip = g.Clip; try { Rectangle rClip = r; rClip.Inflate(1, 0); g.SetClip(rClip, CombineMode.Replace); if (stateColors != null) { eDotNetBarStyle effectiveStyle = button.EffectiveStyle; using (GraphicsPath path = GetTabPath(r, cornerSize, true, effectiveStyle)) { DisplayHelp.FillPath(g, path, stateColors.Background); DisplayHelp.DrawGradientPathBorder(g, path, stateColors.OuterBorder, 1); } if (effectiveStyle != eDotNetBarStyle.Metro && tab.Checked && ribbonExpanded && tab.RenderTabState /*|| tab.IsMouseOver*/) { SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = SmoothingMode.Default; if (this.ColorTable.RibbonControl.TabsBackground.Start.GetBrightness() > .5 && !stateColors.OuterBorder.IsEmpty) { using (GraphicsPath path = new GraphicsPath()) { path.AddRectangle(new Rectangle(r.Right - 1, r.Y + cornerSize + 1, 1, r.Height - cornerSize - 3)); DisplayHelp.FillPath(g, path, Color.FromArgb(96, stateColors.OuterBorder.Start), Color.FromArgb(32, stateColors.OuterBorder.End), 90); } using (GraphicsPath path = new GraphicsPath()) { path.AddRectangle(new Rectangle(r.X + 1, r.Y + cornerSize + 1, 1, r.Height - cornerSize - 3)); DisplayHelp.FillPath(g, path, Color.FromArgb(32, stateColors.OuterBorder.Start), Color.FromArgb(8, stateColors.OuterBorder.End), 90); } } g.SmoothingMode = sm; } Rectangle r1 = r; r1.Inflate(-1, 0); r1.Height--; r1.Y++; using (GraphicsPath path = GetTabPath(r1, cornerSize, true, effectiveStyle)) { DisplayHelp.DrawGradientPathBorder(g, path, stateColors.InnerBorder, 1); } if (tab.Checked && ribbonExpanded && tab.RenderTabState) { using (SolidBrush brush = new SolidBrush(stateColors.InnerBorder.Start)) { SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = SmoothingMode.None; g.FillRectangle(brush, new Rectangle(r1.X + cornerSize, r1.Y + 1, r1.Width - cornerSize * 2, 2)); g.SmoothingMode = sm; } } float topSplit = .6f; float bottomSplit = .4f; Rectangle fillRectangle = r; Rectangle backRect = new Rectangle(fillRectangle.X, fillRectangle.Y + (int)(fillRectangle.Height * topSplit), fillRectangle.Width, (int)(fillRectangle.Height * bottomSplit)); if (!stateColors.BackgroundHighlight.IsEmpty) { Rectangle ellipse = new Rectangle(backRect.X, backRect.Y, fillRectangle.Width, fillRectangle.Height); GraphicsPath path = new GraphicsPath(); path.AddEllipse(ellipse); PathGradientBrush brush = new PathGradientBrush(path); brush.CenterColor = stateColors.BackgroundHighlight.Start; brush.SurroundColors = new Color[] { stateColors.BackgroundHighlight.End }; brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, fillRectangle.Bottom + 2); Blend blend = new Blend(); blend.Factors = new float[] { 0f, .8f, 1f }; blend.Positions = new float[] { .0f, .55f, 1f }; brush.Blend = blend; g.FillRectangle(brush, backRect); brush.Dispose(); path.Dispose(); } } if (tab.ReducedSize && !tab.Checked && !tab.IsMouseOver && tabColorTable != null && tabColorTable.Selected != null) { Color c = this.ColorTable.RibbonControl.OuterBorder.Start; if (!c.IsEmpty) DisplayHelp.DrawGradientLine(g, new Point(r.Right - 1, r.Y), new Point(r.Right - 1, r.Bottom - 1), Color.Transparent, c, 90, 1, new float[] { 0, .8f, 1f }, new float[] { 0, .50f, 1f }); } g.Clip = oldClip; } finally { if (oldClip != null) oldClip.Dispose(); } }
private static eTextFormat GetStringFormat(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { eTextFormat stringFormat=pa.ButtonStringFormat; bool isOnMenu = IsOnMenu(button, pa); if(!isOnMenu) { if(button.ContainerControl is RibbonStrip && (image==null || button.ImagePosition==eImagePosition.Top || button.ImagePosition==eImagePosition.Bottom)) stringFormat |= eTextFormat.HorizontalCenter; else if(pa.IsOnMenuBar || pa.ContainerControl is Bar && image==null || button.ImagePosition==eImagePosition.Top || button.ImagePosition==eImagePosition.Bottom) stringFormat |= eTextFormat.HorizontalCenter; } return stringFormat; }