public static void RenderBackgroundInternal( Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode) { if (drawBorder) { rect.Width--; rect.Height--; } using (LinearGradientBrush brush = new LinearGradientBrush( rect, Color.Transparent, Color.Transparent, mode)) { Color[] colors = new Color[4]; colors[0] = GetColor(baseColor, 0, 35, 24, 9); colors[1] = GetColor(baseColor, 0, 13, 8, 3); colors[2] = baseColor; colors[3] = GetColor(baseColor, 0, 35, 24, 9); ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f }; blend.Colors = colors; brush.InterpolationColors = blend; if (style != RoundStyle.None) { using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { g.FillPath(brush, path); } if (drawGlass) { if (baseColor.A > 80) { Rectangle rectTop = rect; if (mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(rect.Width * basePosition); } using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath( rectTop, roundWidth, RoundStyle.Top, false)) { using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { g.FillPath(brushAlpha, pathTop); } } } RectangleF glassRect = rect; if (mode == LinearGradientMode.Vertical) { glassRect.Y = rect.Y + rect.Height * basePosition; glassRect.Height = (rect.Height - rect.Height * basePosition) * 2; } else { glassRect.X = rect.X + rect.Width * basePosition; glassRect.Width = (rect.Width - rect.Width * basePosition) * 2; } ControlPaintEx.DrawGlass(g, glassRect, 170, 0); } if (drawBorder) { using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (Pen pen = new Pen(borderColor)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (Pen pen = new Pen(innerBorderColor)) { g.DrawPath(pen, path); } } } } else { g.FillRectangle(brush, rect); if (drawGlass) { if (baseColor.A > 80) { Rectangle rectTop = rect; if (mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(rect.Width * basePosition); } using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { g.FillRectangle(brushAlpha, rectTop); } } RectangleF glassRect = rect; if (mode == LinearGradientMode.Vertical) { glassRect.Y = rect.Y + rect.Height * basePosition; glassRect.Height = (rect.Height - rect.Height * basePosition) * 2; } else { glassRect.X = rect.X + rect.Width * basePosition; glassRect.Width = (rect.Width - rect.Width * basePosition) * 2; } ControlPaintEx.DrawGlass(g, glassRect, 200, 0); } if (drawBorder) { using (Pen pen = new Pen(borderColor)) { g.DrawRectangle(pen, rect); } rect.Inflate(-1, -1); using (Pen pen = new Pen(innerBorderColor)) { g.DrawRectangle(pen, rect); } } } } }
public static void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode) { if (drawBorder) { rect.Width--; rect.Height--; } using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode)) { Color[] colorArray = new Color[] { GetColor(baseColor, 0, 0x23, 0x18, 9), GetColor(baseColor, 0, 13, 8, 3), baseColor, GetColor(baseColor, 0, 0x23, 0x18, 9) }; ColorBlend blend = new ColorBlend(); float[] numArray = new float[4]; numArray[1] = basePosition; numArray[2] = basePosition + 0.05f; numArray[3] = 1f; blend.Positions = numArray; blend.Colors = colorArray; brush.InterpolationColors = blend; if (style != RoundStyle.None) { using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { g.FillPath(brush, path); } if (drawGlass) { if (baseColor.A > 80) { Rectangle rectangle = rect; if (mode == LinearGradientMode.Vertical) { rectangle.Height = (int)(rectangle.Height * basePosition); } else { rectangle.Width = (int)(rect.Width * basePosition); } using (GraphicsPath path2 = GraphicsPathHelper.CreatePath(rectangle, roundWidth, RoundStyle.Top, false)) { using (SolidBrush brush2 = new SolidBrush(Color.FromArgb(0x80, 0xff, 0xff, 0xff))) { g.FillPath(brush2, path2); } } } RectangleF glassRect = rect; if (mode == LinearGradientMode.Vertical) { glassRect.Y = rect.Y + (rect.Height * basePosition); glassRect.Height = (rect.Height - (rect.Height * basePosition)) * 2f; } else { glassRect.X = rect.X + (rect.Width * basePosition); glassRect.Width = (rect.Width - (rect.Width * basePosition)) * 2f; } ControlPaintEx.DrawGlass(g, glassRect, 170, 0); } if (!drawBorder) { return; } using (GraphicsPath path3 = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (Pen pen = new Pen(borderColor)) { g.DrawPath(pen, path3); } } rect.Inflate(-1, -1); using (GraphicsPath path4 = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (Pen pen2 = new Pen(innerBorderColor)) { g.DrawPath(pen2, path4); } return; } } g.FillRectangle(brush, rect); if (drawGlass) { if (baseColor.A > 80) { Rectangle rectangle2 = rect; if (mode == LinearGradientMode.Vertical) { rectangle2.Height = (int)(rectangle2.Height * basePosition); } else { rectangle2.Width = (int)(rect.Width * basePosition); } using (SolidBrush brush3 = new SolidBrush(Color.FromArgb(0x80, 0xff, 0xff, 0xff))) { g.FillRectangle(brush3, rectangle2); } } RectangleF ef2 = rect; if (mode == LinearGradientMode.Vertical) { ef2.Y = rect.Y + (rect.Height * basePosition); ef2.Height = (rect.Height - (rect.Height * basePosition)) * 2f; } else { ef2.X = rect.X + (rect.Width * basePosition); ef2.Width = (rect.Width - (rect.Width * basePosition)) * 2f; } ControlPaintEx.DrawGlass(g, ef2, 200, 0); } if (drawBorder) { using (Pen pen3 = new Pen(borderColor)) { g.DrawRectangle(pen3, rect); } rect.Inflate(-1, -1); using (Pen pen4 = new Pen(innerBorderColor)) { g.DrawRectangle(pen4, rect); } } } }