Advertisement
benito

Untitled

Sep 7th, 2011
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 15.24 KB | None | 0 0
  1.   Imports System.Drawing.Drawing2D
  2.      
  3.     Class Pigment
  4.      
  5.         Private _Name As String = "Pigment"
  6.         Property Name() As String
  7.             Get
  8.                 Return _name
  9.             End Get
  10.             Set(ByVal v As String)
  11.                 _name = v
  12.             End Set
  13.         End Property
  14.      
  15.      
  16.         Private _Value As Color = Color.Black
  17.         Public Property Value() As Color
  18.             Get
  19.                 Return _Value
  20.             End Get
  21.             Set(ByVal value As Color)
  22.                 _Value = value
  23.             End Set
  24.         End Property
  25.      
  26.      
  27.         Sub New()
  28.         End Sub
  29.      
  30.         Sub New(ByVal n As String, ByVal v As Color)
  31.             Name = n
  32.             Value = v
  33.         End Sub
  34.      
  35.         Sub New(ByVal n As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  36.             Name = n
  37.             Value = Color.FromArgb(a, r, g, b)
  38.         End Sub
  39.      
  40.         Sub New(ByVal n As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  41.             Name = n
  42.             Value = Color.FromArgb(r, g, b)
  43.         End Sub
  44.     End Class
  45.      
  46.     Class FTheme
  47.         Inherits ContainerControl
  48.      
  49.      
  50.         Private _Resizeable As Boolean = True
  51.         Public Property Resizeable() As Boolean
  52.             Get
  53.                 Return _Resizeable
  54.             End Get
  55.             Set(ByVal value As Boolean)
  56.                 _Resizeable = value
  57.             End Set
  58.         End Property
  59.      
  60.      
  61.      
  62.         Sub New()
  63.             SetStyle(DirectCast(8198, ControlStyles), True)
  64.             C = New Pigment() { _
  65.             New Pigment("Border", Color.Black), _
  66.             New Pigment("Frame", 47, 47, 50), _
  67.             New Pigment("Border Highlight", 15, 255, 255, 255), _
  68.             New Pigment("Side Highlight", 6, 255, 255, 255), _
  69.             New Pigment("Shine", 20, 255, 255, 255), _
  70.             New Pigment("Shadow", 38, 38, 40), _
  71.             New Pigment("Backcolor", 247, 247, 251), _
  72.             New Pigment("Transparency", Color.Fuchsia) _
  73.             }
  74.         End Sub
  75.      
  76.         Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  77.             Dock = DockStyle.Fill
  78.             If TypeOf Parent Is Form Then DirectCast(Parent, Form).FormBorderStyle = FormBorderStyle.None
  79.             Colors = C
  80.             MyBase.OnHandleCreated(e)
  81.         End Sub
  82.      
  83.         Const Count As Byte = 8
  84.         Private C As Pigment()
  85.         Public Property Colors() As Pigment()
  86.             Get
  87.                 Return C
  88.             End Get
  89.             Set(ByVal v As Pigment())
  90.                 If v.Length <> Count Then Throw New IndexOutOfRangeException
  91.      
  92.                 P1 = New Pen(v(0).Value)
  93.                 P2 = New Pen(v(2).Value)
  94.      
  95.                 B1 = New SolidBrush(v(6).Value)
  96.                 B2 = New SolidBrush(v(7).Value)
  97.      
  98.                 If Parent IsNot Nothing Then
  99.                     Parent.BackColor = v(6).Value
  100.                     If TypeOf Parent Is Form Then DirectCast(Parent, Form).TransparencyKey = v(7).Value
  101.                 End If
  102.      
  103.                 CB = New ColorBlend
  104.                 CB.Colors = New Color() {Color.Transparent, v(4).Value, Color.Transparent}
  105.                 CB.Positions = New Single() {0, 0.5, 1}
  106.      
  107.                 C = v
  108.      
  109.                 Invalidate()
  110.             End Set
  111.         End Property
  112.      
  113.         Private P1, P2, P3 As Pen
  114.         Private B1, B2 As SolidBrush, B3, B4 As LinearGradientBrush
  115.         Private R1, R2 As Rectangle
  116.         Private CB As ColorBlend
  117.      
  118.         Private G As Graphics, B As Bitmap
  119.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  120.             B = New Bitmap(Width, Height)
  121.             G = Graphics.FromImage(B)
  122.      
  123.             G.Clear(C(1).Value)
  124.      
  125.      
  126.             G.DrawRectangle(P2, New Rectangle(1, 1, Width - 3, Height - 3))
  127.             G.DrawRectangle(P2, New Rectangle(12, 40, Width - 24, Height - 52))
  128.      
  129.      
  130.             R1 = New Rectangle(1, 0, 15, Height)
  131.             B3 = New LinearGradientBrush(R1, C(3).Value, Color.Transparent, 90.0F)
  132.             G.FillRectangle(B3, R1)
  133.             G.FillRectangle(B3, New Rectangle(Width - 16, 0, 15, Height))
  134.      
  135.      
  136.             G.FillRectangle(B1, New Rectangle(13, 41, Width - 26, Height - 54))
  137.      
  138.      
  139.             R2 = New Rectangle(0, 2, Width, 2)
  140.             B4 = New LinearGradientBrush(R2, Color.Empty, Color.Empty, 0)
  141.             B4.InterpolationColors = CB
  142.             G.FillRectangle(B4, R2)
  143.      
  144.      
  145.             G.DrawRectangle(P1, New Rectangle(13, 41, Width - 26, Height - 54))
  146.             G.DrawRectangle(P1, New Rectangle(0, 0, Width - 1, Height - 1))
  147.      
  148.      
  149.             G.FillRectangle(B2, New Rectangle(0, 0, 2, 2))
  150.             G.FillRectangle(B2, New Rectangle(Width - 2, 0, 2, 2))
  151.             G.FillRectangle(B2, New Rectangle(Width - 2, Height - 2, 2, 2))
  152.             G.FillRectangle(B2, New Rectangle(0, Height - 2, 2, 2))
  153.      
  154.             B.SetPixel(1, 1, Color.Black)
  155.             B.SetPixel(Width - 2, 1, Color.Black)
  156.             B.SetPixel(Width - 2, Height - 2, Color.Black)
  157.             B.SetPixel(1, Height - 2, Color.Black)
  158.      
  159.      
  160.             e.Graphics.DrawImage(B, 0, 0)
  161.             B3.Dispose()
  162.             B4.Dispose()
  163.             G.Dispose()
  164.             B.Dispose()
  165.         End Sub
  166.      
  167.      
  168.         Enum Direction As Integer
  169.             NONE = 0
  170.             LEFT = 10
  171.             RIGHT = 11
  172.             TOP = 12
  173.             TOPLEFT = 13
  174.             TOPRIGHT = 14
  175.             BOTTOM = 15
  176.             BOTTOMLEFT = 16
  177.             BOTTOMRIGHT = 17
  178.         End Enum
  179.         Private Current As Direction
  180.         Sub SetCurrent()
  181.             Dim T As Point = PointToClient(MousePosition)
  182.             If T.X < 7 And T.Y < 7 Then
  183.                 Current = Direction.TOPLEFT
  184.                 Cursor = Cursors.SizeNWSE
  185.             ElseIf T.X < 7 And T.Y > Height - 7 Then
  186.                 Current = Direction.BOTTOMLEFT
  187.                 Cursor = Cursors.SizeNESW
  188.             ElseIf T.X > Width - 7 And T.Y > Height - 7 Then
  189.                 Current = Direction.BOTTOMRIGHT
  190.                 Cursor = Cursors.SizeNWSE
  191.             ElseIf T.X > Width - 7 And T.Y < 7 Then
  192.                 Current = Direction.TOPRIGHT
  193.                 Cursor = Cursors.SizeNESW
  194.             ElseIf T.X < 7 Then
  195.                 Current = Direction.LEFT
  196.                 Cursor = Cursors.SizeWE
  197.             ElseIf T.X > Width - 7 Then
  198.                 Current = Direction.RIGHT
  199.                 Cursor = Cursors.SizeWE
  200.             ElseIf T.Y < 7 Then
  201.                 Current = Direction.TOP
  202.                 Cursor = Cursors.SizeNS
  203.             ElseIf T.Y > Height - 7 Then
  204.                 Current = Direction.BOTTOM
  205.                 Cursor = Cursors.SizeNS
  206.             Else
  207.                 Current = Direction.NONE
  208.                 Cursor = Cursors.Default
  209.             End If
  210.         End Sub
  211.         Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  212.             If e.Button = MouseButtons.Left Then
  213.                 If TypeOf Parent Is Form Then
  214.                     If DirectCast(Parent, Form).WindowState = FormWindowState.Maximized Then Return
  215.                 End If
  216.                 If Drag.Contains(e.Location) Then
  217.                     Capture = False
  218.                     DefWndProc(Message.Create(Parent.Handle, 161, New IntPtr(2), Nothing))
  219.                 Else
  220.                     If Current <> Direction.NONE And _Resizeable Then
  221.                         Capture = False
  222.                         DefWndProc(Message.Create(Parent.Handle, 161, New IntPtr(Current), Nothing))
  223.                     End If
  224.                 End If
  225.             End If
  226.             MyBase.OnMouseDown(e)
  227.         End Sub
  228.         Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  229.             If _Resizeable Then SetCurrent()
  230.             MyBase.OnMouseMove(e)
  231.         End Sub
  232.         Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  233.             Invalidate()
  234.             MyBase.OnSizeChanged(e)
  235.         End Sub
  236.         Private ReadOnly Property Drag() As Rectangle
  237.             Get
  238.                 Return New Rectangle(7, 7, Width - 14, 35)
  239.             End Get
  240.         End Property
  241.      
  242.     End Class
  243.     Class FButton
  244.         Inherits Control
  245.      
  246.      
  247.         Private Shadow_ As Boolean = True
  248.         Public Property Shadow() As Boolean
  249.             Get
  250.                 Return Shadow_
  251.             End Get
  252.             Set(ByVal value As Boolean)
  253.                 Shadow_ = value
  254.                 Invalidate()
  255.             End Set
  256.         End Property
  257.      
  258.      
  259.         Sub New()
  260.             SetStyle(DirectCast(8198, ControlStyles), True)
  261.             Colors = New Pigment() {New Pigment("Border", 254, 133, 0), New Pigment("Backcolor", 247, 247, 251), _
  262.             New Pigment("Highlight", 255, 197, 19), New Pigment("Gradient1", 255, 175, 12), _
  263.             New Pigment("Gradient2", 255, 127, 1), New Pigment("Text Color", Color.White), _
  264.             New Pigment("Text Shadow", 30, 0, 0, 0)}
  265.             Font = New Font("Verdana", 8)
  266.         End Sub
  267.      
  268.         Const Count As Byte = 7
  269.         Private C As Pigment()
  270.         Public Property Colors() As Pigment()
  271.             Get
  272.                 Return C
  273.             End Get
  274.             Set(ByVal v As Pigment())
  275.                 If v.Length <> Count Then Throw New IndexOutOfRangeException
  276.      
  277.                 P1 = New Pen(v(0).Value)
  278.                 P2 = New Pen(v(2).Value)
  279.      
  280.                 B1 = New SolidBrush(v(6).Value)
  281.                 B2 = New SolidBrush(v(5).Value)
  282.      
  283.                 C = v
  284.                 Invalidate()
  285.             End Set
  286.         End Property
  287.      
  288.         Private P1, P2 As Pen
  289.         Private B1, B2 As SolidBrush, B3 As LinearGradientBrush
  290.         Private SZ As Size, PT As Point
  291.      
  292.         Private G As Graphics, B As Bitmap
  293.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  294.             B = New Bitmap(Width, Height)
  295.             G = Graphics.FromImage(B)
  296.      
  297.             If Down Then
  298.                 B3 = New LinearGradientBrush(ClientRectangle, C(4).Value, C(3).Value, 90.0F)
  299.             Else
  300.                 B3 = New LinearGradientBrush(ClientRectangle, C(3).Value, C(4).Value, 90.0F)
  301.             End If
  302.             G.FillRectangle(B3, ClientRectangle)
  303.      
  304.             If Not String.IsNullOrEmpty(Text) Then
  305.                 SZ = G.MeasureString(Text, Font).ToSize
  306.                 PT = New Point(CInt(Width / 2 - SZ.Width / 2), CInt(Height / 2 - SZ.Height / 2))
  307.                 If Shadow_ Then G.DrawString(Text, Font, B1, PT.X + 1, PT.Y + 1)
  308.                 G.DrawString(Text, Font, B2, PT)
  309.             End If
  310.      
  311.             G.DrawRectangle(P1, New Rectangle(0, 0, Width - 1, Height - 1))
  312.             G.DrawRectangle(P2, New Rectangle(1, 1, Width - 3, Height - 3))
  313.      
  314.             B.SetPixel(0, 0, C(1).Value)
  315.             B.SetPixel(Width - 1, 0, C(1).Value)
  316.             B.SetPixel(Width - 1, Height - 1, C(1).Value)
  317.             B.SetPixel(0, Height - 1, C(1).Value)
  318.      
  319.             e.Graphics.DrawImage(B, 0, 0)
  320.             B3.Dispose()
  321.             G.Dispose()
  322.             B.Dispose()
  323.         End Sub
  324.      
  325.         Private Down As Boolean
  326.         Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  327.             If e.Button = MouseButtons.Left Then
  328.                 Down = True
  329.                 Invalidate()
  330.             End If
  331.             MyBase.OnMouseDown(e)
  332.         End Sub
  333.         Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  334.             Down = False
  335.             Invalidate()
  336.             MyBase.OnMouseUp(e)
  337.         End Sub
  338.      
  339.     End Class
  340.     Class FProgressBar
  341.         Inherits Control
  342.      
  343.         Private _Maximum As Double = 100
  344.         Public Property Maximum() As Double
  345.             Get
  346.                 Return _Maximum
  347.             End Get
  348.             Set(ByVal v As Double)
  349.                 _Maximum = v
  350.                 Progress = _Current / v * 100
  351.             End Set
  352.         End Property
  353.         Private _Current As Double
  354.         Public Property Current() As Double
  355.             Get
  356.                 Return _Current
  357.             End Get
  358.             Set(ByVal v As Double)
  359.                 Progress = v / _Maximum * 100
  360.             End Set
  361.         End Property
  362.         Private _Progress As Double
  363.         Public Property Progress() As Double
  364.             Get
  365.                 Return _Progress
  366.             End Get
  367.             Set(ByVal v As Double)
  368.                 If v < 0 Then v = 0 Else If v > 100 Then v = 100
  369.                 _Progress = v
  370.                 _Current = v * 0.01 * _Maximum
  371.                 Invalidate()
  372.             End Set
  373.         End Property
  374.      
  375.         Sub New()
  376.             SetStyle(DirectCast(8198, ControlStyles), True)
  377.             Colors = New Pigment() { _
  378.             New Pigment("Border", 214, 214, 216), New Pigment("Backcolor1", 247, 247, 251), _
  379.             New Pigment("Backcolor2", 239, 239, 242), New Pigment("Highlight", 100, 255, 255, 255), _
  380.             New Pigment("Forecolor", 224, 224, 224), New Pigment("Gloss", 130, 255, 255, 255)}
  381.         End Sub
  382.      
  383.         Const Count As Byte = 6
  384.         Private C As Pigment()
  385.         Public Property Colors() As Pigment()
  386.             Get
  387.                 Return C
  388.             End Get
  389.             Set(ByVal v As Pigment())
  390.                 If v.Length <> Count Then Throw New IndexOutOfRangeException
  391.      
  392.                 P1 = New Pen(v(0).Value)
  393.                 P2 = New Pen(v(3).Value)
  394.      
  395.                 B1 = New SolidBrush(v(4).Value)
  396.      
  397.                 CB = New ColorBlend
  398.                 CB.Colors = New Color() {v(5).Value, Color.Transparent, Color.Transparent}
  399.                 CB.Positions = New Single() {0, 0.3, 1}
  400.      
  401.                 C = v
  402.                 Invalidate()
  403.             End Set
  404.         End Property
  405.      
  406.         Private P1, P2 As Pen
  407.         Private B1 As SolidBrush, B2 As LinearGradientBrush
  408.         Private CB As ColorBlend
  409.      
  410.         Private G As Graphics, B As Bitmap
  411.         Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  412.             B = New Bitmap(Width, Height)
  413.             G = Graphics.FromImage(B)
  414.      
  415.             G.Clear(C(2).Value)
  416.      
  417.             G.FillRectangle(B1, New Rectangle(1, 1, CInt((Width * _Progress * 0.01) - 2), Height - 2))
  418.      
  419.             B2 = New LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 90.0F)
  420.             B2.InterpolationColors = CB
  421.             G.FillRectangle(B2, ClientRectangle)
  422.      
  423.             G.DrawRectangle(P1, New Rectangle(0, 0, Width - 1, Height - 1))
  424.             G.DrawRectangle(P2, New Rectangle(1, 1, Width - 3, Height - 3))
  425.      
  426.             B.SetPixel(0, 0, C(1).Value)
  427.             B.SetPixel(Width - 1, 0, C(1).Value)
  428.             B.SetPixel(Width - 1, Height - 1, C(1).Value)
  429.             B.SetPixel(0, Height - 1, C(1).Value)
  430.      
  431.             e.Graphics.DrawImage(B, 0, 0)
  432.             B2.Dispose()
  433.             G.Dispose()
  434.             B.Dispose()
  435.         End Sub
  436.      
  437.         Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  438.             Invalidate()
  439.             MyBase.OnSizeChanged(e)
  440.         End Sub
  441.     End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement