Advertisement
Guest User

Untitled

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