Advertisement
Guest User

Visual Studio Theme

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