Yassine_Abbani

Notification Number [Massanger] [Costume Control]

May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.72 KB | None | 0 0
  1. #region Directives
  2. using System;
  3. using System.Drawing;
  4. using System.Drawing.Drawing2D;
  5. using System.Windows.Forms;
  6. #endregion
  7. #region Browse
  8. #region Browse
  9. /* Copyright & Contact
  10. * --------------------------------------------------------------------------------<
  11. * Tool Name    : Notification Number                                              *
  12. * From Project : Creator Eye                                                      *
  13. * Creator      : Yassine Abbani                                                   *
  14. * Facebook     : https://www.facebook.com/YassineAbbani.user                      *
  15. * Pastebin     : https://pastebin.com/u/Yassine_Abbani                            *
  16. * Youtube      : https://www.youtube.com/channel/UCqvOCRs3HWbPH4yuZuTx8mw         *
  17. * Version      : 1.3 Beta                                                         *
  18. * Color        : MultiColor + Gradient                                            *
  19. * Style        : Dark                                                             *
  20. *>--------------------------------------------------------------------------------<
  21. */
  22. /* Features
  23. * ------------------------
  24.  * Value > Set The number of Notification you got at your application control
  25.  * Maximum Value > The Maximum number are 99+
  26. */
  27. /*  history
  28. * ------------------------
  29. * 1.1 (18 Jan 2018):
  30. * Add  value (number) properties
  31. * Add maximum value (number) properties
  32. */
  33. #endregion
  34. #endregion
  35. #region Notification Number
  36. class Ce_NotificationNumber : Control
  37. {
  38.     #region Variables
  39.  
  40.     private int _Value = 0;
  41.     private int _Maximum = 99;
  42.  
  43.     #endregion
  44.     #region Properties
  45.  
  46.     public int Value
  47.     {
  48.         get
  49.         {
  50.             if (this._Value == 0)
  51.             {
  52.                 return 0;
  53.             }
  54.             return this._Value;
  55.         }
  56.         set
  57.         {
  58.             if (value > this._Maximum)
  59.             {
  60.                 value = this._Maximum;
  61.             }
  62.             this._Value = value;
  63.             this.Invalidate();
  64.         }
  65.     }
  66.  
  67.     public int Maximum
  68.     {
  69.         get
  70.         {
  71.             return this._Maximum;
  72.         }
  73.         set
  74.         {
  75.             if (value < this._Value)
  76.             {
  77.                 this._Value = value;
  78.             }
  79.             this._Maximum = value;
  80.             this.Invalidate();
  81.         }
  82.     }
  83.  
  84.  
  85.  
  86.     #endregion
  87.  
  88.     public Ce_NotificationNumber()
  89.     {
  90.         SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  91.         SetStyle(ControlStyles.UserPaint, true);
  92.  
  93.         Text = null;
  94.         DoubleBuffered = true;
  95.     }
  96.  
  97.     protected override void OnResize(EventArgs e)
  98.     {
  99.         base.OnResize(e);
  100.         Height = 20;
  101.         Width = 20;
  102.     }
  103.  
  104.     protected override void OnPaint(PaintEventArgs e)
  105.     {
  106.         base.OnPaint(e);
  107.         var _G = e.Graphics;
  108.         string myString = _Value.ToString();
  109.         _G.Clear(BackColor);
  110.         _G.SmoothingMode = SmoothingMode.AntiAlias;
  111.         LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(18, 20)), Color.FromArgb(197, 69, 68), Color.FromArgb(176, 52, 52), 90f);
  112.  
  113.         // Fills the body with LGB gradient
  114.         _G.FillEllipse(LGB, new Rectangle(new Point(0, 0), new Size(18, 18)));
  115.         // Draw border
  116.         _G.DrawEllipse(new Pen(Color.FromArgb(205, 70, 66)), new Rectangle(new Point(0, 0), new Size(18, 18)));
  117.         _G.DrawString(myString, new Font("Segoe UI", 8, FontStyle.Bold), new SolidBrush(Color.FromArgb(255, 255, 253)), new Rectangle(0, 0, Width - 2, Height), new StringFormat
  118.         {
  119.             Alignment = StringAlignment.Center,
  120.             LineAlignment = StringAlignment.Center
  121.         });
  122.         e.Dispose();
  123.     }
  124.  
  125. }
  126. #endregion
Add Comment
Please, Sign In to add comment