Advertisement
Guest User

Pearl Theme by AeonHack, converted by Chuiby

a guest
Apr 25th, 2011
1,585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.38 KB | None | 0 0
  1. //Pearl Theme
  2. public class PTheme : Control
  3. {
  4.     private int _TitleHeight = 25;
  5.     public int TitleHeight
  6.     {
  7.         get
  8.         {
  9.             return _TitleHeight;
  10.         }
  11.         set
  12.         {
  13.             if (value > Height)
  14.             {
  15.                 value = Height;
  16.             }
  17.             if (value < 2)
  18.             {
  19.                 Height = 1;
  20.             }
  21.             _TitleHeight = value;
  22.             Invalidate();
  23.         }
  24.     }
  25.     private HorizontalAlignment _TitleAlign;
  26.     public HorizontalAlignment TitleAlign
  27.     {
  28.         get
  29.         {
  30.             return _TitleAlign;
  31.         }
  32.         set
  33.         {
  34.             _TitleAlign = value;
  35.             Invalidate();
  36.         }
  37.     }
  38.     protected override void OnHandleCreated(System.EventArgs e)
  39.     {
  40.         Dock = (DockStyle)5;
  41.         if (Parent is Form)
  42.         {
  43.             ((Form)Parent).FormBorderStyle = 0;
  44.         }
  45.         base.OnHandleCreated(e);
  46.     }
  47.     protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  48.     {
  49.         if (new Rectangle(Parent.Location.X, Parent.Location.Y, Width - 1, _TitleHeight - 1).IntersectsWith(new Rectangle(MousePosition.X, MousePosition.Y, 1, 1)))
  50.         {
  51.             Capture = false;
  52.             var M = Message.Create(Parent.Handle, 161, new IntPtr(2), new IntPtr(0));
  53.             DefWndProc(ref M);
  54.         }
  55.         base.OnMouseDown(e);
  56.     }
  57.     private Color C1 = Color.FromArgb(240, 240, 240);
  58.     private Color C2 = Color.FromArgb(230, 230, 230);
  59.     private Color C3 = Color.FromArgb(190, 190, 190);
  60.     protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
  61.     {
  62.     }
  63.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  64.     {
  65.         using (Bitmap B = new Bitmap(Width, Height))
  66.         {
  67.             using (var G = Graphics.FromImage(B))
  68.             {
  69.                 G.Clear(Color.FromArgb(245, 245, 245));
  70.  
  71.                 Draw.Blend(G, Color.White, C2, C1, 0.7F, 1, 0, 0, Width, _TitleHeight);
  72.  
  73.                 G.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, System.Convert.ToInt32(_TitleHeight / 2.0));
  74.                 G.DrawRectangle(new Pen(Color.FromArgb(100, 255, 255, 255)), 1, 1, Width - 3, _TitleHeight - 2);
  75.  
  76.                 var S = G.MeasureString(Text, Font);
  77.                 var O = 6;
  78.                 if ((int)_TitleAlign == 2)
  79.                 {
  80.                     O = Width / 2 - (int)S.Width / 2;
  81.                 }
  82.                 if ((int)_TitleAlign == 1)
  83.                 {
  84.                     O = Width - (int)S.Width - 6;
  85.                 }
  86.                 G.DrawString(Text, Font, new SolidBrush(C3), O, System.Convert.ToInt32(_TitleHeight / 2.0 - S.Height / 2.0));
  87.  
  88.                 G.DrawLine(new Pen(C3), 0, _TitleHeight, Width, _TitleHeight);
  89.                 G.DrawLine(Pens.White, 0, _TitleHeight + 1, Width, _TitleHeight + 1);
  90.                 G.DrawRectangle(new Pen(C3), 0, 0, Width - 1, Height - 1);
  91.                 e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  92.             }
  93.         }
  94.     }
  95. }
  96. public class PButton : Control
  97. {
  98.     public PButton()
  99.     {
  100.         ForeColor = C3;
  101.     }
  102.     private int State;
  103.     protected override void OnMouseEnter(System.EventArgs e)
  104.     {
  105.         State = 1;
  106.         Invalidate();
  107.         base.OnMouseEnter(e);
  108.     }
  109.     protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  110.     {
  111.         State = 2;
  112.         Invalidate();
  113.         base.OnMouseDown(e);
  114.     }
  115.     protected override void OnMouseLeave(System.EventArgs e)
  116.     {
  117.         State = 0;
  118.         Invalidate();
  119.         base.OnMouseLeave(e);
  120.     }
  121.     protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
  122.     {
  123.         State = 1;
  124.         Invalidate();
  125.         base.OnMouseUp(e);
  126.     }
  127.     private Color C1 = Color.FromArgb(240, 240, 240);
  128.     private Color C2 = Color.FromArgb(230, 230, 230);
  129.     private Color C3 = Color.FromArgb(190, 190, 190);
  130.     protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
  131.     {
  132.     }
  133.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  134.     {
  135.         using (Bitmap B = new Bitmap(Width, Height))
  136.         {
  137.             using (var G = Graphics.FromImage(B))
  138.             {
  139.                 if (State == 2)
  140.                 {
  141.                     Draw.Gradient(G, C2, Color.WhiteSmoke, 1, 1, Width, Height);
  142.                 }
  143.                 else
  144.                 {
  145.                     Draw.Gradient(G, Color.WhiteSmoke, C2, 1, 1, Width, Height);
  146.                 }
  147.  
  148.                 if (State < 2)
  149.                 {
  150.                     G.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, System.Convert.ToInt32(Height * 0.3));
  151.                 }
  152.  
  153.                 var S = G.MeasureString(Text, Font);
  154.                 G.DrawString(Text, Font, new SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2);
  155.                 G.DrawRectangle(new Pen(C3), 0, 0, Width - 1, Height - 1);
  156.  
  157.                 e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
  158.             }
  159.         }
  160.     }
  161. }
  162. public class PProgress : Control
  163. {
  164.     private int _Value;
  165.     public int Value
  166.     {
  167.         get
  168.         {
  169.             return _Value;
  170.         }
  171.         set
  172.         {
  173.             _Value = value;
  174.             Invalidate();
  175.         }
  176.     }
  177.     private int _Maximum = 100;
  178.     public int Maximum
  179.     {
  180.         get
  181.         {
  182.             return _Maximum;
  183.         }
  184.         set
  185.         {
  186.             if (value == 0)
  187.             {
  188.                 value = 1;
  189.             }
  190.             _Maximum = value;
  191.             Invalidate();
  192.         }
  193.     }
  194.     private Color C1 = Color.FromArgb(240, 240, 240);
  195.     private Color C2 = Color.FromArgb(230, 230, 230);
  196.     private Color C3 = Color.FromArgb(190, 190, 190);
  197.     protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
  198.     {
  199.     }
  200.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  201.     {
  202.         int V = Width * _Value / _Maximum;
  203.         using (Bitmap B = new Bitmap(Width, Height))
  204.         {
  205.             using (var G = Graphics.FromImage(B))
  206.             {
  207.                 Draw.Gradient(G, C2, C1, 1, 1, Width - 2, Height - 2);
  208.                 G.DrawRectangle(new Pen(C2), 1, 1, V - 3, Height - 3);
  209.                 Draw.Gradient(G, C1, C2, 2, 2, V - 4, Height - 4);
  210.  
  211.                 G.FillRectangle(new SolidBrush(Color.FromArgb(50, 255, 255, 255)), 2, 2, V - 4, System.Convert.ToInt32(Height / 2) - 2);
  212.                 G.DrawRectangle(new Pen(C3), 0, 0, Width - 1, Height - 1);
  213.  
  214.                 e.Graphics.DrawImage((Image)B.Clone(), (float)0, (float)0);
  215.             }
  216.         }
  217.     }
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement