protected override void OnPaint(PaintEventArgs e) { G = e.Graphics; G.Clear(bodyColor.Color); G.SmoothingMode = SmoothingMode.HighQuality; float percent = ((float)Width / 100) * Value; LinearGradientBrush linGrBrush = GraphicsHelper.CreateGradient(Width, Height, upColor); G.FillPath(fillColor, RoundedRectangle.Create(0, 0, Width - 1, Height - 1, 4)); if ((int)percent <= 0) { G.FillPath(fillColor, RoundedRectangle.Create(0, 1, (int)percent, Height - 2, 4)); } else { G.FillPath(linGrBrush, RoundedRectangle.Create(0, 1, (int)percent, Height - 2, 4)); } G.DrawPath(new Pen(Color.LightGray), RoundedRectangle.Create(0, 0, Width - 1, Height - 1, 4)); var myColor = Value > 50 ? textColor.Color : Color.FromArgb(textColor.Color.ToArgb() ^ 0xffffff); if (ShowPercentage) { G.DrawString(string.Format("{0}%", Value), textFont, new SolidBrush(myColor), new Point((Width + 2) / 2, (Height + 2) / 2), stringformat); } }
protected override void OnPaint(PaintEventArgs e) { G = e.Graphics; switch (CheckStyle) { case CheckStyleType.Square: G.DrawRectangle(borderColor, new Rectangle(0, 0, 12, 12)); G.DrawString(Text, textFont, textColor, 14, 0); if (Checked) { G.FillRectangle(GraphicsHelper.CreateGradient(2, 9, upColor), new Rectangle(2, 2, 9, 9)); } break; case CheckStyleType.Round: G.DrawEllipse(borderColor, new Rectangle(0, 0, 13, 13)); G.DrawString(Text, textFont, textColor, 14, 0); if (Checked) { G.FillEllipse(GraphicsHelper.CreateGradient(2, 9, upColor), new Rectangle(2, 2, 9, 9)); } break; case CheckStyleType.Checkmark: G.DrawRectangle(borderColor, new Rectangle(0, 0, 12, 12)); G.DrawString(Text, textFont, textColor, 14, 0); if (Checked) { G.DrawString("\u221A", new Font("serif", 6, FontStyle.Bold), upColor, 3, 3); //G.DrawLine(new Pen(downColor.Color, 2), 3, 5, 7, 9); //G.DrawLine(new Pen(downColor.Color, 2), 6, 9, 9, 3); } break; default: break; } }
protected override void OnPaint(PaintEventArgs e) { G = e.Graphics; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.HighQuality; SolidBrush currentBrush; if (isMouseDown) { currentBrush = downColor; } else { currentBrush = fillColor; } LinearGradientBrush linGrBrush = GraphicsHelper.CreateGradient(Width, Height, currentBrush); G.DrawPath(new Pen(currentBrush), RoundedRectangle.Create(0, 0, Width, Height, 4)); G.FillPath(linGrBrush, RoundedRectangle.Create(0, 0, Width, Height, 4)); G.DrawString(Text, textFont, textColor, new Point(Width / 2, Height / 2), stringformat); }