Advertisement
Yassine_Abbani

Blue [Progress Bar], [Costume Control]

May 14th, 2018 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. #region Import
  2. using System;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Drawing.Text;
  8. using System.Windows.Forms;
  9. #endregion
  10. #region Copyright & Contact
  11. // Creator: Cheat Eye
  12. // Version: 1.0.0
  13. #endregion
  14.  
  15. #region ProgressBar
  16. public class BlueProgressBar : Control
  17. {
  18.     #region variables
  19.  
  20.     private Rectangle BGShape;
  21.     private int _Value = 10;
  22.     private Pen P = new Pen(Color.FromArgb(20, 60, 71));
  23.  
  24.     #endregion
  25.     #region Properties
  26.     [Category("Behavior")]
  27.     public int Value
  28.     {
  29.         get { return _Value; }
  30.         set
  31.         {
  32.             _Value = value;
  33.             Invalidate();
  34.         }
  35.     }
  36.     #endregion
  37.  
  38.     public BlueProgressBar()
  39.     {
  40.         Width = 300;
  41.         Height = 13;
  42.  
  43.         Font = new Font("Roboto", 10);
  44.         DoubleBuffered = true;
  45.     }
  46.  
  47.     protected override void OnResize(EventArgs e)
  48.     {
  49.         base.OnResize(e);
  50.  
  51.         BGShape = new Rectangle(0, 0, Width - 1, Height - 1);
  52.         Invalidate();
  53.     }
  54.  
  55.     protected override void OnPaint(PaintEventArgs e)
  56.     {
  57.         base.OnPaint(e);
  58.         Graphics G = e.Graphics;
  59.  
  60.         HatchBrush Hatch = new HatchBrush(HatchStyle.WideUpwardDiagonal, Color.FromArgb(42, 137, 247), Color.FromArgb(42, 137, 247));
  61.  
  62.         if (_Value <= 100 && _Value >= 0)
  63.         {
  64.             G.DrawRectangle(P, BGShape);
  65.             G.FillRectangle(Hatch, 2, 2, (Width * _Value) / (100 - 0) - 4, Height - 4);
  66.         }
  67.         else
  68.         {
  69.             _Value = 10;
  70.             MessageBox.Show("Wrong value...!", "Blue Theme", MessageBoxButtons.OK, MessageBoxIcon.Information);
  71.  
  72.             G.DrawRectangle(P, BGShape);
  73.             G.FillRectangle(Hatch, 2, 2, (Width * _Value) / (100 - 0) - 4, Height - 4);
  74.         }
  75.     }
  76. }
  77. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement