/// <summary> /// Paint the background /// </summary> /// <param name="pevent"></param> protected override void OnPaintBackground(PaintEventArgs pevent) { AreaPainter.PaintRectangle(pevent.Graphics, 0, 0, Width, Height, m_Style.FillStyle, m_Style.BackColor, m_Style.FadeColor, m_Style.BorderStyle, m_Style.BorderColor); if (m_Style.BorderStyle == BorderStyle.Raised) { ControlPaint.DrawBorder3D(pevent.Graphics, 0, 0, Width, Height, Border3DStyle.Raised); } else if (m_Style.BorderStyle == BorderStyle.Sunken) { ControlPaint.DrawBorder3D(pevent.Graphics, 0, 0, Width, Height, Border3DStyle.Sunken); } if (m_HighlightRect == Rectangle.Empty) { return; } // determine the rectangle area type if (m_HighlightRectType == HighlightRectType.Left) { AreaPainter.PaintRectangle(pevent.Graphics, m_HighlightRect.Left, 0, m_HighlightRect.Width - 13, Height, m_Style.FillStyleSelection, m_Style.SelectionColor, Color.White, BorderStyle.None, Color.White); AreaPainter.PaintRectangle(pevent.Graphics, m_HighlightRect.Right - 13, 0, 13, Height, m_Style.FillStyleSelection, Color.LightGray, Color.White, BorderStyle.None, Color.White); // paint the border Pen pen = new Pen(ColorManager.ModifyBrightness(m_Style.SelectionColor, 0.8f)); pevent.Graphics.DrawLine(pen, m_HighlightRect.Left, 0, m_HighlightRect.Right - 13, 0); pevent.Graphics.DrawLine(pen, m_HighlightRect.Left, 0, m_HighlightRect.Left, Height); pevent.Graphics.DrawLine(pen, m_HighlightRect.Left, Height - 1, m_HighlightRect.Right - 13, Height - 1); pen.Color = ColorManager.ModifyBrightness(Color.LightGray, 0.8f); pevent.Graphics.DrawLine(pen, m_HighlightRect.Right, 0, m_HighlightRect.Right - 13, 0); pevent.Graphics.DrawLine(pen, m_HighlightRect.Right, 0, m_HighlightRect.Right, Height); pevent.Graphics.DrawLine(pen, m_HighlightRect.Right, Height - 1, m_HighlightRect.Right - 13, Height - 1); pen.Dispose(); } else if (m_HighlightRectType == HighlightRectType.Right) { AreaPainter.PaintRectangle(pevent.Graphics, m_HighlightRect.Left, 0, m_HighlightRect.Width - 13, Height, m_Style.FillStyleSelection, Color.LightGray, Color.White, BorderStyle.None, Color.White); AreaPainter.PaintRectangle(pevent.Graphics, m_HighlightRect.Right - 13, 0, 13, Height, m_Style.FillStyleSelection, m_Style.SelectionColor, Color.White, BorderStyle.None, Color.White); // paint the border Pen pen = new Pen(ColorManager.ModifyBrightness(Color.LightGray, 0.8f)); pevent.Graphics.DrawLine(pen, m_HighlightRect.Left, 0, m_HighlightRect.Right - 13, 0); pevent.Graphics.DrawLine(pen, m_HighlightRect.Left, 0, m_HighlightRect.Left, Height); pevent.Graphics.DrawLine(pen, m_HighlightRect.Left, Height - 1, m_HighlightRect.Right - 13, Height - 1); pen.Color = ColorManager.ModifyBrightness(m_Style.SelectionColor, 0.8f); pevent.Graphics.DrawLine(pen, m_HighlightRect.Right, 0, m_HighlightRect.Right - 13, 0); pevent.Graphics.DrawLine(pen, m_HighlightRect.Right, 0, m_HighlightRect.Right, Height); pevent.Graphics.DrawLine(pen, m_HighlightRect.Right, Height - 1, m_HighlightRect.Right - 13, Height - 1); pen.Dispose(); } else { AreaPainter.PaintRectangle(pevent.Graphics, m_HighlightRect.Left, 0, m_HighlightRect.Width, Height, m_Style.FillStyleSelection, m_Style.SelectionColor, Color.White, BorderStyle.Solid, ColorManager.ModifyBrightness(m_Style.SelectionColor, 0.8f)); } }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="fillStyle"></param> /// <param name="backColor"></param> /// <param name="fadeColor"></param> /// <param name="borderStyle"></param> /// <param name="borderColor"></param> /// <param name="graphics"></param> private static void OnPaintBackgroundClassic(int x, int y, int width, int height, FillStyle fillStyle, Color backColor, Color fadeColor, BorderStyle borderStyle, Color borderColor, Graphics graphics) { if (height == 0) { height = 4; } if (width == 0) { width = 4; } if (fillStyle == FillStyle.VistaFading) { Brush brush1 = null, brush2 = null, brush3 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); brush3 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 2), Color.FromArgb(50, ColorManager.ModifyBrightness(backColor, 0.15)), Color.FromArgb(10, ColorManager.ModifyBrightness(backColor, 1.4)), LinearGradientMode.Vertical); Blend bl = new Blend(); bl.Factors = new float[] { 0f, 0.0f, 0.05f, 1.0f }; bl.Positions = new float[] { 0, 0.5f, 0.55f, 1.0f }; ((LinearGradientBrush)brush3).Blend = bl; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f) + 1); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 2); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush3, x + 1, y + (int)((float)height / 2.0f) - 1, width - 3, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); brush3.Dispose(); } else if (fillStyle == FillStyle.VerticalCentreFading) { Brush brush1 = null, brush2 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f)); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); } else { Brush brush = null; if (fillStyle == FillStyle.DiagonalBackward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.BackwardDiagonal); } else if (fillStyle == FillStyle.DiagonalForward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.ForwardDiagonal); } else if (fillStyle == FillStyle.Flat) { brush = new SolidBrush(backColor); } else if (fillStyle == FillStyle.HorizontalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.Horizontal); } else if (fillStyle == FillStyle.VerticalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), fadeColor, backColor, LinearGradientMode.Vertical); //brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), // backColor, fadeColor, LinearGradientMode.Vertical); } graphics.FillRectangle(brush, x, y, width, height); brush.Dispose(); } // now render the other part a bit if (borderStyle == BorderStyle.Dot) { Pen pen = new Pen(borderColor); pen.DashStyle = DashStyle.Dot; graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } else if (borderStyle == BorderStyle.Solid) { Pen pen = new Pen(borderColor); graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } }