Advertisement
benito

Untitled

Sep 7th, 2011
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 12.57 KB | None | 0 0
  1.     Imports System.Drawing.Drawing2D
  2.  
  3.     Class FutureTheme
  4.         Inherits Control
  5.      
  6.         Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  7.             Dock = DockStyle.Fill
  8.             If TypeOf Parent Is Form Then
  9.                 With DirectCast(Parent, Form)
  10.                     .FormBorderStyle = 0
  11.                     .BackColor = C1
  12.                     .ForeColor = Color.FromArgb(12, 12, 12)
  13.                 End With
  14.             End If
  15.             MyBase.OnHandleCreated(e)
  16.         End Sub
  17.         Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  18.             If New Rectangle(Parent.Location.X, Parent.Location.Y, Width, 22).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then
  19.                 Capture = False
  20.                 Dim M As Message = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  21.                 DefWndProc(M)
  22.             End If
  23.             MyBase.OnMouseDown(e)
  24.         End Sub
  25.      
  26.         Dim G As Graphics, B As Bitmap, R1, R2 As Rectangle
  27.         Dim C1, C2, C3 As Color, P1, P2, P3 As Pen, B1 As SolidBrush, B2, B3 As LinearGradientBrush
  28.      
  29.         Sub New()
  30.      
  31.             SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
  32.             C1 = Color.FromArgb(34, 34, 34) 'Background
  33.             C2 = Color.FromArgb(49, 49, 49) 'Highlight
  34.             C3 = Color.FromArgb(22, 22, 22) 'Shadow
  35.             P1 = New Pen(Color.Black) 'Border
  36.             P2 = New Pen(C1)
  37.             P3 = New Pen(C2)
  38.             B1 = New SolidBrush(C2)
  39.             Font = New Font("Verdana", 7.0F, FontStyle.Bold)
  40.      
  41.         End Sub
  42.      
  43.         Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  44.             If Height > 0 Then
  45.                 R1 = New Rectangle(0, 2, Width, 18)
  46.                 R2 = New Rectangle(0, 21, Width, 10)
  47.                 B2 = New LinearGradientBrush(R1, C1, C3, 90.0F)
  48.                 B3 = New LinearGradientBrush(R2, Color.FromArgb(70, 0, 0, 0), Color.Transparent, 90.0F)
  49.                 Invalidate()
  50.             End If
  51.             MyBase.OnSizeChanged(e)
  52.         End Sub
  53.      
  54.         Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
  55.         End Sub
  56.      
  57.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  58.             B = New Bitmap(Width, Height)
  59.             G = Graphics.FromImage(B)
  60.      
  61.             G.Clear(C1)
  62.      
  63.             For I As Integer = 0 To Width + 17 Step 4
  64.                 G.DrawLine(P1, I, 21, I - 17, 37)
  65.                 G.DrawLine(P1, I - 1, 21, I - 16, 37)
  66.             Next
  67.             G.FillRectangle(B3, R2)
  68.      
  69.             G.FillRectangle(B2, R1)
  70.             G.DrawString(Text, Font, B1, 5, 5)
  71.      
  72.             G.DrawRectangle(P2, 1, 1, Width - 3, 19)
  73.             G.DrawRectangle(P3, 1, 39, Width - 3, Height - 41)
  74.      
  75.             G.DrawRectangle(P1, 0, 0, Width - 1, Height - 1)
  76.             G.DrawLine(P1, 0, 21, Width, 21)
  77.             G.DrawLine(P1, 0, 38, Width, 38)
  78.      
  79.             e.Graphics.DrawImage(B, 0, 0)
  80.             G.Dispose()
  81.             B.Dispose()
  82.         End Sub
  83.      
  84.     End Class
  85.     Class FutureButton
  86.         Inherits Control
  87.      
  88.         Dim B As Bitmap, G As Graphics, R1 As Rectangle
  89.         Dim C1, C2, C3, C4 As Color, P1, P2, P3, P4 As Pen, B1, B2, B5 As Brush, B3, B4 As LinearGradientBrush
  90.      
  91.         Sub New()
  92.             SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
  93.      
  94.             C1 = Color.FromArgb(34, 34, 34) 'Background
  95.             C2 = Color.FromArgb(49, 49, 49) 'Highlight
  96.             C3 = Color.FromArgb(39, 39, 39) 'Lesser Highlight
  97.             C4 = Color.FromArgb(60, Color.Black)
  98.             P1 = New Pen(Color.FromArgb(22, 22, 22)) 'Shadow
  99.             P2 = New Pen(Color.FromArgb(20, Color.White))
  100.             P3 = New Pen(Color.FromArgb(10, Color.White))
  101.             P4 = New Pen(Color.FromArgb(30, Color.Black))
  102.             B1 = New SolidBrush(C1)
  103.             B2 = New SolidBrush(C3)
  104.             B5 = New SolidBrush(Color.FromArgb(12, 12, 12)) 'Text Color
  105.             Font = New Font("Verdana", 8.0F)
  106.         End Sub
  107.      
  108.         Private State As Integer
  109.         Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  110.             State = 0
  111.             Invalidate()
  112.         End Sub
  113.         Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  114.             State = 1
  115.             Invalidate()
  116.         End Sub
  117.         Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  118.             State = 1
  119.             Invalidate()
  120.         End Sub
  121.         Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  122.             State = 2
  123.             Invalidate()
  124.         End Sub
  125.      
  126.         Protected Overrides Sub OnResize(ByVal e As EventArgs)
  127.             R1 = New Rectangle(2, 2, Width - 4, 4)
  128.             B3 = New LinearGradientBrush(ClientRectangle, C3, C2, 90.0F)
  129.             B4 = New LinearGradientBrush(R1, C4, Color.Transparent, 90.0F)
  130.             Invalidate()
  131.         End Sub
  132.      
  133.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  134.             B = New Bitmap(Width, Height)
  135.             G = Graphics.FromImage(B)
  136.      
  137.             G.FillRectangle(B3, ClientRectangle)
  138.      
  139.             Select Case State
  140.                 Case 0 'Up
  141.                     G.FillRectangle(B1, 1, 1, Width - 2, Height - 2)
  142.                     G.DrawLine(P2, 2, 2, Width - 3, 2)
  143.                     G.DrawLine(P3, 2, Height - 3, Width - 3, Height - 3)
  144.                 Case 1 'Over
  145.                     G.FillRectangle(B2, 1, 1, Width - 2, Height - 2)
  146.                     G.DrawLine(P2, 2, 2, Width - 3, 2)
  147.                     G.DrawLine(P3, 2, Height - 3, Width - 3, Height - 3)
  148.                 Case 2 'Down
  149.                     G.FillRectangle(B2, 1, 1, Width - 2, Height - 2)
  150.                     G.FillRectangle(B4, R1)
  151.                     G.DrawLine(P4, 2, 2, 2, Height - 3)
  152.             End Select
  153.      
  154.             Dim S As SizeF = G.MeasureString(Text, Font)
  155.             G.DrawString(Text, Font, B5, Convert.ToInt32(Width / 2 - S.Width / 2), Convert.ToInt32(Height / 2 - S.Height / 2))
  156.      
  157.             G.DrawRectangle(P1, 1, 1, Width - 3, Height - 3)
  158.      
  159.             e.Graphics.DrawImage(B, 0, 0)
  160.             G.Dispose()
  161.             B.Dispose()
  162.         End Sub
  163.      
  164.         Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
  165.         End Sub
  166.      
  167.     End Class
  168.     Class FutureProgressBar
  169.         Inherits Control
  170.      
  171.     #Region " Properties "
  172.         Private _Maximum As Double = 100
  173.         Public Property Maximum() As Double
  174.             Get
  175.                 Return _Maximum
  176.             End Get
  177.             Set(ByVal v As Double)
  178.                 _Maximum = v
  179.                 Progress = _Current / v * 100
  180.                 Invalidate()
  181.             End Set
  182.         End Property
  183.         Private _Current As Double
  184.         Public Property Current() As Double
  185.             Get
  186.                 Return _Current
  187.             End Get
  188.             Set(ByVal v As Double)
  189.                 _Current = v
  190.                 Progress = v / _Maximum * 100
  191.                 Invalidate()
  192.             End Set
  193.         End Property
  194.         Private _Progress As Integer
  195.         Public Property Progress() As Double
  196.             Get
  197.                 Return _Progress
  198.             End Get
  199.             Set(ByVal v As Double)
  200.                 If v < 0 Then v = 0 Else If v > 100 Then v = 100
  201.                 _Progress = Convert.ToInt32(v)
  202.                 _Current = v * 0.01 * _Maximum
  203.                 If Width > 0 Then UpdateProgress()
  204.                 Invalidate()
  205.             End Set
  206.         End Property
  207.      
  208.         Dim C2 As Color = Color.FromArgb(6, 96, 149) 'Dark Color
  209.         Public Property Color1() As Color
  210.             Get
  211.                 Return C2
  212.             End Get
  213.             Set(ByVal v As Color)
  214.                 C2 = v
  215.                 UpdateColors()
  216.                 Invalidate()
  217.             End Set
  218.         End Property
  219.         Dim C3 As Color = Color.FromArgb(70, 167, 220) 'Light color
  220.         Public Property Color2() As Color
  221.             Get
  222.                 Return C3
  223.             End Get
  224.             Set(ByVal v As Color)
  225.                 C3 = v
  226.                 UpdateColors()
  227.                 Invalidate()
  228.             End Set
  229.         End Property
  230.      
  231.     #End Region
  232.      
  233.         Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
  234.         End Sub
  235.      
  236.         Dim G As Graphics, B As Bitmap, R1, R2 As Rectangle, X As ColorBlend
  237.         Dim C1 As Color, P1, P2, P3 As Pen, B1, B2 As LinearGradientBrush, B3 As SolidBrush
  238.         Sub New()
  239.      
  240.             C1 = Color.FromArgb(22, 22, 22) 'Background
  241.             P1 = New Pen(Color.FromArgb(70, Color.White), 2)
  242.             P2 = New Pen(C2)
  243.             P3 = New Pen(Color.FromArgb(49, 49, 49)) 'Highlight
  244.             B3 = New SolidBrush(Color.FromArgb(100, Color.White))
  245.             X = New ColorBlend(4)
  246.             X.Colors = {C2, C3, C3, C2}
  247.             X.Positions = {0.0F, 0.1F, 0.9F, 1.0F}
  248.             R2 = New Rectangle(2, 2, 2, 2)
  249.             B2 = New LinearGradientBrush(R2, Nothing, Nothing, 180.0F)
  250.             B2.InterpolationColors = X
  251.      
  252.         End Sub
  253.      
  254.         Sub UpdateColors()
  255.             P2.Color = C2
  256.             X.Colors = {C2, C3, C3, C2}
  257.             B2.InterpolationColors = X
  258.         End Sub
  259.      
  260.         Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  261.             R1 = New Rectangle(0, 1, Width, 4)
  262.             B1 = New LinearGradientBrush(R1, Color.FromArgb(60, Color.Black), Color.Transparent, 90.0F)
  263.             UpdateProgress()
  264.             Invalidate()
  265.             MyBase.OnSizeChanged(e)
  266.         End Sub
  267.      
  268.         Sub UpdateProgress()
  269.             If _Progress = 0 Then Return
  270.             R2 = New Rectangle(2, 2, Convert.ToInt32((Width - 4) * (_Progress * 0.01)), Height - 4)
  271.             B2 = New LinearGradientBrush(R2, Nothing, Nothing, 180.0F)
  272.             B2.InterpolationColors = X
  273.         End Sub
  274.      
  275.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  276.             B = New Bitmap(Width, Height)
  277.             G = Graphics.FromImage(B)
  278.      
  279.             G.Clear(C1)
  280.      
  281.             G.FillRectangle(B1, R1)
  282.      
  283.             If _Progress > 0 Then
  284.                 G.FillRectangle(B2, R2)
  285.      
  286.                 G.FillRectangle(B3, 2, 3, R2.Width, 4)
  287.                 G.DrawRectangle(P1, 4, 4, R2.Width - 4, Height - 8)
  288.      
  289.                 G.DrawRectangle(P2, 2, 2, R2.Width - 1, Height - 5)
  290.             End If
  291.      
  292.             G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1)
  293.      
  294.             e.Graphics.DrawImage(B, 0, 0)
  295.             G.Dispose()
  296.             B.Dispose()
  297.         End Sub
  298.      
  299.     End Class
  300.     Class FutureSeperator
  301.         Inherits Control
  302.      
  303.         Private _Orientation As Orientation
  304.         Public Property Orientation() As Orientation
  305.             Get
  306.                 Return _Orientation
  307.             End Get
  308.             Set(ByVal v As Orientation)
  309.                 _Orientation = v
  310.                 UpdateOffset()
  311.                 Invalidate()
  312.             End Set
  313.         End Property
  314.      
  315.         Dim G As Graphics, B As Bitmap, I As Integer
  316.         Dim C1 As Color, P1, P2 As Pen
  317.         Sub New()
  318.             SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
  319.             C1 = Color.FromArgb(34, 34, 34) 'Background
  320.             P1 = New Pen(Color.FromArgb(22, 22, 22)) 'Shadow
  321.             P2 = New Pen(Color.FromArgb(49, 49, 49)) 'Highlight
  322.         End Sub
  323.      
  324.         Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  325.             UpdateOffset()
  326.             MyBase.OnSizeChanged(e)
  327.         End Sub
  328.      
  329.         Sub UpdateOffset()
  330.             I = Convert.ToInt32(If(_Orientation = 0, Height / 2 - 1, Width / 2 - 1))
  331.         End Sub
  332.      
  333.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  334.             B = New Bitmap(Width, Height)
  335.             G = Graphics.FromImage(B)
  336.      
  337.             G.Clear(C1)
  338.      
  339.             If _Orientation = 0 Then
  340.                 G.DrawLine(P1, 0, I, Width, I)
  341.                 G.DrawLine(P2, 0, I + 1, Width, I + 1)
  342.             Else
  343.                 G.DrawLine(P2, I, 0, I, Height)
  344.                 G.DrawLine(P1, I + 1, 0, I + 1, Height)
  345.             End If
  346.      
  347.             e.Graphics.DrawImage(B, 0, 0)
  348.             G.Dispose()
  349.             B.Dispose()
  350.         End Sub
  351.      
  352.         Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
  353.         End Sub
  354.      
  355.     End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement