Advertisement
Yassine_Abbani

Gradient [Panel], [Costume Control]

May 14th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.00 KB | None | 0 0
  1. #region Copyright & Contact
  2. // Creator : Yassine Abbani
  3. // Pastebin : https://pastebin.com/u/Yassine_Abbani
  4. // Facebook:  https://wwww.facebook.com/yassineabbani.user
  5. #endregion
  6. #region Import
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using System.Drawing;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. #endregion
  14. #region Gradient Panel
  15. public class Ce_Gradient_Panel : System.Windows.Forms.Panel
  16.     {
  17.  
  18.         #region Installing
  19.         #region Add Panel Information
  20.         private Color color1 = Color.SteelBlue;
  21.         private Color color2 = Color.DarkBlue;
  22.         private int color1Transparent = 150;
  23.         private int color2Transparent = 150;
  24.         private int angle = 90;
  25.         #endregion
  26.         #region Draw
  27.  
  28.         protected override void OnPaint(PaintEventArgs e)
  29.         {
  30.             base.OnPaint(e);
  31.             Color c1 = Color.FromArgb(color1Transparent, color1);
  32.             Color c2 = Color.FromArgb(color2Transparent, color2);
  33.             Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, c1, c2, angle);
  34.             //fill rectangle with panel size  
  35.             e.Graphics.FillRectangle(b, ClientRectangle);
  36.             b.Dispose();
  37.         }
  38.         #endregion
  39.         #region Ce_Gradient_Panel Return
  40.         public Ce_Gradient_Panel()
  41.         {
  42.         }
  43.         #endregion
  44.         #endregion
  45.         #region Properties
  46.         //Create   Properties
  47.  
  48.         #region  Top Color
  49.         public Color GradientTopColor       {
  50.             get { return color1; }
  51.             set { color1 = value; Invalidate(); }
  52.         }
  53.         #endregion
  54.         #region Transparent On Top
  55.         public int GradientTopTransparent
  56.         {
  57.             get { return color1Transparent; }
  58.             set
  59.             {
  60.                 color1Transparent = value;
  61.                 if (color1Transparent > 255)
  62.                 {
  63.                     color1Transparent = 255;
  64.                     Invalidate();
  65.                 }
  66.                 else
  67.                     Invalidate();
  68.             }
  69.         }
  70.         #endregion
  71.  
  72.         #region Buttom Color
  73.         public Color GradientBottomColor
  74.         {
  75.             get { return color2; }
  76.             set { color2 = value; Invalidate(); }
  77.         }
  78.         #endregion
  79.         #region Transparent On Buttom
  80.         public int GradientBottomTransparent
  81.         {
  82.             get { return color2Transparent; }
  83.             set
  84.             {
  85.                 color2Transparent = value;
  86.                 if (color2Transparent > 255)
  87.                 {
  88.                     color2Transparent = 255;
  89.                     Invalidate();
  90.                 }
  91.                 else
  92.                     Invalidate();
  93.             }
  94.         }
  95.         #endregion
  96.  
  97.         #region Gradient Angle
  98.         public int GradientAngle
  99.         {
  100.             get { return angle; }
  101.             set { angle = value; Invalidate(); }
  102.         }
  103. #endregion
  104.         #endregion
  105.  
  106.     }
  107. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement