/// <summary> /// Draws the knob indicator. /// </summary> /// <param name="Gr">The gr.</param> /// <param name="rc">The rc.</param> /// <param name="pos">The position.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public virtual bool DrawKnobIndicator(Graphics Gr, RectangleF rc, PointF pos) { if (this.Knob == null) { return(false); } RectangleF _rc = rc; _rc.X = pos.X - 4; _rc.Y = pos.Y - 4; _rc.Width = 8; _rc.Height = 8; Color cKnob = this.Knob.IndicatorColor; Color cKnobDark = ZeroitLBColorManager.StepColor(cKnob, 60); LinearGradientBrush br = new LinearGradientBrush(_rc, cKnobDark, cKnob, 45); Gr.FillEllipse(br, _rc); br.Dispose(); return(true); }
/// <summary> /// Draws the needle cover. /// </summary> /// <param name="Gr">The gr.</param> /// <param name="rc">The rc.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public virtual bool DrawNeedleCover(Graphics Gr, RectangleF rc) { if (this.AnalogMeter == null) { return(false); } Color clr = this.AnalogMeter.NeedleColor; RectangleF _rc = rc; 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 = ZeroitLBColorManager.StepColor(clr, 75); LinearGradientBrush br1 = new LinearGradientBrush(rc, clr1, clr2, 45); Gr.FillEllipse(br1, rc); return(true); }
/// <summary> /// Draws the body. /// </summary> /// <param name="Gr">The gr.</param> /// <param name="rc">The rc.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public virtual bool DrawBody(Graphics Gr, RectangleF rc) { if (this.AnalogMeter == null) { return(false); } Color bodyColor = this.AnalogMeter.BodyColor; Color cDark = ZeroitLBColorManager.StepColor(bodyColor, 20); LinearGradientBrush br1 = new LinearGradientBrush(rc, bodyColor, cDark, 45); Gr.FillEllipse(br1, rc); 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); }
/// <summary> /// Draw the body of the control /// </summary> /// <param name="Gr">The gr.</param> /// <param name="rc">The rc.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public virtual bool DrawBody(Graphics Gr, RectangleF rc) { if (this.Button == null) { return(false); } Color bodyColor = this.Button.ButtonColor; Color cDark = ZeroitLBColorManager.StepColor(bodyColor, 20); LinearGradientBrush br1 = new LinearGradientBrush(rc, bodyColor, cDark, 45); if ((this.Button.Style == ZeroitLBButton.ButtonStyle.Circular) || (this.Button.Style == ZeroitLBButton.ButtonStyle.Elliptical)) { Gr.FillEllipse(br1, rc); } else { GraphicsPath path = this.RoundedRect(rc, 15F); Gr.FillPath(br1, path); path.Dispose(); } if (this.Button.State == ZeroitLBButton.ButtonState.Pressed) { RectangleF _rc = rc; _rc.Inflate(-15F * this.drawRatio, -15F * drawRatio); LinearGradientBrush br2 = new LinearGradientBrush(_rc, cDark, bodyColor, 45); if ((this.Button.Style == ZeroitLBButton.ButtonStyle.Circular) || (this.Button.Style == ZeroitLBButton.ButtonStyle.Elliptical)) { Gr.FillEllipse(br2, _rc); } else { GraphicsPath path = this.RoundedRect(_rc, 10F); Gr.FillPath(br2, path); path.Dispose(); } br2.Dispose(); } br1.Dispose(); return(true); }
/// <summary> /// Draw the knob of the control /// </summary> /// <param name="Gr">The gr.</param> /// <param name="rc">The rc.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public virtual bool DrawKnob(Graphics Gr, RectangleF rc) { if (this.Knob == null) { return(false); } Color cKnob = this.Knob.KnobColor; Color cKnobDark = ZeroitLBColorManager.StepColor(cKnob, 60); LinearGradientBrush br = new LinearGradientBrush(rc, cKnob, cKnobDark, 45); Gr.FillEllipse(br, rc); br.Dispose(); return(true); }
/// <summary> /// Draw the text of the control /// </summary> /// <param name="Gr">The gr.</param> /// <param name="rc">The rc.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public virtual bool DrawText(Graphics Gr, RectangleF rc) { if (this.Button == null) { return(false); } //Draw Strings Font font = new Font(this.Button.Font.FontFamily, this.Button.Font.Size * this.drawRatio, this.Button.Font.Style); String str = this.Button.Label; Color bodyColor = this.Button.ButtonColor; Color cDark = ZeroitLBColorManager.StepColor(bodyColor, 20); SizeF size = Gr.MeasureString(str, font); SolidBrush br1 = new SolidBrush(bodyColor); SolidBrush br2 = new SolidBrush(cDark); Gr.DrawString(str, font, br1, rc.Left + ((rc.Width * 0.5F) - (float)(size.Width * 0.5F)) + (float)(1 * this.drawRatio), rc.Top + ((rc.Height * 0.5F) - (float)(size.Height * 0.5)) + (float)(1 * this.drawRatio)); Gr.DrawString(str, font, br2, rc.Left + ((rc.Width * 0.5F) - (float)(size.Width * 0.5F)), rc.Top + ((rc.Height * 0.5F) - (float)(size.Height * 0.5))); br1.Dispose(); br2.Dispose(); font.Dispose(); return(false); }
/// <summary> /// Steps the color. /// </summary> /// <param name="clr">The color.</param> /// <param name="alpha">The alpha.</param> /// <returns>Color.</returns> 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)(ZeroitLBColorManager.BlendColour(r, bg, ialpha)); g = (byte)(ZeroitLBColorManager.BlendColour(g, bg, ialpha)); b = (byte)(ZeroitLBColorManager.BlendColour(b, bg, ialpha)); return(Color.FromArgb(a, r, g, b)); }
/// <summary> /// Draw the body of the control /// </summary> /// <param name="Gr">The gr.</param> /// <param name="rc">The rc.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public virtual bool DrawLed(Graphics Gr, RectangleF rc) { if (this.Led == null) { return(false); } Color cDarkOff = ZeroitLBColorManager.StepColor(Color.LightGray, 20); Color cDarkOn = ZeroitLBColorManager.StepColor(this.Led.LedColor, 60); LinearGradientBrush brOff = new LinearGradientBrush(rc, Color.Gray, cDarkOff, 45); LinearGradientBrush brOn = new LinearGradientBrush(rc, this.Led.LedColor, cDarkOn, 45); if (this.Led.State == ZeroitLBLed.LedState.Blink) { if (this.Led.BlinkIsOn == false) { if (this.Led.Style == ZeroitLBLed.LedStyle.Circular) { Gr.FillEllipse(brOff, rc); } else if (this.Led.Style == ZeroitLBLed.LedStyle.Rectangular) { Gr.FillRectangle(brOff, rc); } } else { if (this.Led.Style == ZeroitLBLed.LedStyle.Circular) { Gr.FillEllipse(brOn, rc); } else if (this.Led.Style == ZeroitLBLed.LedStyle.Rectangular) { Gr.FillRectangle(brOn, rc); } } } else { if (this.Led.State == ZeroitLBLed.LedState.Off) { if (this.Led.Style == ZeroitLBLed.LedStyle.Circular) { Gr.FillEllipse(brOff, rc); } else if (this.Led.Style == ZeroitLBLed.LedStyle.Rectangular) { Gr.FillRectangle(brOff, rc); } } else { if (this.Led.Style == ZeroitLBLed.LedStyle.Circular) { Gr.FillEllipse(brOn, rc); } else if (this.Led.Style == ZeroitLBLed.LedStyle.Rectangular) { Gr.FillRectangle(brOn, rc); } } } brOff.Dispose(); brOn.Dispose(); return(true); }