Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Derectives
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Text;
- using System.Windows.Forms;
- #endregion
- #region Browse
- /* Copyright & Contact
- * --------------------------------------------------------------------------------<
- * Tool Name : ProgressBar *
- * From Project : Creator Eye *
- * Project Lang : C# *
- * Creator : Yassine Abbani *
- * Facebook : https://www.facebook.com/YassineAbbani.user *
- * Pastebin : https://pastebin.com/u/Yassine_Abbani *
- * Youtube : https://www.youtube.com/channel/UCqvOCRs3HWbPH4yuZuTx8mw *
- * Version : 1.0 Beta *
- * Color : Blue, Dark Theme *
- * Style : Ring *
- *>--------------------------------------------------------------------------------<
- */
- /* Features
- * ------------------------
- * Custom Properties:
- * Create Circular Style.
- * add the range specified by minimum and maximum value.
- * Using Relative Value Style
- */
- /* history
- * ------------------------
- * 1.0 (20 Feb 2018):
- * In my Source Code Get Ring progress-bar Like Gmail Style with Great Effect.
- * So, in this case,you can use this controller as Circular Progress Bar with input Or edit value, and maximum value.
- *
- */
- #endregion
- #region
- public class Ce_CircularProgressBar : Control
- {
- private float P = 10;
- #region Properties
- [Description("The current percentage for the ProgressBar, in the range specified by minimum and maximum"), Category("Behavior")]
- public float Percentage
- {
- 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
- #region Constructors
- public Ce_CircularProgressBar()
- {
- Font = new Font("Roboto", 10);
- DoubleBuffered = true;
- }
- #endregion
- #region Draw Control
- 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 (Percentage <= 100 && Percentage >= 0)
- {
- percentage = P;
- }
- else
- {
- percentage = 10;
- Percentage = 10;
- MessageBox.Show("Wrong value...!", "Chek Creators Eye Website", 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.LightGray, 3))
- {
- 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(172, 172, 172)), textPoint);
- }
- }
- #endregion
- }
- #endregion
Add Comment
Please, Sign In to add comment