Advertisement
Yassine_Abbani

Gradient [Label], [Costume Control]

May 22nd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.83 KB | None | 0 0
  1. #region Derectives
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Drawing;
  8. using System.Data;
  9. using System.Drawing.Drawing2D;
  10. using System.Windows.Forms;
  11.  
  12. #endregion
  13. #region Browse
  14. /* Copyright & Contact
  15. * --------------------------------------------------------------------------------<
  16. * Tool Name    : Label                                                           *
  17. * From Project : Creator Eye                                                      *
  18. * Project Lang : C#                                                               *
  19. * Creator      : Yassine Abbani                                                   *
  20. * Facebook     : https://www.facebook.com/YassineAbbani.user                      *
  21. * Pastebin     : https://pastebin.com/u/Yassine_Abbani                            *
  22. * Youtube      : https://www.youtube.com/channel/UCqvOCRs3HWbPH4yuZuTx8mw         *
  23. * Version      : 1.0 Beta                                                         *
  24. * Color        : Multi  Color                                                     *
  25. * Style        : Gradient                                                         *
  26. *>--------------------------------------------------------------------------------<
  27. */
  28. /* Features
  29. * ------------------------
  30. *   Custom Properties:
  31.  *   Add Gradient Top Color
  32.  *   Add Transparent Effect to Top Color  
  33.  *   Add Transparent Effect to bottom Color  
  34.  *   Add Gradient Angel
  35. */
  36. /*  history
  37. * ------------------------
  38. * 1.0 (23 Feb 2018):
  39.  *  This Costume Control Was Designed By Creator Eye UI for add that label to her library
  40.  *  Created by using Simple Commands
  41. *
  42. */
  43. #endregion
  44.  
  45.  
  46.  
  47. class CeGradientLabel : System.Windows.Forms.Label
  48. {
  49.     #region Variables
  50.     private Color colorA = Color.LightGreen;
  51.     private Color colorB = Color.DarkBlue;
  52.     private int colorATransparent = 0;
  53.     private int colorBTransparent = 0;
  54.     private int angle = 90;
  55.     private String text = "CreatorEye Label";
  56.     #endregion
  57.     #region Properties
  58.     public String DisplayText
  59.     {
  60.         get { return text; }
  61.         set { text = value; Invalidate(); }
  62.     }
  63.     public Color TopColor
  64.     {
  65.         get { return colorA; }
  66.         set { colorA = value; Invalidate(); }
  67.     }
  68.     public Color ButtomColor
  69.     {
  70.         get { return colorB; }
  71.         set { colorB = value; Invalidate(); }
  72.     }
  73.     public int TopColorTransparent
  74.     {
  75.         get { return colorATransparent; }
  76.         set
  77.         {
  78.             colorATransparent = value;
  79.             if (colorATransparent > 255)
  80.             {
  81.                 colorATransparent = 255;
  82.                 Invalidate();
  83.             }
  84.             else
  85.                 Invalidate();
  86.         }
  87.     }
  88.     public int ButtomColorTransparent
  89.     {
  90.         get { return colorBTransparent; }
  91.         set
  92.         {
  93.             colorBTransparent = value;
  94.             if (colorBTransparent > 255)
  95.             {
  96.                 colorBTransparent = 255;
  97.                 Invalidate();
  98.             }
  99.             else
  100.                 Invalidate();
  101.         }
  102.     }
  103.     public int GradientAngle
  104.     {
  105.         get { return angle; }
  106.         set { angle = value; Invalidate(); }
  107.     }
  108.     #endregion
  109.     #region Constructors
  110.     public CeGradientLabel()
  111.     {
  112.         this.ForeColor = Color.Transparent;
  113.     }
  114.     #endregion
  115.     #region Draw Control
  116.     protected override void OnPaint(PaintEventArgs e)
  117.     {
  118.         base.OnPaint(e);
  119.         this.Text = text;
  120.         Color c1 = Color.FromArgb(colorATransparent, colorA);
  121.         Color c2 = Color.FromArgb(colorBTransparent, colorB);
  122.         Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, 50, 50), c1, c2, angle);
  123.         e.Graphics.DrawString(this.Text, this.Font, b, new Point(0, 0));
  124.     }
  125.     #endregion
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement