public override bool DrawNeedleCover(Graphics Gr, RectangleF rc) { if (this.AnalogMeter == null) { return(false); } Color clr = this.AnalogMeter.NeedleColor; RectangleF _rc = rc; float drawRatio = this.AnalogMeter.GetDrawRatio(); Color clr1 = Color.FromArgb(70, clr); _rc.Inflate(5 * drawRatio, 5 * drawRatio); SolidBrush brTransp = new SolidBrush(clr1); Gr.FillEllipse(brTransp, _rc); clr1 = clr; Color clr2 = LBColorManager.StepColor(clr, 75); LinearGradientBrush br1 = new LinearGradientBrush(rc, clr1, clr2, 45); Gr.FillEllipse(br1, rc); return(true); }
public override bool DrawBody(Graphics Gr, RectangleF rc) { if (this.AnalogMeter == null) { return(false); } Color bodyColor = this.AnalogMeter.BodyColor; Color cDark = LBColorManager.StepColor(bodyColor, 20); LinearGradientBrush br1 = new LinearGradientBrush(rc, bodyColor, cDark, 45); Gr.FillEllipse(br1, rc); float drawRatio = this.AnalogMeter.GetDrawRatio(); RectangleF _rc = rc; _rc.X += 3 * drawRatio; _rc.Y += 3 * drawRatio; _rc.Width -= 6 * drawRatio; _rc.Height -= 6 * drawRatio; LinearGradientBrush br2 = new LinearGradientBrush(_rc, cDark, bodyColor, 45); Gr.FillEllipse(br2, _rc); return(true); }
public static Color StepColor(Color clr, int alpha) { if (alpha == 100) { return(clr); } byte a = clr.A; byte r = clr.R; byte g = clr.G; byte b = clr.B; float bg = 0; int _alpha = Math.Min(alpha, 200); _alpha = Math.Max(alpha, 0); double ialpha = ((double)(_alpha - 100.0)) / 100.0; if (ialpha > 100) { // blend with white bg = 255.0F; ialpha = 1.0F - ialpha; // 0 = transparent fg; 1 = opaque fg } else { // blend with black bg = 0.0F; ialpha = 1.0F + ialpha; // 0 = transparent fg; 1 = opaque fg } r = (byte)(LBColorManager.BlendColour(r, bg, ialpha)); g = (byte)(LBColorManager.BlendColour(g, bg, ialpha)); b = (byte)(LBColorManager.BlendColour(b, bg, ialpha)); return(Color.FromArgb(a, r, g, b)); }