private static void DrawGradientToolItem( Graphics g, ToolStripItem item, GradientItemColors colors) { DrawGradientItem(g, new Rectangle(Point.Empty, item.Bounds.Size), colors); }
private static void DrawGradientContextMenuItem( Graphics g, ToolStripItem item, GradientItemColors colors) { var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); DrawGradientItem(g, backRect, colors); }
public static void DrawGradientBorder(Graphics g, Rectangle outline, Color color) { GradientItemColors colors = Office2007Renderer._itemToolItemSelectedColors.Clone(); colors.FillTop1 = AdobeColors.ModifySaturation(color, 0.2); colors.FillTop2 = AdobeColors.ModifySaturation(color, 0.4); colors.FillBottom1 = color; colors.FillBottom2 = AdobeColors.ModifyBrightness(colors.FillTop2, 1.2); Instance.DrawGradientBorder(g, outline, colors); }
private static void DrawGradientToolSplitItem( Graphics g, ToolStripSplitButton splitButton, GradientItemColors colorsButton, GradientItemColors colorsDrop, GradientItemColors colorsSplit) { var backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); var backRectDrop = splitButton.DropDownButtonBounds; if ((backRect.Width <= 0) || (backRectDrop.Width <= 0) || (backRect.Height <= 0) || (backRectDrop.Height <= 0)) { return; } var backRectButton = backRect; int splitOffset; if (backRectDrop.X > 0) { backRectButton.Width = backRectDrop.Left; backRectDrop.X -= 1; backRectDrop.Width++; splitOffset = backRectDrop.X; } else { backRectButton.Width -= backRectDrop.Width - 2; backRectButton.X = backRectDrop.Right - 1; backRectDrop.Width++; splitOffset = backRectDrop.Right - 1; } using (CreateBorderPath(backRect, CutMenuItemBack)) { DrawGradientBack(g, backRectButton, colorsButton); DrawGradientBack(g, backRectDrop, colorsDrop); using (var splitBrush = new LinearGradientBrush( new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1), colorsSplit.Border1, colorsSplit.Border2, 90f)) { splitBrush.SetSigmaBellShape(0.5f); using (var splitPen = new Pen(splitBrush)) g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); } DrawGradientBorder(g, backRect, colorsButton); } }
private static void DrawGradientItem( Graphics g, Rectangle backRect, GradientItemColors colors) { if ((backRect.Width <= 0) || (backRect.Height <= 0)) { return; } DrawGradientBack(g, backRect, colors); DrawGradientBorder(g, backRect, colors); }
private static void DrawGradientBack( Graphics g, Rectangle backRect, GradientItemColors colors) { backRect.Inflate(-1, -1); var y2 = backRect.Height / 2; var backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); var backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); var backRect1I = backRect1; var backRect2I = backRect2; backRect1I.Inflate(1, 1); backRect2I.Inflate(1, 1); using (LinearGradientBrush insideBrush1 = new LinearGradientBrush(backRect1I, colors.InsideTop1, colors.InsideTop2, 90f), insideBrush2 = new LinearGradientBrush(backRect2I, colors.InsideBottom1, colors.InsideBottom2, 90f)) { g.FillRectangle(insideBrush1, backRect1); g.FillRectangle(insideBrush2, backRect2); } y2 = backRect.Height / 2; backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); backRect1I = backRect1; backRect2I = backRect2; backRect1I.Inflate(1, 1); backRect2I.Inflate(1, 1); using (LinearGradientBrush fillBrush1 = new LinearGradientBrush(backRect1I, colors.FillTop1, colors.FillTop2, 90f), fillBrush2 = new LinearGradientBrush(backRect2I, colors.FillBottom1, colors.FillBottom2, 90f)) { backRect.Inflate(-1, -1); y2 = backRect.Height / 2; backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); g.FillRectangle(fillBrush1, backRect1); g.FillRectangle(fillBrush2, backRect2); } }
private static void DrawGradientBorder( Graphics g, Rectangle backRect, GradientItemColors colors) { using (new UseAntiAlias(g)) { var backRectI = backRect; backRectI.Inflate(1, 1); using (var borderBrush = new LinearGradientBrush(backRectI, colors.Border1, colors.Border2, 90f)) { borderBrush.SetSigmaBellShape(0.5f); using (var borderPen = new Pen(borderBrush)) { using (var borderPath = CreateBorderPath(backRect, CutMenuItemBack)) g.DrawPath(borderPen, borderPath); } } } }
private void DrawGradientItem(Graphics g, Rectangle backRect, GradientItemColors colors) { // Cannot paint a zero sized area if ((backRect.Width > 0) && (backRect.Height > 0)) { // Draw the background of the entire item this.DrawGradientBack(g, backRect, colors); // Draw the border of the entire item this.DrawGradientBorder(g, backRect, colors); } }
private void DrawGradientContextMenuItem(Graphics g, ToolStripItem item, GradientItemColors colors) { // Do we need to draw with separator on the opposite edge? Rectangle backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background this.DrawGradientItem(g, backRect, colors); }
/// <summary> /// Initializes a new instance of the <see cref="Office2007Renderer"/> class. /// </summary> /// <param name="textColorIsRed">if set to <c>true</c> [text color is red].</param> /// <param name="colors">The colors.</param> private Office2007Renderer(bool textColorIsRed, ProfessionalColorTable colors) : base(colors) { if (textColorIsRed) _textColor = Color.FromArgb(137, 22, 22); else _textColor = Color.FromArgb(21, 66, 139); // blue // Palette Initialization _textDisabled = _disabledTextColor; _textMenuStripItem = _textColor; _textStatusStripItem = _textColor; _textContextMenuItem = _textColor; _arrowDisabled = _disabledTextColor; _arrowLight = Color.FromArgb(106, 126, 197); _arrowDark = Color.FromArgb(64, 70, 90); _separatorMenuLight = Color.FromArgb(245, 245, 245); _separatorMenuDark = Color.FromArgb(197, 197, 197); _contextMenuBack = _c4; _contextCheckBorder = Color.FromArgb(242, 149, 54); _contextCheckTick = Color.FromArgb(66, 75, 138); _statusStripBorderDark = Color.FromArgb(86, 125, 176); _statusStripBorderLight = Color.White; _gripDark = Color.FromArgb(114, 152, 204); _gripLight = _c5; _itemContextItemEnabledColors = new GradientItemColors( _r1, _r2, _r3, _r4, _r5, _r6, _r7, _r8, Color.FromArgb(217, 203, 150), Color.FromArgb(192, 167, 118)); _itemDisabledColors = new GradientItemColors( _c4, _c6, Color.FromArgb(236, 236, 236), Color.FromArgb(230, 230, 230), _c6, Color.FromArgb(224, 224, 224), Color.FromArgb(200, 200, 200), Color.FromArgb(210, 210, 210), Color.FromArgb(212, 212, 212), Color.FromArgb(195, 195, 195)); _itemToolItemSelectedColors = new GradientItemColors(_r1, _r2, _r3, _r4, _r5, _r6, _r7, _r8, _r9, _rA); _itemToolItemPressedColors = new GradientItemColors(_rD, _rE, _rF, _rG, _rH, _rI, _rJ, _rK, _r9, _rA); _itemToolItemCheckedColors = new GradientItemColors(_rL, _rM, _rN, _rO, _rP, _rQ, _rR, _rS, _r9, _rA); _itemToolItemCheckPressColors = new GradientItemColors(_rT, _rU, _rV, _rW, _rX, _rI, _rY, _rZ, _r9, _rA); }
private static void DrawGradientBack(Graphics g, Rectangle backRect, GradientItemColors colors) { backRect.X++; backRect.Width -= 1; using (RenderContext context = new RenderContext(null, g, backRect, null)) { using (GraphicsPath backPath = CreateBorderPath(backRect, _cutMenuItemBack)) { backRect.Width -= 1; backRect.Height -= 1; RenderGlassHelpers.DrawBackGlassBottom(context, backRect, colors.Begin, colors.End, VisualOrientation.Top, backPath, null); } } }
private void UpdateCache() { // Only need to create the cache objects first time around if (_gradientItem == null) { _linearItem = new LinearItemColors(KCT.ButtonSelectedGradientMiddle, CommonHelper.BlackenColor(KCT.ButtonSelectedGradientMiddle, 0.91f, 0.91f, 0.91f), CommonHelper.BlackenColor(KCT.ButtonSelectedGradientMiddle, 0.75f, 0.75f, 0.75f)); _gradientItem = new GradientItemColors(KCT.CheckBackground, KCT.ButtonSelectedGradientBegin, KCT.ButtonSelectedGradientBegin); _gradientTracking = new GradientItemColors(KCT.ButtonSelectedBorder, KCT.ButtonSelectedGradientBegin, KCT.ButtonSelectedGradientEnd); _gradientPressed = new GradientItemColors(KCT.ButtonPressedBorder, KCT.ButtonPressedGradientBegin, KCT.ButtonPressedGradientEnd); _gradientChecked = new GradientItemColors(KCT.ButtonPressedBorder, KCT.ButtonCheckedGradientBegin, KCT.ButtonCheckedGradientEnd); _gradientCheckedTracking = new GradientItemColors(KCT.ButtonSelectedBorder, KCT.ButtonPressedGradientBegin, KCT.ButtonCheckedGradientEnd); } }
private void DrawGradientToolItem(Graphics g, ToolStripItem item, GradientItemColors colors) { // Perform drawing into the entire background of the item this.DrawGradientItem(g, new Rectangle(Point.Empty, item.Bounds.Size), colors); }
private static void DrawGradientBorder(Graphics g, Rectangle backRect, GradientItemColors colors) { var backRectI = backRect; backRectI.Inflate(1, 1); // Finally draw the border around the menu item using (var borderBrush = new LinearGradientBrush(backRectI, colors.Border1, colors.Border2, 90f)) { // Sigma curve, so go from color1 to color2 and back to color1 again borderBrush.SetSigmaBellShape(0.5f); // Convert the brush to a pen for DrawPath call using (var borderPen = new Pen(borderBrush)) { // Create border path around the entire item using (var borderPath = CreateBorderPath(backRect, _cutMenuItemBack)) g.DrawPath(borderPen, borderPath); } } }
private void DrawGradientContextMenuItem(Graphics g, ToolStripItem item, GradientItemColors colors) { // Do we need to draw with separator on the opposite edge? var backRect = new Rectangle(2, 0, item.Bounds.Width - 3, item.Bounds.Height); // Perform actual drawing into the background backRect.X++; backRect.Width -= 2; if ((backRect.Width > 0) && (backRect.Height > 0)) { // Draw the background of the entire item DrawGradientBack(g, backRect, colors); // Draw the border of the entire item DrawGradientBorder(g, backRect, colors); // g.Clear(Color.Red); } // DrawGradientItem(g, backRect, colors); }
private void DrawGradientBack(Graphics g, Rectangle backRect, GradientItemColors colors) { // Reduce rect draw drawing inside the border backRect.Inflate(-1, -1); int y2 = backRect.Height/2; Rectangle backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); Rectangle backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); Rectangle backRect1I = backRect1; Rectangle backRect2I = backRect2; backRect1I.Inflate(1, 1); backRect2I.Inflate(1, 1); using ( LinearGradientBrush insideBrush1 = new LinearGradientBrush(backRect1I, colors.InsideTop1, colors.InsideTop2, 90f), insideBrush2 = new LinearGradientBrush(backRect2I, colors.InsideBottom1, colors.InsideBottom2, 90f)) { g.FillRectangle(insideBrush1, backRect1); g.FillRectangle(insideBrush2, backRect2); } y2 = backRect.Height/2; backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); backRect1I = backRect1; backRect2I = backRect2; backRect1I.Inflate(1, 1); backRect2I.Inflate(1, 1); using ( LinearGradientBrush fillBrush1 = new LinearGradientBrush(backRect1I, colors.FillTop1, colors.FillTop2, 90f), fillBrush2 = new LinearGradientBrush(backRect2I, colors.FillBottom1, colors.FillBottom2, 90f)) { // Reduce rect one more time for the innermost drawing backRect.Inflate(-1, -1); y2 = backRect.Height/2; backRect1 = new Rectangle(backRect.X, backRect.Y, backRect.Width, y2); backRect2 = new Rectangle(backRect.X, backRect.Y + y2, backRect.Width, backRect.Height - y2); g.FillRectangle(fillBrush1, backRect1); g.FillRectangle(fillBrush2, backRect2); } }
private void DrawGradientBorder(Graphics g, Rectangle backRect, GradientItemColors colors) { // Drawing with anti aliasing to create smoother appearance using (UseAntiAlias uaa = new UseAntiAlias(g)) { Rectangle backRectI = backRect; backRectI.Inflate(1, 1); // Finally draw the border around the menu item using ( LinearGradientBrush borderBrush = new LinearGradientBrush(backRectI, colors.Border1, colors.Border2, 90f)) { // Sigma curve, so go from color1 to color2 and back to color1 again borderBrush.SetSigmaBellShape(0.5f); // Convert the brush to a pen for DrawPath call using (Pen borderPen = new Pen(borderBrush)) { // Create border path around the entire item using (GraphicsPath borderPath = this.CreateBorderPath(backRect, _cutMenuItemBack)) g.DrawPath(borderPen, borderPath); } } } }
private static void DrawSolidBorder(Graphics g, Rectangle backRect, GradientItemColors colors) { // Drawing with anti aliasing to create smoother appearance using (AntiAlias aa = new AntiAlias(g)) { Rectangle backRectI = backRect; backRectI.Inflate(1, 1); // Use solid color for the border using (Pen borderPen = new Pen(colors.Border)) using (GraphicsPath borderPath = CreateBorderPath(backRect, _cutMenuItemBack)) g.DrawPath(borderPen, borderPath); } }
private void DrawGradientToolSplitItem(Graphics g, ToolStripSplitButton splitButton, GradientItemColors colorsButton, GradientItemColors colorsDrop, GradientItemColors colorsSplit) { // Create entire area and just the drop button area rectangles Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas if ((backRect.Width > 0) && (backRectDrop.Width > 0) && (backRect.Height > 0) && (backRectDrop.Height > 0)) { // Area that is the normal button starts as everything Rectangle backRectButton = backRect; // The X offset to draw the split line int splitOffset; // Is the drop button on the right hand side of entire area? if (backRectDrop.X > 0) { backRectButton.Width = backRectDrop.Left; backRectDrop.X -= 1; backRectDrop.Width++; splitOffset = backRectDrop.X; } else { backRectButton.Width -= backRectDrop.Width - 2; backRectButton.X = backRectDrop.Right - 1; backRectDrop.Width++; splitOffset = backRectDrop.Right - 1; } // Create border path around the item using (GraphicsPath borderPath = this.CreateBorderPath(backRect, _cutMenuItemBack)) { // Draw the normal button area background this.DrawGradientBack(g, backRectButton, colorsButton); // Draw the drop button area background this.DrawGradientBack(g, backRectDrop, colorsDrop); // Draw the split line between the areas using ( LinearGradientBrush splitBrush = new LinearGradientBrush( new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1), colorsSplit.Border1, colorsSplit.Border2, 90f)) { // Sigma curve, so go from color1 to color2 and back to color1 again splitBrush.SetSigmaBellShape(0.5f); // Convert the brush to a pen for DrawPath call using (Pen splitPen = new Pen(splitBrush)) g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); } // Draw the border of the entire item this.DrawGradientBorder(g, backRect, colorsButton); } } }
private void DrawGradientToolSplitItem(Graphics g, ToolStripSplitButton splitButton, GradientItemColors colorsButton, GradientItemColors colorsDrop, GradientItemColors colorsSplit) { // Create entire area and just the drop button area rectangles Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas if ((backRect.Width > 0) && (backRectDrop.Width > 0) && (backRect.Height > 0) && (backRectDrop.Height > 0)) { // Area that is the normal button starts as everything Rectangle backRectButton = backRect; // The X offset to draw the split line int splitOffset; // Is the drop button on the right hand side of entire area? if (backRectDrop.X > 0) splitOffset = backRectDrop.X; else splitOffset = backRectDrop.Right - 1; // Create border path around the item using (GraphicsPath borderPath = CreateBorderPath(backRect, _cutMenuItemBack)) { // Draw the entire background area DrawGradientBack(g, backRect, colorsButton); // Draw the split line between the areas using (Pen splitPen = new Pen(colorsSplit.Border)) g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); // Draw the border of the entire item DrawSolidBorder(g, backRect, colorsButton); } } }