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); }
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); }