Advertisement
Guest User

Visual Studio Theme - Aeonhack

a guest
Jun 21st, 2011
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.45 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2.  
  3. Public Class Draw
  4.     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)
  5.         Dim R As New Rectangle(x, y, width, height)
  6.         Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
  7.             g.FillRectangle(T, R)
  8.         End Using
  9.     End Sub
  10.     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)
  11.         Dim V As New ColorBlend(3)
  12.         V.Colors = New Color() {c1, c2, c3}
  13.         V.Positions = New Single() {0, c, 1}
  14.         Dim R As New Rectangle(x, y, width, height)
  15.         Using T As New LinearGradientBrush(R, c1, c1, CType(d, LinearGradientMode))
  16.             T.InterpolationColors = V : g.FillRectangle(T, R)
  17.         End Using
  18.     End Sub
  19. End Class
  20.  
  21. Public Class VSTheme : Inherits Control
  22.     Private _TitleHeight As Integer = 23
  23.     Public Property TitleHeight() As Integer
  24.         Get
  25.             Return _TitleHeight
  26.         End Get
  27.         Set(ByVal v As Integer)
  28.             If v > Height Then v = Height
  29.             If v < 2 Then Height = 1
  30.             _TitleHeight = v : Invalidate()
  31.         End Set
  32.     End Property
  33.     Private _TitleAlign As HorizontalAlignment
  34.     Public Property TitleAlign() As HorizontalAlignment
  35.         Get
  36.             Return _TitleAlign
  37.         End Get
  38.         Set(ByVal v As HorizontalAlignment)
  39.             _TitleAlign = v : Invalidate()
  40.         End Set
  41.     End Property
  42.     Sub New()
  43.         Using B As New Bitmap(3, 3)
  44.             Using G = Graphics.FromImage(B)
  45.                 G.Clear(Color.FromArgb(53, 67, 88))
  46.                 G.DrawLine(New Pen(Color.FromArgb(33, 46, 67)), 0, 0, 2, 2)
  47.                 Tile = B.Clone
  48.             End Using
  49.         End Using
  50.     End Sub
  51.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  52.         Invalidate()
  53.         MyBase.OnTextChanged(e)
  54.     End Sub
  55.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  56.         Dock = 5
  57.         If TypeOf Parent Is Form Then
  58.             CType(Parent, Form).FormBorderStyle = 0
  59.             CType(Parent, Form).TransparencyKey = Color.Fuchsia
  60.         End If
  61.         MyBase.OnHandleCreated(e)
  62.     End Sub
  63.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  64.         If New Rectangle(Parent.Location.X, Parent.Location.Y, Width - 1, _TitleHeight - 1).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then
  65.             Capture = False : Dim M = Message.Create(Parent.Handle, 161, 2, 0) : DefWndProc(M)
  66.         End If : MyBase.OnMouseDown(e)
  67.     End Sub
  68.     Dim C1 As Color = Color.FromArgb(249, 245, 226), C2 As Color = Color.FromArgb(255, 232, 165), C3 As Color = Color.FromArgb(64, 90, 127)
  69.     Dim Tile As Image
  70.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  71.     End Sub
  72.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  73.         Using B As New Bitmap(Width, Height)
  74.             Using G = Graphics.FromImage(B)
  75.  
  76.                 Using T As New TextureBrush(Tile, 0)
  77.                     G.FillRectangle(T, 0, _TitleHeight, Width, Height - _TitleHeight)
  78.                 End Using
  79.                 Draw.Blend(G, Color.Transparent, Color.Transparent, C3, 0.1, 1, 0, 0, Width, Height - _TitleHeight * 2)
  80.                 G.FillRectangle(New SolidBrush(C3), 0, Height - _TitleHeight * 2, Width, _TitleHeight * 2)
  81.  
  82.                 Draw.Gradient(G, C1, C2, 0, 0, Width, _TitleHeight)
  83.                 G.FillRectangle(New SolidBrush(Color.FromArgb(100, 255, 255, 255)), 0, 0, Width, CInt(_TitleHeight / 2))
  84.  
  85.                 G.DrawRectangle(New Pen(C2, 2), 1, _TitleHeight - 1, Width - 2, Height - _TitleHeight)
  86.                 G.DrawArc(New Pen(Color.Fuchsia, 2), -1, -1, 9, 9, 180, 90)
  87.                 G.DrawArc(New Pen(Color.Fuchsia, 2), Width - 9, -1, 9, 9, 270, 90)
  88.  
  89.                 G.TextRenderingHint = 5
  90.                 Dim S = G.MeasureString(Text, Font), O = 6
  91.                 If _TitleAlign = 2 Then O = Width / 2 - S.Width / 2
  92.                 If _TitleAlign = 1 Then O = Width - S.Width - 6
  93.                 G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(111, 88, 38)), O, CInt(_TitleHeight / 2 - S.Height / 2))
  94.  
  95.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  96.             End Using
  97.         End Using
  98.     End Sub
  99. End Class
  100. Public Class VSButton : Inherits Control
  101.     Sub New()
  102.         ForeColor = C3
  103.     End Sub
  104.     Private State As Integer
  105.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  106.         State = 1 : Invalidate() : MyBase.OnMouseEnter(e)
  107.     End Sub
  108.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  109.         State = 2 : Invalidate() : MyBase.OnMouseDown(e)
  110.     End Sub
  111.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  112.         State = 0 : Invalidate() : MyBase.OnMouseLeave(e)
  113.     End Sub
  114.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  115.         State = 1 : Invalidate() : MyBase.OnMouseUp(e)
  116.     End Sub
  117.     Dim C1 As Color = Color.FromArgb(249, 245, 226), C2 As Color = Color.FromArgb(255, 232, 165), C3 As Color = Color.FromArgb(111, 88, 38)
  118.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  119.     End Sub
  120.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  121.         Using B As New Bitmap(Width, Height)
  122.             Using G = Graphics.FromImage(B)
  123.                 If State = 2 Then
  124.                     Draw.Gradient(G, C2, C1, 0, 0, Width, Height)
  125.                 Else
  126.                     Draw.Gradient(G, C1, C2, 0, 0, Width, Height)
  127.                 End If
  128.  
  129.                 If State < 2 Then G.FillRectangle(New SolidBrush(Color.FromArgb(100, 255, 255, 255)), 0, 0, Width, CInt(Height / 2))
  130.  
  131.                 G.TextRenderingHint = 5
  132.                 Dim S = G.MeasureString(Text, Font)
  133.                 G.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)
  134.                 G.DrawRectangle(New Pen(C1), 0, 0, Width - 1, Height - 1)
  135.  
  136.                 e.Graphics.DrawImage(B.Clone, 0, 0)
  137.             End Using
  138.         End Using
  139.     End Sub
  140. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement