Want more features on Pastebin? Sign Up, it's FREE!
Guest

Aeonhack - Custom Themes

By: a guest on Apr 25th, 2010  |  syntax: VB.NET  |  size: 16.60 KB  |  views: 7,864  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Imports System.Drawing.Drawing2D
  2. 'Controls created by Aeonhack
  3. 'http://www.youtube.com/aeonhack
  4. Public Class Draw
  5.     Shared Sub Gradient(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  6.         Dim R As New Rectangle(x, y, width, height)
  7.         Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
  8.             g.FillRectangle(T, R)
  9.         End Using
  10.     End Sub
  11.     Shared Sub Blend(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal c3 As Color, ByVal c As Single, ByVal d As Integer, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  12.         Dim V As New ColorBlend(3)
  13.         V.Colors = New Color() {c1, c2, c3}
  14.         V.Positions = New Single() {0, c, 1}
  15.         Dim R As New Rectangle(x, y, width, height)
  16.         Using T As New LinearGradientBrush(R, c1, c1, CType(d, LinearGradientMode))
  17.             T.InterpolationColors = V : g.FillRectangle(T, R)
  18.         End Using
  19.     End Sub
  20. End Class
  21. 'Pearl Theme
  22. Public Class PTheme : Inherits Control
  23.     Private _TitleHeight As Integer = 25
  24.     Public Property TitleHeight() As Integer
  25.         Get
  26.             Return _TitleHeight
  27.         End Get
  28.         Set(ByVal v As Integer)
  29.             If v > Height Then v = Height
  30.             If v < 2 Then Height = 1
  31.             _TitleHeight = v : Invalidate()
  32.         End Set
  33.     End Property
  34.     Private _TitleAlign As HorizontalAlignment
  35.     Public Property TitleAlign() As HorizontalAlignment
  36.         Get
  37.             Return _TitleAlign
  38.         End Get
  39.         Set(ByVal v As HorizontalAlignment)
  40.             _TitleAlign = v : Invalidate()
  41.         End Set
  42.     End Property
  43.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  44.         Dock = 5
  45.         If TypeOf Parent Is Form Then CType(Parent, Form).FormBorderStyle = 0
  46.         MyBase.OnHandleCreated(e)
  47.     End Sub
  48.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  49.         If New Rectangle(Parent.Location.X, Parent.Location.Y, Width - 1, _TitleHeight - 1).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then
  50.             Capture = False : Dim M = Message.Create(Parent.Handle, 161, 2, 0) : DefWndProc(M)
  51.         End If : MyBase.OnMouseDown(e)
  52.     End Sub
  53.     Dim C1 As Color = Color.FromArgb(240, 240, 240), C2 As Color = Color.FromArgb(230, 230, 230), C3 As Color = Color.FromArgb(190, 190, 190)
  54.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  55.     End Sub
  56.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  57.         Using B As New Bitmap(Width, Height)
  58.             Using G = Graphics.FromImage(B)
  59.                 G.Clear(Color.FromArgb(245, 245, 245))
  60.  
  61.                 Draw.Blend(G, Color.White, C2, C1, 0.7, 1, 0, 0, Width, _TitleHeight)
  62.  
  63.                 G.FillRectangle(New SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, CInt(_TitleHeight / 2))
  64.                 G.DrawRectangle(New Pen(Color.FromArgb(100, 255, 255, 255)), 1, 1, Width - 3, _TitleHeight - 2)
  65.  
  66.                 Dim S = G.MeasureString(Text, Font), O = 6
  67.                 If _TitleAlign = 2 Then O = Width / 2 - S.Width / 2
  68.                 If _TitleAlign = 1 Then O = Width - S.Width - 6
  69.                 G.DrawString(Text, Font, New SolidBrush(C3), O, CInt(_TitleHeight / 2 - S.Height / 2))
  70.  
  71.                 G.DrawLine(New Pen(C3), 0, _TitleHeight, Width, _TitleHeight)
  72.                 G.DrawLine(Pens.White, 0, _TitleHeight + 1, Width, _TitleHeight + 1)
  73.                 G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
  74.  
  75.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  76.             End Using
  77.         End Using
  78.     End Sub
  79. End Class
  80. Public Class PButton : Inherits Control
  81.     Sub New()
  82.         ForeColor = C3
  83.     End Sub
  84.     Private State As Integer
  85.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  86.         State = 1 : Invalidate() : MyBase.OnMouseEnter(e)
  87.     End Sub
  88.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  89.         State = 2 : Invalidate() : MyBase.OnMouseDown(e)
  90.     End Sub
  91.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  92.         State = 0 : Invalidate() : MyBase.OnMouseLeave(e)
  93.     End Sub
  94.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  95.         State = 1 : Invalidate() : MyBase.OnMouseUp(e)
  96.     End Sub
  97.     Dim C1 As Color = Color.FromArgb(240, 240, 240), C2 As Color = Color.FromArgb(230, 230, 230), C3 As Color = Color.FromArgb(190, 190, 190)
  98.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  99.     End Sub
  100.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  101.         Using B As New Bitmap(Width, Height)
  102.             Using G = Graphics.FromImage(B)
  103.                 If State = 2 Then
  104.                     Draw.Gradient(G, C2, Color.WhiteSmoke, 1, 1, Width, Height)
  105.                 Else
  106.                     Draw.Gradient(G, Color.WhiteSmoke, C2, 1, 1, Width, Height)
  107.                 End If
  108.  
  109.                 If State < 2 Then G.FillRectangle(New SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, CInt(Height * 0.3))
  110.  
  111.                 Dim S = G.MeasureString(Text, Font)
  112.                 G.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)
  113.                 G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
  114.  
  115.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  116.             End Using
  117.         End Using
  118.     End Sub
  119. End Class
  120. Public Class PProgress : Inherits Control
  121.     Private _Value As Integer
  122.     Public Property Value() As Integer
  123.         Get
  124.             Return _Value
  125.         End Get
  126.         Set(ByVal value As Integer)
  127.             _Value = value : Invalidate()
  128.         End Set
  129.     End Property
  130.     Private _Maximum As Integer = 100
  131.     Public Property Maximum() As Integer
  132.         Get
  133.             Return _Maximum
  134.         End Get
  135.         Set(ByVal value As Integer)
  136.             If value = 0 Then value = 1
  137.             _Maximum = value : Invalidate()
  138.         End Set
  139.     End Property
  140.     Dim C1 As Color = Color.FromArgb(240, 240, 240), C2 As Color = Color.FromArgb(230, 230, 230), C3 As Color = Color.FromArgb(190, 190, 190)
  141.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  142.     End Sub
  143.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  144.         Dim V As Integer = Width * _Value / _Maximum
  145.         Using B As New Bitmap(Width, Height)
  146.             Using G = Graphics.FromImage(B)
  147.                 Draw.Gradient(G, C2, C1, 1, 1, Width - 2, Height - 2)
  148.                 G.DrawRectangle(New Pen(C2), 1, 1, V - 3, Height - 3)
  149.                 Draw.Gradient(G, C1, C2, 2, 2, V - 4, Height - 4)
  150.  
  151.                 G.FillRectangle(New SolidBrush(Color.FromArgb(50, 255, 255, 255)), 2, 2, V - 4, CInt(Height / 2) - 2)
  152.                 G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
  153.  
  154.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  155.             End Using
  156.         End Using
  157.     End Sub
  158. End Class
  159. 'Modern Theme
  160. Public Class MTheme : Inherits Control
  161.     Private _TitleHeight As Integer = 25
  162.     Public Property TitleHeight() As Integer
  163.         Get
  164.             Return _TitleHeight
  165.         End Get
  166.         Set(ByVal v As Integer)
  167.             If v > Height Then v = Height
  168.             If v < 2 Then Height = 1
  169.             _TitleHeight = v : Invalidate()
  170.         End Set
  171.     End Property
  172.     Private _TitleAlign As HorizontalAlignment = 2
  173.     Public Property TitleAlign() As HorizontalAlignment
  174.         Get
  175.             Return _TitleAlign
  176.         End Get
  177.         Set(ByVal v As HorizontalAlignment)
  178.             _TitleAlign = v : Invalidate()
  179.         End Set
  180.     End Property
  181.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  182.         Dock = 5
  183.         If TypeOf Parent Is Form Then CType(Parent, Form).FormBorderStyle = 0
  184.         MyBase.OnHandleCreated(e)
  185.     End Sub
  186.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  187.         If New Rectangle(Parent.Location.X, Parent.Location.Y, Width - 1, _TitleHeight - 1).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then
  188.             Capture = False : Dim M = Message.Create(Parent.Handle, 161, 2, 0) : DefWndProc(M)
  189.         End If : MyBase.OnMouseDown(e)
  190.     End Sub
  191.     Dim C1 As Color = Color.FromArgb(74, 74, 74), C2 As Color = Color.FromArgb(63, 63, 63), C3 As Color = Color.FromArgb(41, 41, 41), _
  192.     C4 As Color = Color.FromArgb(27, 27, 27), C5 As Color = Color.FromArgb(0, 0, 0, 0), C6 As Color = Color.FromArgb(25, 255, 255, 255)
  193.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  194.     End Sub
  195.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  196.         Using B As New Bitmap(Width, Height)
  197.             Using G = Graphics.FromImage(B)
  198.                 G.Clear(C3)
  199.  
  200.                 Draw.Gradient(G, C4, C3, 0, 0, Width, _TitleHeight)
  201.  
  202.                 Dim S = G.MeasureString(Text, Font), O = 6
  203.                 If _TitleAlign = 2 Then O = Width / 2 - S.Width / 2
  204.                 If _TitleAlign = 1 Then O = Width - S.Width - 6
  205.                 Dim R As New Rectangle(O, (_TitleHeight + 2) / 2 - S.Height / 2, S.Width, S.Height)
  206.                 Using T As New LinearGradientBrush(R, C1, C3, LinearGradientMode.Vertical)
  207.                     G.DrawString(Text, Font, T, R)
  208.                 End Using
  209.  
  210.                 G.DrawLine(New Pen(C3), 0, 1, Width, 1)
  211.  
  212.                 Draw.Blend(G, C5, C6, C5, 0.5, 0, 0, _TitleHeight + 1, Width, 1)
  213.  
  214.                 G.DrawLine(New Pen(C4), 0, _TitleHeight, Width, _TitleHeight)
  215.                 G.DrawRectangle(New Pen(C4), 0, 0, Width - 1, Height - 1)
  216.  
  217.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  218.             End Using
  219.         End Using
  220.     End Sub
  221. End Class
  222. Public Class MButton : Inherits Control
  223.     Sub New()
  224.         ForeColor = Color.FromArgb(65, 65, 65)
  225.     End Sub
  226.     Private State As Integer
  227.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  228.         State = 1 : Invalidate() : MyBase.OnMouseEnter(e)
  229.     End Sub
  230.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  231.         State = 2 : Invalidate() : MyBase.OnMouseDown(e)
  232.     End Sub
  233.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  234.         State = 0 : Invalidate() : MyBase.OnMouseLeave(e)
  235.     End Sub
  236.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  237.         State = 1 : Invalidate() : MyBase.OnMouseUp(e)
  238.     End Sub
  239.     Dim C1 As Color = Color.FromArgb(31, 31, 31), C2 As Color = Color.FromArgb(41, 41, 41), C3 As Color = Color.FromArgb(51, 51, 51), _
  240.     C4 As Color = Color.FromArgb(0, 0, 0, 0), C5 As Color = Color.FromArgb(25, 255, 255, 255)
  241.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  242.     End Sub
  243.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  244.         Using B As New Bitmap(Width, Height)
  245.             Using G = Graphics.FromImage(B)
  246.                 G.DrawRectangle(New Pen(C1), 0, 0, Width - 1, Height - 1)
  247.  
  248.                 If State = 2 Then
  249.                     Draw.Gradient(G, C2, C3, 1, 1, Width - 2, Height - 2)
  250.                 Else
  251.                     Draw.Gradient(G, C3, C2, 1, 1, Width - 2, Height - 2)
  252.                 End If
  253.  
  254.                 Dim O = G.MeasureString(Text, Font)
  255.                 G.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - O.Width / 2, Height / 2 - O.Height / 2)
  256.  
  257.                 Draw.Blend(G, C4, C5, C4, 0.5, 0, 1, 1, Width - 2, 1)
  258.  
  259.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  260.             End Using
  261.         End Using
  262.     End Sub
  263. End Class
  264. Public Class MProgress : Inherits Control
  265.     Private _Value As Integer
  266.     Public Property Value() As Integer
  267.         Get
  268.             Return _Value
  269.         End Get
  270.         Set(ByVal value As Integer)
  271.             _Value = value : Invalidate()
  272.         End Set
  273.     End Property
  274.     Private _Maximum As Integer = 100
  275.     Public Property Maximum() As Integer
  276.         Get
  277.             Return _Maximum
  278.         End Get
  279.         Set(ByVal value As Integer)
  280.             If value = 0 Then value = 1
  281.             _Maximum = value : Invalidate()
  282.         End Set
  283.     End Property
  284.     Dim C1 As Color = Color.FromArgb(31, 31, 31), C2 As Color = Color.FromArgb(41, 41, 41), C3 As Color = Color.FromArgb(51, 51, 51), _
  285.     C4 As Color = Color.FromArgb(0, 0, 0, 0), C5 As Color = Color.FromArgb(25, 255, 255, 255)
  286.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  287.     End Sub
  288.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  289.         Dim V As Integer = Width * _Value / _Maximum
  290.         Using B As New Bitmap(Width, Height)
  291.             Using G = Graphics.FromImage(B)
  292.                 Draw.Gradient(G, C2, C3, 1, 1, Width - 2, Height - 2)
  293.                 G.DrawRectangle(New Pen(C2), 1, 1, V - 3, Height - 3)
  294.                 Draw.Gradient(G, C3, C2, 2, 2, V - 4, Height - 4)
  295.  
  296.                 G.DrawRectangle(New Pen(C1), 0, 0, Width - 1, Height - 1)
  297.  
  298.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  299.             End Using
  300.         End Using
  301.     End Sub
  302. End Class
  303. 'Electron Theme
  304. Public Class ETheme : Inherits Control
  305.     Private _TitleHeight As Integer = 25
  306.     Public Property TitleHeight() As Integer
  307.         Get
  308.             Return _TitleHeight
  309.         End Get
  310.         Set(ByVal v As Integer)
  311.             If v > Height Then v = Height
  312.             If v < 2 Then Height = 1
  313.             _TitleHeight = v : Invalidate()
  314.         End Set
  315.     End Property
  316.     Private _TitleAlign As HorizontalAlignment = 2
  317.     Public Property TitleAlign() As HorizontalAlignment
  318.         Get
  319.             Return _TitleAlign
  320.         End Get
  321.         Set(ByVal v As HorizontalAlignment)
  322.             _TitleAlign = v : Invalidate()
  323.         End Set
  324.     End Property
  325.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  326.         Dock = 5
  327.         If TypeOf Parent Is Form Then CType(Parent, Form).FormBorderStyle = 0
  328.         MyBase.OnHandleCreated(e)
  329.     End Sub
  330.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  331.         If New Rectangle(Parent.Location.X, Parent.Location.Y, Width - 1, _TitleHeight - 1).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then
  332.             Capture = False : Dim M = Message.Create(Parent.Handle, 161, 2, 0) : DefWndProc(M)
  333.         End If : MyBase.OnMouseDown(e)
  334.     End Sub
  335.     Dim C1 As Color = Color.FromArgb(0, 70, 114), C2 As Color = Color.FromArgb(0, 47, 78), C3 As Color = Color.FromArgb(0, 34, 57), _
  336.     C4 As Color = Color.FromArgb(0, 30, 50)
  337.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  338.     End Sub
  339.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  340.         Using B As New Bitmap(Width, Height)
  341.             Using G = Graphics.FromImage(B)
  342.                 G.Clear(C3)
  343.  
  344.                 Draw.Blend(G, C2, C3, C1, 0.5, 1, 0, 0, Width, _TitleHeight)
  345.  
  346.                 G.FillRectangle(New SolidBrush(Color.FromArgb(15, 255, 255, 255)), 1, 1, Width - 2, CInt(_TitleHeight / 2) - 2)
  347.                 G.DrawRectangle(New Pen(Color.FromArgb(35, 255, 255, 255)), 1, 1, Width - 3, _TitleHeight - 2)
  348.  
  349.                 Dim S = G.MeasureString(Text, Font), O = 6
  350.                 If _TitleAlign = 2 Then O = Width / 2 - S.Width / 2
  351.                 If _TitleAlign = 1 Then O = Width - S.Width - 14
  352.                 Dim V = CInt(_TitleHeight / 2 - (S.Height + 4) / 2)
  353.  
  354.                 Draw.Gradient(G, C3, C2, O, V, S.Width + 8, S.Height + 4)
  355.                 G.DrawRectangle(New Pen(C3), O, V, S.Width + 7, S.Height + 3)
  356.  
  357.                 Dim R As New Rectangle(O + 4, CInt(_TitleHeight / 2 - S.Height / 2), S.Width, S.Height)
  358.                 Using T As New LinearGradientBrush(R, C1, C2, LinearGradientMode.Vertical)
  359.                     G.DrawString(Text, Font, T, R)
  360.                 End Using
  361.  
  362.                 G.DrawRectangle(New Pen(C1), 1, _TitleHeight + 1, Width - 3, Height - _TitleHeight - 3)
  363.  
  364.                 G.DrawLine(New Pen(C4), 0, _TitleHeight, Width, _TitleHeight)
  365.                 G.DrawRectangle(New Pen(C4), 0, 0, Width - 1, Height - 1)
  366.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  367.             End Using
  368.         End Using
  369.     End Sub
  370. End Class
clone this paste RAW Paste Data