protected override void OnPaint(PaintEventArgs e) { this.UpdateColors(); Bitmap B = new Bitmap(Width, Height); Graphics G = Graphics.FromImage(B); W = Width - 1; H = Height - 1; GraphicsPath GP = new GraphicsPath(); GraphicsPath GP2 = new GraphicsPath(); GraphicsPath GP3 = new GraphicsPath(); Rectangle Base = new Rectangle(8, 8, W - 16, H - 16); var _with7 = G; _with7.SmoothingMode = SmoothingMode.HighQuality; _with7.PixelOffsetMode = PixelOffsetMode.HighQuality; _with7.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; _with7.Clear(BackColor); //-- Base GP = Helpers.RoundRec(Base, 8); _with7.FillPath(new SolidBrush(_BaseColor), GP); //-- Arrows GP2 = Helpers.DrawArrow(28, 2, false); _with7.FillPath(new SolidBrush(_BaseColor), GP2); GP3 = Helpers.DrawArrow(28, 8, true); _with7.FillPath(new SolidBrush(Color.FromArgb(60, 70, 73)), GP3); //-- if ShowText if (ShowText) { _with7.DrawString(Text, Font, new SolidBrush(_TextColor), new Rectangle(16, 16, W, H), Helpers.NearSF); } base.OnPaint(e); G.Dispose(); e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.DrawImageUnscaled(B, 0, 0); B.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { this.UpdateColors(); Bitmap B = new Bitmap(Width, Height); Graphics G = Graphics.FromImage(B); W = Width - 1; H = Height - 1; Rectangle Base = new Rectangle(0, 24, W, H); GraphicsPath GP = new GraphicsPath(); GraphicsPath GP2 = new GraphicsPath(); GraphicsPath GP3 = new GraphicsPath(); var _with15 = G; _with15.SmoothingMode = SmoothingMode.HighQuality; _with15.PixelOffsetMode = PixelOffsetMode.HighQuality; _with15.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; _with15.Clear(BackColor); //-- Progress Value //int iValue = Convert.ToInt32(((float)_Value) / ((float)(_Maximum * Width))); float percent = ((float)_Value) / ((float)_Maximum); int iValue = (int)(percent * ((float)Width)); switch (Value) { case 0: //-- Base _with15.FillRectangle(new SolidBrush(_BaseColor), Base); //--Progress _with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1)); break; case 100: //-- Base _with15.FillRectangle(new SolidBrush(_BaseColor), Base); //--Progress _with15.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(0, 24, iValue - 1, H - 1)); break; default: //-- Base _with15.FillRectangle(new SolidBrush(_BaseColor), Base); //--Progress GP.AddRectangle(new Rectangle(0, 24, iValue - 1, H - 1)); _with15.FillPath(new SolidBrush(_ProgressColor), GP); if (_Pattern) { //-- Hatch Brush HatchBrush HB = new HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor); _with15.FillRectangle(HB, new Rectangle(0, 24, iValue - 1, H - 1)); } if (_ShowBalloon) { //-- Balloon Rectangle Balloon = new Rectangle(iValue - 18, 0, 34, 16); GP2 = Helpers.RoundRec(Balloon, 4); _with15.FillPath(new SolidBrush(_BaseColor), GP2); //-- Arrow GP3 = Helpers.DrawArrow(iValue - 9, 16, true); _with15.FillPath(new SolidBrush(_BaseColor), GP3); //-- Value > You can add "%" > value & "%" string text = (_PercentSign ? Value.ToString() + "%" : Value.ToString()); int wOffset = (_PercentSign ? iValue - 15 : iValue - 11); _with15.DrawString(text, new Font("Segoe UI", 10), new SolidBrush(_ProgressColor), new Rectangle(wOffset, -2, W, H), Helpers.NearSF); } break; } base.OnPaint(e); G.Dispose(); e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.DrawImageUnscaled(B, 0, 0); B.Dispose(); }