Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Import
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Text;
- using System.Windows.Forms;
- #endregion
- #region Copyright & Contact
- // Creator: Cheat Eye
- // CEO: Yassine Abbani
- // Link: https://www.facebook.com/yassineabbani
- // Version: 1.0.0
- #endregion
- #region CircularProgressBar
- public class BlueCircularProgressBar : Control
- {
- private float P = 10;
- #region Properties
- [Description("The current Value for the ProgressBar, in the range specified by minimum and maximum"), Category("Behavior")]
- public float Value
- {
- get { return P; }
- set
- {
- P = value;
- Invalidate();
- }
- }
- [Browsable(false)]
- public bool AllowDrop
- {
- get { return base.AllowDrop; }
- set { base.AllowDrop = value; }
- }
- [Browsable(false)]
- public ImeMode ImeMode
- {
- get { return base.ImeMode; }
- set { base.ImeMode = value; }
- }
- #endregion
- public BlueCircularProgressBar()
- {
- Font = new Font("Roboto", 10);
- DoubleBuffered = true;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- base.OnPaint(e);
- Width = 71;
- Height = 71;
- Rectangle rect = new Rectangle(5, 5, 60, 60);
- Graphics g = e.Graphics;
- float percentage;
- if (Value <= 100 && Value >= 0)
- {
- percentage = P;
- }
- else
- {
- percentage = 10;
- Value = 10;
- MessageBox.Show("Wrong value...!", "Blue Theme", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- dynamic progressAngle = Convert.ToSingle((percentage * 360) / 100);
- dynamic remainderAngle = 360 - progressAngle;
- using (Pen progressPen = new Pen(new SolidBrush(Color.FromArgb(110, 161, 252)), 3))
- {
- using (Pen remainderPen = new Pen(Color.FromArgb(91, 110, 144)))
- {
- g.SmoothingMode = SmoothingMode.AntiAlias;
- g.DrawArc(progressPen, rect, -90, progressAngle);
- g.DrawArc(remainderPen, rect, progressAngle - 90, remainderAngle);
- }
- }
- using (Font fnt = new Font("Roboto", 14))
- {
- string text = percentage.ToString() + "%";
- dynamic textSize = g.MeasureString(text, fnt);
- Point textPoint = new Point(Convert.ToInt32(rect.Left + (rect.Width / 2) - (textSize.Width / 2)), Convert.ToInt32(rect.Top + (rect.Height / 2) - (textSize.Height / 2)));
- g.TextRenderingHint = TextRenderingHint.AntiAlias;
- g.DrawString(text, fnt, new SolidBrush(Color.FromArgb(37, 150, 255)), textPoint);
- }
- }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement