Advertisement
Guest User

Visual Studio Theme by AeonHack, converted by Chuiby

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