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 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 = LBColorManager.StepColor(cKnob, 60); LinearGradientBrush br = new LinearGradientBrush(_rc, cKnobDark, cKnob, 45); Gr.FillEllipse(br, _rc); br.Dispose(); 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 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); }
/// <summary> /// Draw the body of the control /// </summary> /// <param name="Gr"></param> /// <param name="rc"></param> /// <returns></returns> public virtual bool DrawBody(Graphics Gr, RectangleF rc) { if (this.Button == null) { return(false); } Color bodyColor = this.Button.ButtonColor; //结束颜色。bodyColor基色,60渐变系数 Color cDark = LBColorManager.StepColor(bodyColor, 60); LinearGradientBrush br1 = new LinearGradientBrush(rc, bodyColor, cDark, 270); if ((this.Button.Style == LBButton.ButtonStyle.Circular) || (this.Button.Style == LBButton.ButtonStyle.Elliptical)) { Gr.FillEllipse(br1, rc); } else { GraphicsPath path = this.RoundedRect(rc, 15F); Gr.FillPath(br1, path); path.Dispose(); } if (this.Button.State == LBButton.ButtonState.Pressed) { RectangleF _rc = rc; _rc.Inflate(-15F * this.drawRatio, -15F * drawRatio); LinearGradientBrush br2 = new LinearGradientBrush(_rc, cDark, bodyColor, 270); if ((this.Button.Style == LBButton.ButtonStyle.Circular) || (this.Button.Style == LBButton.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 body of the control /// </summary> /// <param name="Gr"></param> /// <param name="rc"></param> /// <returns></returns> public virtual bool DrawLed(Graphics Gr, RectangleF rc) { if (this.Led == null) { return(false); } Color cDarkOff = LBColorManager.StepColor(this.Led.LedColor, 20); Color cDarkOn = LBColorManager.StepColor(this.Led.LedColor, 90); LinearGradientBrush brOff = new LinearGradientBrush(rc, this.Led.LedColor, cDarkOff, 45); LinearGradientBrush brOn = new LinearGradientBrush(rc, cDarkOn, this.Led.LedColor, 45); if (this.Led.State == LBLed.LedState.Blink) { if (this.Led.BlinkIsOn == false) { Gr.FillEllipse(brOff, rc); } else { Gr.FillEllipse(brOn, rc); } } else { if (this.Led.State == LBLed.LedState.Off) { Gr.FillEllipse(brOff, rc); } else { Gr.FillEllipse(brOn, rc); } } brOff.Dispose(); brOn.Dispose(); return(true); }
/// <summary> /// Draw the knob of the control /// </summary> /// <param name="Gr"></param> /// <param name="rc"></param> /// <returns></returns> public virtual bool DrawKnob(Graphics Gr, RectangleF rc) { if (this.Knob == null) { return(false); } Color cKnob = this.Knob.KnobColor; Color cKnobDark = LBColorManager.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"></param> /// <param name="rc"></param> /// <returns></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 = LBColorManager.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> /// Draw the body of the control /// </summary> /// <param name="Gr"></param> /// <param name="rc"></param> /// <returns></returns> public virtual bool DrawBody(Graphics Gr, RectangleF rc) { if (this.Button == null) { return(false); } Color bodyColor = this.Button.ButtonColor; Color cDark = LBColorManager.StepColor(bodyColor, 20); LinearGradientBrush br1 = new LinearGradientBrush(rc, bodyColor, cDark, 45); Gr.FillEllipse(br1, rc); br1.Dispose(); if (this.Button.State == LBButton.ButtonState.Pressed) { float drawRatio = this.Button.GetDrawRatio(); RectangleF _rc = rc; _rc.Inflate(-15F * drawRatio, -15F * drawRatio); LinearGradientBrush br2 = new LinearGradientBrush(_rc, cDark, bodyColor, 45); Gr.FillEllipse(br2, _rc); br2.Dispose(); } return(true); }