protected virtual void DrawItemBackground(PaintEventArgs e, bool hover, bool pressed) { Color color; //UIControlStatus us = UIControlStatus.Normal; if (pressed) { color = SystemColors.ControlDark; } //us = UIControlStatus.Selected; else if (hover) { color = SystemColors.ControlLight; } //us = UIControlStatus.Hover; else if (BackColor.HasValue) { color = BackColor.Value; } else { return; } e.Graphics.FillRectangle(new SolidBrush(color), Bounds); e.Graphics.DrawRectangle(new Pen(PaintHelper.GetDarkColor(color)), 0, 0, Bounds.Width, Bounds.Height); //Skin.DrawToolButtonBackground(new SkinPaintEventArgs(this, e), item.Bounds, us); }
protected override void DrawItemBackground(TabItemPaintEventArgs e) { //base.DrawItemBackground(e); TaskBar taskBar = e.GetBar <TaskBar>(); Color backColor = e.Bar.ItemBackColor; switch (e.Status) { case UIControlStatus.Selected: case UIControlStatus.Focused: if (taskBar.IsActive) { backColor = taskBar.SelectedItemBackColor; } else { backColor = taskBar.InactiveSelectedItemBackColor; } break; case UIControlStatus.Hover: backColor = taskBar.HoverItemBackColor; break; } if (!backColor.IsEmpty) { GraphicsPath path = PaintHelper.GetRoundRectangle(e.Bounds, taskBar.TabRounded, taskBar.TabRounded, 0, 0); //if (e.Status == UIControlStatus.Hover) //{ // LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds, backColor, backColor, 90.0f); // ColorBlend cb = new ColorBlend(3); // cb.Colors = new Color[] { PaintHelper.GetLightColor(backColor), backColor, backColor }; // cb.Positions = new float[] { 0.0f, 0.5f, 1.0f }; // backBrush.InterpolationColors = cb; // e.Graphics.FillPath(backBrush, path); //} //else //{ SolidBrush backBrush = new SolidBrush(backColor); e.Graphics.FillPath(backBrush, path); //} // if ((e.Status == UIControlStatus.Normal || e.Status == UIControlStatus.Hover) && e.Bounds.Height > 10) { Rectangle rectShadow = e.Bounds; rectShadow.Y = rectShadow.Bottom - 6; rectShadow.Height = 5; var brush = new LinearGradientBrush(rectShadow, Color.Transparent, PaintHelper.AdjustColorSLess(PaintHelper.GetDarkColor(backColor), 20), 90.0f); rectShadow.Y++;//规避一个Gdi+错误, 会导致第一行有一个很深的线 //e.Graphics.FillRectangle(Brushes.Red, rectShadow); e.Graphics.FillRectangle(brush, rectShadow); } } }
void PaintBackground(PaintEventArgs e) { //e.Graphics.Clear(BackColor); LinearGradientBrush brush = new LinearGradientBrush(ClientRectangle, PaintHelper.GetDarkColor(BackColor), BackColor, 45.0f); e.Graphics.FillRectangle(brush, ClientRectangle); }
protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) { //base.OnRenderImageMargin(e); Rectangle rect = e.AffectedBounds; rect.X += 2; rect.Width -= 2; rect.Y += 2; rect.Height -= 4; Color color = UITheme.Default.Colors.MediumDark;// PaintHelper.AdjustColor(Blumind.Core.Settings.Options.Default.Appearance.WindowBackColor, 15, 25, 90, 90); e.Graphics.FillRectangle(new SolidBrush(color), rect); e.Graphics.DrawLine(new Pen(PaintHelper.GetDarkColor(color, .1f)), rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); }
protected override void OnPaint(PaintEventArgs e) { Rectangle rect = ClientRectangle; Graphics grf = e.Graphics; LinearGradientBrush brush = new LinearGradientBrush(rect, PaintHelper.GetLightColor(BackColor), BackColor, 90.0f); grf.FillRectangle(brush, rect); if (!string.IsNullOrEmpty(Text)) { grf.DrawString(Text, Font, new SolidBrush(ForeColor), rect, PaintHelper.SFCenter); } grf.DrawRectangle(new Pen(PaintHelper.GetDarkColor(BackColor)), rect.Left, rect.Top, rect.Width - 1, rect.Height - 1); }
public DefaultToolStripColors() { UIColorTheme theme = UITheme.Default.Colors; if (theme == null) { theme = UIColorThemeManage.Default; } _MenuStripGradientEnd = theme.Workspace; _MenuStripGradientBegin = theme.Workspace; // PaintHelper.GetDarkColor(_MenuStripGradientEnd, 0.1); _MenuItemPressedGradientBegin = PaintHelper.GetLightColor(theme.Light, 0.2f); _MenuItemSelected = theme.MediumLight; // PaintHelper.GetDarkColor(theme.Sharp, 0.1f); MenuStripItemSelectedForeColor = PaintHelper.FarthestColor(_MenuItemSelected, theme.Dark, theme.Light); _MenuItemSelectedGradientMiddle = _MenuItemSelected; _MenuItemSelectedGradientBegin = PaintHelper.GetLightColor(_MenuItemSelectedGradientMiddle, 0.1f); _MenuItemSelectedGradientEnd = PaintHelper.GetLightColor(_MenuItemSelectedGradientMiddle, 0.05f); _MenuItemSelectedBorder = Color.Empty;// PaintHelper.AdjustColor(PaintHelper.GetDarkColor(theme.Sharp), 0, 50, 30, 40); _MenuBorder = theme.MediumLight; MenuStripItemForeColor = PaintHelper.FarthestColor(theme.Workspace, theme.MediumLight, theme.MediumDark, 50); _GripDark = PaintHelper.GetDarkColor(_MenuStripGradientBegin, 0.2); _GripLight = PaintHelper.GetLightColor(_MenuStripGradientBegin, 0.1); _ToolStripGradientBegin = theme.MediumLight; _ToolStripGradientMiddle = theme.MediumLight; _ToolStripGradientEnd = theme.MediumLight;// PaintHelper.GetDarkColor(theme.MediumLight, 0.1); _ToolStripDropDownBackground = theme.Light; _ImageMarginGradientBegin = theme.MenuImageMargin; _ImageMarginGradientMiddle = _ImageMarginGradientBegin; _ImageMarginGradientEnd = _ImageMarginGradientBegin; _CheckBackground = PaintHelper.GetLightColor(theme.MediumDark); _CheckSelectedBackground = PaintHelper.GetLightColor(_CheckBackground); //_SeparatorDark = _ToolStripGradientMiddle; _SeparatorDark = PaintHelper.GetDarkColor(_ToolStripGradientMiddle, 0.1); _SeparatorLight = Color.Empty; // PaintHelper.GetLightColor(_ToolStripGradientMiddle, 0.1); _ButtonCheckedGradientMiddle = PaintHelper.AdjustColor(theme.MediumLight, 0, 60, 40, 70); // .GetDarkColor(theme.MediumLight, 0.2); _ButtonCheckedGradientBegin = PaintHelper.GetDarkColor(_ButtonCheckedGradientMiddle, 0.2); _ButtonCheckedGradientEnd = PaintHelper.GetDarkColor(_ButtonCheckedGradientMiddle, 0.1); _ButtonSelectedBorder = PaintHelper.AdjustColor(theme.MediumDark, 0, 0, 30, 40); _ButtonSelectedGradientMiddle = PaintHelper.AdjustColor(theme.Sharp, 0, 100, 70, 80); _ButtonSelectedGradientBegin = PaintHelper.GetLightColor(_ButtonSelectedGradientMiddle, 0.2); _ButtonSelectedGradientEnd = PaintHelper.GetLightColor(_ButtonSelectedGradientMiddle, 0.1); }
protected override void OnPaint(PaintEventArgs e) { //base.OnPaint(e); InvokePaintBackground(this, e); Rectangle rectTitle = ClientRectangle; rectTitle.Height = FoldingButtonRect.Height; Size sizeText = Size.Ceiling(e.Graphics.MeasureString(Text, Font)); rectTitle.Height = Math.Max(rectTitle.Height, sizeText.Height); Image image = Folded ? Properties.Resources.folding_expand : Properties.Resources.folding_collapse; PaintHelper.DrawImageInRange(e.Graphics, image, FoldingButtonRect); rectTitle.X += FoldingButtonRect.Width; rectTitle.Width -= FoldingButtonRect.Width; e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), rectTitle, PaintHelper.SFLeft); rectTitle.X += sizeText.Width; rectTitle.Width -= sizeText.Width; PaintHelper.SetHighQualityRender(e.Graphics); e.Graphics.ExcludeClip(new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - rectTitle.Width, rectTitle.Height)); Rectangle rectBorder = new Rectangle(0, rectTitle.Y + rectTitle.Height / 2, ClientSize.Width, ClientSize.Height - rectTitle.Height / 2); Pen penLine = new Pen(PaintHelper.GetDarkColor(BackColor)); if (Folded) { e.Graphics.DrawLine(penLine, rectBorder.X, rectBorder.Y, rectBorder.Right, rectBorder.Y); } else { GraphicsPath path = PaintHelper.GetRoundRectangle(rectBorder, 6); e.Graphics.DrawPath(penLine, path); path.Dispose(); } if (Focused) { ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(0, 0, ClientSize.Width, ClientSize.Height)); } }
private void PaintSplitButton(PaintEventArgs e, Rectangle rect, bool hover, bool toLeftTop) { Brush brushBack = null; if (!hover) { brushBack = new SolidBrush(BackColor); } else { if (Orientation == Orientation.Horizontal) { brushBack = new LinearGradientBrush(rect, PaintHelper.GetLightColor(BackColor), BackColor, 90.0f); } else { brushBack = new LinearGradientBrush(rect, PaintHelper.GetLightColor(BackColor), BackColor, 0.0f); } } e.Graphics.FillRectangle(brushBack, rect); Pen penLine = new Pen(PaintHelper.GetDarkColor(BackColor)); const int iw = 5; const int ih = 3; if (Orientation == Orientation.Horizontal) { Image image = Properties.Resources.split_btn_h; int x = toLeftTop ? 0 : iw; e.Graphics.DrawImage(image, new Rectangle(rect.Left + (rect.Width - iw) / 2, rect.Top + (rect.Height - ih) / 2, iw, ih), x, 0, iw, ih, GraphicsUnit.Pixel); } else { Image image = Properties.Resources.split_btn_v; int y = toLeftTop ? 0 : iw; e.Graphics.DrawImage(image, new Rectangle(rect.Left + (rect.Width - iw) / 2, rect.Top + (rect.Height - ih) / 2, ih, iw), 0, y, ih, iw, GraphicsUnit.Pixel); } }
public static void DrawCaptionBackground(PaintEventArgs e , Rectangle rect , Color backColor , CaptionStyle backgroundStyle , int baseLineSize , Color baseLineColor) { if (rect.Width == 0 || rect.Height == 0) { return; } Brush brush; switch (backgroundStyle) { case CaptionStyle.HorizontalGradient: brush = new LinearGradientBrush(rect, backColor, PaintHelper.GetLightColor(backColor), 0.0f); e.Graphics.FillRectangle(brush, rect); break; case CaptionStyle.VerticalGradient: brush = new LinearGradientBrush(rect, backColor, PaintHelper.GetDarkColor(backColor), 90.0f); e.Graphics.FillRectangle(brush, rect); break; case CaptionStyle.BaseLine: if (baseLineSize > 0) { //brush = new LinearGradientBrush(rect, baseLineColor, Color.FromArgb(0, baseLineColor), 0.0f); brush = new SolidBrush(baseLineColor); e.Graphics.FillRectangle(brush, new Rectangle(rect.Left, rect.Bottom - baseLineSize, rect.Width, baseLineSize)); rect.Height -= baseLineSize; } break; default: break; } }
protected override void OnPaint(PaintEventArgs e) { Graphics grf = e.Graphics; grf.Clear(Owner.BackColor); Rectangle rect = new Rectangle(0, 0, Width, Height); //rect.Inflate(0, -1); //grf.FillRectangle(SystemBrushes.Highlight, rect); LinearGradientBrush brush = new LinearGradientBrush(rect, PaintHelper.GetLightColor(this.BackColor), this.BackColor, 90.0f); grf.FillRectangle(brush, rect); if (!string.IsNullOrEmpty(Text)) { grf.DrawString(Text, Owner.Font, new SolidBrush(this.ForeColor), rect, PaintHelper.SFLeft); } grf.DrawRectangle(new Pen(PaintHelper.GetDarkColor(this.BackColor)), rect.Left, rect.Top, rect.Width - 1, rect.Height - 1); }
protected virtual void DrawItemBackground(TabItemPaintEventArgs e) { var rect = e.Bounds; Color borderColor = Color.Empty; if (e.Selected) { // 把BaseLineSize加回去 switch (e.Bar.Alignment) { case TabAlignment.Left: rect.Width += e.Bar.BaseLineSize; break; case TabAlignment.Top: rect.Height += e.Bar.BaseLineSize; break; case TabAlignment.Right: rect.X -= e.Bar.BaseLineSize; rect.Width += e.Bar.BaseLineSize; break; case TabAlignment.Bottom: rect.Y -= e.Bar.BaseLineSize; rect.Height += e.Bar.BaseLineSize; break; } Color backColor = e.Item.BackColor ?? e.Bar.SelectedItemBackColor; if (!backColor.IsEmpty) { //LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds, PaintHelper.GetLightColor(backColor), backColor, 90.0f); var backBrush = new SolidBrush(backColor); e.Graphics.FillRectangle(backBrush, rect); } borderColor = e.Bar.BaseLineColor; } else { Color backColor = e.Item.BackColor ?? e.Bar.ItemBackColor; switch (e.Status) { case UIControlStatus.Hover: backColor = e.Bar.HoverItemBackColor; break; } if (!backColor.IsEmpty) { var backBrush = new SolidBrush(backColor); e.Graphics.FillRectangle(backBrush, e.Item.Bounds); borderColor = PaintHelper.AdjustColorS(PaintHelper.GetDarkColor(backColor, 0.15), 10, 20); } } if (!borderColor.IsEmpty) { DrawItemBorder(e, rect, borderColor); } }