internal static void InternalDrawHighlightBorder(Graphics g, Color baseColor, RectangleF bounds, double highlightOpacity) { HSBColor.HSB hsl = HSBColor.RGBToHSB(baseColor); hsl.B += hsl.B * 0.5; Color color = HSBColor.HSBToRGB(hsl); using (Pen pen = new Pen(Color.FromArgb((int)(150.0 * highlightOpacity), color), 1f)) { g.DrawRectangle(pen, (float)(bounds.X + 1f), (float)(bounds.Y + 1f), (float)(bounds.Width - 3f), (float)(bounds.Height - 2f)); } HSBColor.HSB hsb2 = HSBColor.RGBToHSB(baseColor); hsb2.S -= hsb2.S * 0.5; Color color2 = HSBColor.HSBToRGB(hsb2); using (Pen pen2 = new Pen(Color.FromArgb((int)(255.0 * highlightOpacity), color2), 1f)) { g.DrawLine(pen2, bounds.X + 1f, bounds.Y, bounds.Right - 2f, bounds.Y); g.DrawLine(pen2, (float)(bounds.X + 1f), (float)(bounds.Bottom - 1f), (float)(bounds.Right - 2f), (float)(bounds.Bottom - 1f)); g.DrawLine(pen2, bounds.X, bounds.Y + 1f, bounds.X, bounds.Bottom - 2f); g.DrawLine(pen2, (float)(bounds.Right - 1f), (float)(bounds.Y + 1f), (float)(bounds.Right - 1f), (float)(bounds.Bottom - 2f)); } }
public static void DrawHighlight(Graphics g, Color baseColor, Color pushedBaseColor, RectangleF bounds, RenderMode renderMode, float opacity) { g.SmoothingMode = (renderMode == RenderMode.HighQuality) ? SmoothingMode.HighQuality : SmoothingMode.HighSpeed; using (Brush brush = new SolidBrush(Color.FromArgb((int)(opacity * baseColor.A), baseColor))) { g.FillRectangle(brush, bounds); } HSBColor.HSB hsl = HSBColor.RGBToHSB(baseColor); hsl.H += 0.027450980392156862; hsl.B += hsl.B * 0.40000000596046448; Color color = HSBColor.HSBToRGB(hsl); RectangleF rect = new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height * 0.39f); RectangleF ef2 = new RectangleF(bounds.X, bounds.Y - 1f, bounds.Width, (bounds.Height * 0.39f) + 1f); using (LinearGradientBrush brush2 = new LinearGradientBrush(ef2, Color.FromArgb((int)(color.A * opacity), color), Color.FromArgb((int)(127f * opacity), color), LinearGradientMode.Vertical)) { Blend blend = new Blend(3); blend.Positions[0] = 0f; blend.Positions[1] = 0.65f; blend.Positions[2] = 1f; blend.Factors[0] = 0f; blend.Factors[1] = 0.45f; blend.Factors[2] = 1f; brush2.Blend = blend; g.FillRectangle(brush2, rect); } hsl.H -= 0.047058823529411764; Color color2 = HSBColor.HSBToRGB(hsl); RectangleF ef3 = new RectangleF(bounds.X, rect.Bottom, bounds.Width, bounds.Height * 0.61f); RectangleF ef4 = new RectangleF(bounds.X, rect.Bottom - 1f, bounds.Width, (bounds.Height * 0.61f) + 2f); switch (renderMode) { case RenderMode.HighQuality: { using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ef4.X - 50f, ef4.Y, ef4.Width + 100f, ef4.Height * 2f); using (PathGradientBrush brush3 = new PathGradientBrush(path)) { brush3.CenterColor = Color.FromArgb((int)(215f * opacity), color2); brush3.SurroundColors = new Color[] { Color.Transparent }; g.FillRectangle(brush3, ef3); } return; } } case RenderMode.HighSpeed: using (LinearGradientBrush brush4 = new LinearGradientBrush(ef4, Color.Transparent, Color.FromArgb((int)(215f * opacity), color2), LinearGradientMode.Vertical)) { Blend blend2 = new Blend(3); blend2.Positions[0] = 0f; blend2.Positions[1] = 0.65f; blend2.Positions[2] = 1f; blend2.Factors[0] = 0f; blend2.Factors[1] = 0.5f; blend2.Factors[2] = 1f; brush4.Blend = blend2; g.FillRectangle(brush4, ef3); } return; default: return; } }
public static void DrawPushedHighlight(Graphics g, Color baseColor, Color highlightBaseColor, RectangleF bounds, RenderMode renderMode, float opacity) { g.SmoothingMode = (renderMode == RenderMode.HighQuality) ? SmoothingMode.HighQuality : SmoothingMode.HighSpeed; HSBColor.HSB hsl = HSBColor.RGBToHSB(baseColor); hsl.B -= hsl.B * (0.1f * opacity); baseColor = HSBColor.HSBToRGB(hsl); using (Brush brush = new SolidBrush(baseColor)) { g.FillRectangle(brush, bounds); } HSBColor.HSB hsb2 = HSBColor.RGBToHSB(baseColor); hsb2.H += 0.00784313725490196; hsb2.B += hsb2.B * 0.550000011920929; Color color = HSBColor.HSBToRGB(hsb2); RectangleF rect = new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height * 0.39f); RectangleF ef2 = new RectangleF(bounds.X, bounds.Y - 1f, bounds.Width, (bounds.Height * 0.39f) + 2f); using (LinearGradientBrush brush2 = new LinearGradientBrush(ef2, color, Color.FromArgb(80, color), LinearGradientMode.Vertical)) { Blend blend = new Blend(3); blend.Positions[0] = 0f; blend.Positions[1] = 0.45f; blend.Positions[2] = 1f; blend.Factors[0] = 0f; blend.Factors[1] = 0.55f; blend.Factors[2] = 1f; brush2.Blend = blend; g.FillRectangle(brush2, rect); } HSBColor.HSB hsb3 = HSBColor.RGBToHSB(highlightBaseColor); hsb3.B += hsb3.B * 0.30000001192092896; hsb3.H += 0.027777777777777776; Color color2 = HSBColor.HSBToRGB(hsb3); RectangleF ef3 = new RectangleF(bounds.X, rect.Bottom, bounds.Width, bounds.Height * 0.61f); RectangleF ef4 = new RectangleF(bounds.X, rect.Bottom - 1f, bounds.Width, (bounds.Height * 0.61f) + 1f); switch (renderMode) { case RenderMode.HighQuality: { using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ef4.X - 50f, ef4.Y, ef4.Width + 100f, ef4.Height * 2f); using (PathGradientBrush brush3 = new PathGradientBrush(path)) { ColorBlend blend2 = new ColorBlend(2); float[] numArray = new float[3]; numArray[1] = 0.2f; numArray[2] = 1f; blend2.Positions = numArray; blend2.Colors = new Color[] { Color.Transparent, Color.FromArgb((int)(50f * (1f - opacity)), color2), Color.FromArgb(160 + ((int)(80f * (1f - opacity))), color2) }; brush3.InterpolationColors = blend2; g.FillRectangle(brush3, ef3); } return; } } case RenderMode.HighSpeed: using (LinearGradientBrush brush4 = new LinearGradientBrush(ef4, Color.FromArgb((int)(30f * (1f - opacity)), color2), Color.FromArgb(160 + ((int)(80f * (1f - opacity))), color2), LinearGradientMode.Vertical)) { Blend blend3 = new Blend(3); blend3.Positions[0] = 0f; blend3.Positions[1] = 0.5f; blend3.Positions[2] = 1f; blend3.Factors[0] = 0f; blend3.Factors[1] = 0.5f; blend3.Factors[2] = 1f; brush4.Blend = blend3; g.FillRectangle(brush4, ef3); } return; default: return; } }