Guest User

[VB.NET] [KOBO THEME] MY FIRST CREATION [CUSTOMIZABLE]

a guest
Aug 3rd, 2014
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '--------------------- [ THEME ] ---------------------
  2. 'Name: Kobo theme
  3. 'Creator: Ashlanfox
  4. 'Contact: Ashlanfox (Skype)
  5. 'Created: 27.07.2014
  6. 'Changed: 02.08.2014
  7. 'Thanks to: Aeonhack (theme base), ibennz (progressbar example) and  iSynthesis (tabcontrol example)!
  8. 'Inspirated of: Kobo desktop
  9. '-------------------- [ /THEME ] ---------------------
  10.  
  11. Class KoboTheme
  12.     Inherits ThemeContainer154
  13.  
  14. #Region "Variables | Colors"
  15.     Private BGC As Color = Color.FromArgb(75, 75, 75) 'BACKGROUND COLOR
  16.    Private LC As Color = Color.FromArgb(32, 175, 206) 'LINE COLOR
  17. #End Region
  18.  
  19.     Sub New()
  20.         BackColor = Color.FromArgb(75, 75, 75)
  21.     End Sub
  22.  
  23.     Protected Overrides Sub ColorHook()
  24.  
  25.     End Sub
  26.  
  27.     Protected Overrides Sub PaintHook()
  28.         G.Clear(BGC)
  29.         G.DrawLine(New Pen(New SolidBrush(LC), 2), 0, 50, Width, 50)
  30.     End Sub
  31. End Class
  32.  
  33. Class KoboTabControlB
  34.     Inherits TabControl
  35.  
  36. #Region "Properties | TabControl"
  37.     Private _HighlightTab As Boolean = True
  38.     Public Property HighlightTab() As Boolean
  39.         Get
  40.             Return _HighlightTab
  41.         End Get
  42.         Set(ByVal v As Boolean)
  43.             _HighlightTab = v
  44.             Invalidate()
  45.         End Set
  46.     End Property
  47.  
  48.     Private _ShowBorders As Boolean = False
  49.     Public Property ShowBorders() As Boolean
  50.         Get
  51.             Return _ShowBorders
  52.         End Get
  53.         Set(ByVal v As Boolean)
  54.             _ShowBorders = v
  55.             Invalidate()
  56.         End Set
  57.     End Property
  58.  
  59.     Private _DisableTabIndex As String
  60.     Public Property DisableTabIndex() As String
  61.         Get
  62.             Return _DisableTabIndex
  63.         End Get
  64.         Set(ByVal v As String)
  65.             _DisableTabIndex = v
  66.             Invalidate()
  67.         End Set
  68.     End Property
  69.  
  70.     Private _BGColor As Color = Color.FromArgb(75, 75, 75)
  71.     Public Property BGColor() As Color
  72.         Get
  73.             Return _BGColor
  74.         End Get
  75.         Set(ByVal v As Color)
  76.             _BGColor = v
  77.             Invalidate()
  78.         End Set
  79.     End Property
  80. #End Region
  81.  
  82. #Region "Variables | Colors, Integer, Point"
  83.     Private BC As Color = Color.FromArgb(32, 175, 206) 'BACK COLOR
  84.    Private AC As Color = Color.White 'ACTIVE COLOR
  85.    Private _MOUSEPOS As Point
  86.     Private LSI As Integer 'LAST SELECTED INDEX
  87.    Private MOUSE_STATE As MouseState
  88. #End Region
  89.  
  90. #Region "Functions | Disabled tab page(s)"
  91.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  92.         MOUSE_STATE = MouseState.None
  93.         _MOUSEPOS.X = New Integer
  94.         _MOUSEPOS.Y = New Integer
  95.         MyBase.OnMouseLeave(e)
  96.     End Sub
  97.  
  98.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  99.         MOUSE_STATE = MouseState.Over
  100.         MyBase.OnMouseEnter(e)
  101.     End Sub
  102.  
  103.     Protected Overrides Sub OnSelecting(ByVal e As System.Windows.Forms.TabControlCancelEventArgs)
  104.         If DisabledTabList.Contains(e.TabPageIndex) = True Then e.Cancel = True
  105.         MyBase.OnSelecting(e)
  106.     End Sub
  107.  
  108.     Private Function DisabledTabList() As List(Of Integer)
  109.         Dim l As New List(Of Integer)
  110.         If IsNumeric(DisableTabIndex.Replace(":", Nothing)) = False Then Return l
  111.         Try
  112.             Dim x As Integer = 0
  113.             Do
  114.                 l.Add(DisableTabIndex.Split(":")(x))
  115.                 x += 1
  116.             Loop
  117.         Catch
  118.         End Try
  119.         Return l
  120.     End Function
  121.  
  122.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  123.         _MOUSEPOS.X = e.X
  124.         _MOUSEPOS.Y = e.Y
  125.         MyBase.OnMouseMove(e)
  126.     End Sub
  127.  
  128.     Private Function IsMouseOver(ByVal r As Rectangle) As Boolean
  129.         If _MOUSEPOS.X >= r.X And _MOUSEPOS.Y >= r.Y And _MOUSEPOS.X < (r.Width + r.X) And _MOUSEPOS.Y < (r.Height + r.Y) Then
  130.             Return True
  131.         Else
  132.             Return False
  133.         End If
  134.     End Function
  135. #End Region
  136.  
  137.     Protected Overrides Sub CreateHandle()
  138.         MyBase.CreateHandle()
  139.         Alignment = TabAlignment.Top
  140.     End Sub
  141.  
  142.     Sub New()
  143.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  144.          ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  145.         DoubleBuffered = True
  146.  
  147.         ShowBorders = True
  148.         HighlightTab = True
  149.  
  150.         DisableTabIndex = "example: '0:1'"
  151.         BackColor = Color.White
  152.         BGColor = Color.FromArgb(75, 75, 75)
  153.         Font = New Font("Segoe UI", 9)
  154.         SizeMode = TabSizeMode.FillToRight
  155.         ItemSize = New Size(140, 47)
  156.     End Sub
  157.  
  158.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  159.         Dim B As New Bitmap(Width, Height)
  160.         Dim G As Graphics = Graphics.FromImage(B)
  161.  
  162.         G.Clear(Color.White)
  163.         G.SmoothingMode = SmoothingMode.HighQuality
  164.  
  165.         G.FillRectangle(New SolidBrush(BGColor), New Rectangle(-1, -1, Width + 1, ItemSize.Height - 6))
  166.  
  167.         G.DrawLine(New Pen(BC, 2), New Point(-1, ItemSize.Height - 6), New Point(Width, ItemSize.Height - 6))
  168.  
  169.         If ShowBorders = True Then
  170.             G.DrawLine(New Pen(BC, 3), New Point(1, ItemSize.Height - 6), New Point(1, Height))
  171.             G.DrawLine(New Pen(BC, 3), New Point(1, Height - 2), New Point(Width, Height - 2))
  172.             G.DrawLine(New Pen(BC, 3), New Point(Width - 2, Height - 2), New Point(Width - 2, ItemSize.Height - 6))
  173.         End If
  174.  
  175.         For i = 0 To TabCount - 1
  176.  
  177.             Dim Base As Rectangle = GetTabRect(i)
  178.             Dim Custom As Rectangle = Base
  179.  
  180.             Custom.Width -= 2
  181.             Custom.Height -= 10
  182.             Custom.Y += 1
  183.             Custom.X += 1
  184.  
  185.             Dim P As New GraphicsPath
  186.             Dim PS As New List(Of Point)
  187.  
  188.             PS.Add(New Point(Custom.X + 3, Custom.Y))
  189.             PS.Add(New Point(Custom.X + Custom.Width - 3, Custom.Y))
  190.             PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + 3))
  191.  
  192.             If DisabledTabList.Contains(i) = True Then
  193.                 PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height))
  194.                 PS.Add(New Point(Custom.X, Custom.Y + Custom.Height))
  195.                 PS.Add(New Point(Custom.X, Custom.Y + 3))
  196.  
  197.                 P.AddPolygon(PS.ToArray)
  198.                 Dim BR As New LinearGradientBrush(New Rectangle(0, 0, ItemSize.Width, ItemSize.Height), Color.FromArgb(57, 139, 154), Color.FromArgb(21, 122, 144), 90S)
  199.                 G.FillPath(BR, P)
  200.  
  201.                 Custom.Height += 3
  202.                 G.DrawString(Space(0) & TabPages(i).Text.ToUpper & Space(6), Font, New SolidBrush(Color.FromArgb(153, 153, 153)), Custom, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  203.                 GoTo 1
  204.             End If
  205.  
  206.             If i = SelectedIndex Then
  207. 2:
  208.                 LSI = i
  209.                 Custom.Height -= 1
  210.  
  211.                 PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height + 2))
  212.                 PS.Add(New Point((Custom.X + (Custom.Width / 2)) + 8, Custom.Y + Custom.Height + 2))
  213.                 PS.Add(New Point((Custom.X + (Custom.Width / 2)), Custom.Y + Custom.Height + 9))
  214.                 PS.Add(New Point((Custom.X + (Custom.Width / 2)) - 8, Custom.Y + Custom.Height + 2))
  215.                 PS.Add(New Point(Custom.X, Custom.Y + Custom.Height + 2))
  216.                 PS.Add(New Point(Custom.X, Custom.Y + 3))
  217.  
  218.                 P.AddPolygon(PS.ToArray)
  219.  
  220.                 Dim BR As New LinearGradientBrush(New Rectangle(0, 0, ItemSize.Width, ItemSize.Height + 7), Color.White, Color.FromArgb(235, 236, 237), 90S)
  221.                 G.FillPath(BR, P)
  222.  
  223.                 Dim L As New List(Of Point)
  224.                 L.Add(New Point(Custom.X + Custom.Width - 1, Custom.Y + 4))
  225.                 L.Add(New Point(Custom.X + Custom.Width - 1, Custom.Y + Custom.Height + 1))
  226.                 L.Add(New Point((Custom.X + (Custom.Width / 2)) + 7, Custom.Y + Custom.Height + 1))
  227.                 L.Add(New Point((Custom.X + (Custom.Width / 2)), Custom.Y + Custom.Height + 8))
  228.                 L.Add(New Point((Custom.X + (Custom.Width / 2)) - 7, Custom.Y + Custom.Height + 1))
  229.                 L.Add(New Point(Custom.X + 1, Custom.Y + Custom.Height + 1))
  230.                 L.Add(New Point(Custom.X + 1, Custom.Y + 4))
  231.  
  232.                 G.DrawLines(New Pen(New SolidBrush(AC), 2), L.ToArray)
  233.  
  234.                 L.Clear()
  235.  
  236.                 L.Add(New Point(Custom.X, Custom.Y + Custom.Height + 3))
  237.                 L.Add(New Point((Custom.X + (Custom.Width / 2)) - 8, Custom.Y + Custom.Height + 3))
  238.                 L.Add(New Point((Custom.X + (Custom.Width / 2)), Custom.Y + Custom.Height + 10))
  239.                 L.Add(New Point((Custom.X + (Custom.Width / 2)) + 8, Custom.Y + Custom.Height + 3))
  240.                 L.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height + 3))
  241.  
  242.                 G.DrawLines(New Pen(New SolidBrush(AC), 2), L.ToArray)
  243.                 G.DrawLines(New Pen(New SolidBrush(Color.FromArgb(20, Color.Black))), L.ToArray)
  244.                 G.DrawLines(New Pen(New SolidBrush(Color.FromArgb(10, Color.Black)), 4), L.ToArray)
  245.  
  246.                 Custom.Height += 3
  247.                 G.DrawString(Space(0) & TabPages(i).Text.ToUpper & Space(6), Font, New SolidBrush(Color.FromArgb(75, 75, 75)), Custom, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  248.             Else
  249.  
  250.                 For Each k In DisabledTabList()
  251.                     If k > TabCount - 1 Then Exit For
  252.                     If IsMouseOver(GetTabRect(k)) = True And LSI = i Then
  253.                         GoTo 2
  254.                     End If
  255.                 Next
  256.  
  257.                 PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height))
  258.                 PS.Add(New Point(Custom.X, Custom.Y + Custom.Height))
  259.                 PS.Add(New Point(Custom.X, Custom.Y + 3))
  260.  
  261.                 P.AddPolygon(PS.ToArray)
  262.  
  263.                 Dim BR As New LinearGradientBrush(New Rectangle(0, 0, ItemSize.Width, ItemSize.Height), Color.FromArgb(79, 198, 219), Color.FromArgb(32, 175, 206), 90S)
  264.                 If IsMouseOver(Base) = True And MOUSE_STATE = MouseState.Over And HighlightTab = True Then BR = New LinearGradientBrush(New Rectangle(0, 0, ItemSize.Width, ItemSize.Height), Color.FromArgb(135, 215, 230), Color.FromArgb(109, 203, 223), 90S)
  265.  
  266.                 G.FillPath(BR, P)
  267.  
  268.                 Custom.Height += 3
  269.                 G.DrawString(Space(0) & TabPages(i).Text.ToUpper & Space(6), Font, New SolidBrush(AC), Custom, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  270.             End If
  271. 1:
  272.         Next
  273.  
  274.         e.Graphics.DrawImage(B.Clone, 0, 0)
  275.         G.Dispose()
  276.         B.Dispose()
  277.         MyBase.OnPaint(e)
  278.     End Sub
  279.  
  280. End Class
  281.  
  282. Class KoboTabControlS
  283.     Inherits TabControl
  284.  
  285. #Region "Properties | TabControl"
  286.     Private _BGColor As Color = Color.White
  287.     Public Property BGColor() As Color
  288.         Get
  289.             Return _BGColor
  290.         End Get
  291.         Set(ByVal v As Color)
  292.             _BGColor = v
  293.             Invalidate()
  294.         End Set
  295.     End Property
  296. #End Region
  297.  
  298. #Region "Variables | Colors"
  299.     Private TC As Color = Color.FromArgb(64, 64, 64) 'TEXT COLOR
  300.    Private AC As Color = Color.FromArgb(232, 232, 232) 'ACTIVE COLOR
  301. #End Region
  302.  
  303. #Region "Functions | Create round"
  304.     Private Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  305.         Dim CreateRoundPath As GraphicsPath
  306.  
  307.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  308.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  309.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  310.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  311.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  312.         CreateRoundPath.CloseFigure()
  313.         Return CreateRoundPath
  314.     End Function
  315. #End Region
  316.  
  317.     Protected Overrides Sub CreateHandle()
  318.         MyBase.CreateHandle()
  319.         Alignment = TabAlignment.Top
  320.     End Sub
  321.  
  322.     Sub New()
  323.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  324.          ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  325.         DoubleBuffered = True
  326.  
  327.         Dock = DockStyle.Top
  328.  
  329.         BGColor = Color.White
  330.         Font = New Font("Segoe UI", 9)
  331.         SizeMode = TabSizeMode.FillToRight
  332.         ItemSize = New Size(120, 30)
  333.     End Sub
  334.  
  335.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  336.  
  337.         Dim B As New Bitmap(Width, Height)
  338.         Dim G As Graphics = Graphics.FromImage(B)
  339.         G.Clear(BGColor)
  340.  
  341.         G.SmoothingMode = SmoothingMode.HighQuality
  342.  
  343.         Dim BR As New LinearGradientBrush(New Rectangle(-1, 0, Width, 5), Color.FromArgb(30, Color.Black), BGColor, 90S)
  344.         G.FillRectangle(BR, New Rectangle(-1, ItemSize.Height - 5, Width, 5))
  345.  
  346.         For i = 0 To TabCount - 1
  347.  
  348.             Dim Base As Rectangle = GetTabRect(i)
  349.             Dim Custom As Rectangle = Base
  350.  
  351.             Custom.Y -= 2
  352.             Custom.Height -= 12
  353.  
  354.             If i = SelectedIndex Then
  355.                 Dim GP As New GraphicsPath
  356.                 GP = CreateRound(Custom, 10)
  357.                 G.FillPath(New SolidBrush(AC), GP)
  358.  
  359.             Else
  360.                 G.FillRectangle(New SolidBrush(BGColor), Custom)
  361.  
  362.             End If
  363.  
  364.             G.DrawString(TabPages(i).Text.ToUpper, Font, New SolidBrush(TC), Custom, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  365.         Next
  366.  
  367.         e.Graphics.DrawImage(B.Clone, 0, 0)
  368.         G.Dispose()
  369.         B.Dispose()
  370.         MyBase.OnPaint(e)
  371.     End Sub
  372.  
  373. End Class
  374.  
  375. Class KoboButton
  376.     Inherits ThemeControl154
  377.  
  378. #Region "Properties | Button"
  379.     Private _TextUpper As Boolean = True
  380.     Public Property TextUpper() As Boolean
  381.         Get
  382.             Return _TextUpper
  383.         End Get
  384.         Set(ByVal v As Boolean)
  385.             _TextUpper = v
  386.             Invalidate()
  387.         End Set
  388.     End Property
  389. #End Region
  390.  
  391. #Region "Variables | Colors"
  392.     Private WL As Color = Color.FromArgb(55, Color.White) 'WHITE LINE
  393.    Private SC As Color = Color.FromArgb(31, 147, 174) 'SURROUND COLOR
  394.    Private TC As Color = Color.White 'TEXT COLOR
  395. #End Region
  396.  
  397. #Region "Themebase | DrawTheText functions"
  398.     Private DrawTextPoint As Point
  399.     Private DrawTextSize As Size
  400.  
  401.     Protected Sub DrawTheText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer, Optional ByVal Upper As Boolean = False)
  402.         DrawTheText(b1, Text, a, x, y, Upper)
  403.     End Sub
  404.     Protected Sub DrawTheText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer, Optional ByVal Upper As Boolean = False)
  405.         If text.Length = 0 Then Return
  406.         If Upper = True Then text = text.ToUpper
  407.  
  408.         DrawTextSize = Measure(text)
  409.         DrawTextPoint = Center(DrawTextSize)
  410.  
  411.         Select Case a
  412.             Case HorizontalAlignment.Left
  413.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  414.             Case HorizontalAlignment.Center
  415.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  416.             Case HorizontalAlignment.Right
  417.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  418.         End Select
  419.     End Sub
  420.  
  421.     Protected Sub DrawTheText(ByVal b1 As Brush, ByVal p1 As Point)
  422.         If Text.Length = 0 Then Return
  423.         G.DrawString(Text, Font, b1, p1)
  424.     End Sub
  425.     Protected Sub DrawTheText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  426.         If Text.Length = 0 Then Return
  427.         G.DrawString(Text, Font, b1, x, y)
  428.     End Sub
  429.  
  430. #End Region
  431.  
  432.     Sub New()
  433.         Font = New Font("Segoe UI", 9)
  434.         TextUpper = True
  435.     End Sub
  436.  
  437.     Protected Overrides Sub ColorHook()
  438.  
  439.     End Sub
  440.  
  441.     Protected Overrides Sub PaintHook()
  442.         G.SmoothingMode = SmoothingMode.HighQuality
  443.         G.Clear(BackColor)
  444.  
  445.         Select Case State
  446.             Case MouseState.None
  447.                 Dim BR As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(37, 191, 208), Color.FromArgb(29, 174, 198), 90.0F)
  448.                 Dim GP As GraphicsPath = CreateRound(0, 1, Width - 2, Height - 2, 5)
  449.  
  450.                 G.FillPath(BR, GP)
  451.                 G.DrawPath(New Pen(SC), GP)
  452.                 G.DrawLine(New Pen(WL, 2), New Point(2, 2), New Point(Width - 2, 2))
  453.  
  454.             Case MouseState.Over
  455.                 Dim BR As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(69, 200, 214), Color.FromArgb(63, 186, 206), 90.0F)
  456.                 Dim GP As GraphicsPath = CreateRound(0, 1, Width - 2, Height - 2, 5)
  457.  
  458.                 G.FillPath(BR, GP)
  459.                 G.DrawPath(New Pen(SC), GP)
  460.                 G.DrawLine(New Pen(WL, 2), New Point(2, 2), New Point(Width - 2, 2))
  461.  
  462.             Case MouseState.Down
  463.                 Dim BR As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 190, 214), Color.FromArgb(29, 174, 198), 90.0F)
  464.                 Dim GP As GraphicsPath = CreateRound(0, 1, Width - 2, Height - 2, 5)
  465.  
  466.                 G.FillPath(BR, GP)
  467.                 G.DrawPath(New Pen(SC), GP)
  468.                 G.DrawLine(New Pen(WL, 2), New Point(2, 2), New Point(Width - 2, 2))
  469.  
  470.         End Select
  471.  
  472.         DrawTheText(New SolidBrush(TC), HorizontalAlignment.Center, 0, 0, True)
  473.     End Sub
  474.  
  475. End Class
  476.  
  477. Class KoboProgressBar
  478.     Inherits Control
  479.  
  480. #Region "Variables | Colors, Integer"
  481.     Private LC As Color = Color.FromArgb(32, 175, 206) 'LINE COLOR
  482.    Private APBC As Color = Color.FromArgb(177, 58, 134) 'ACTIVE PROGRESSBAR COLOR
  483.    Private BPBC As Color = Color.FromArgb(56, 56, 56) 'BACK PROGRESSBAR COLOR
  484.    Private PROGRESS As Integer
  485. #End Region
  486.  
  487. #Region "Properties | ProgressBar"
  488.     Private _Minimum As Integer
  489.     Property Minimum() As Integer
  490.         Get
  491.             Return _Minimum
  492.         End Get
  493.         Set(ByVal value As Integer)
  494.             If value < 0 Then
  495.                 Throw New Exception("Property value is not valid.")
  496.             End If
  497.  
  498.             _Minimum = value
  499.             If value > _Value Then _Value = value
  500.             If value > _Maximum Then _Maximum = value
  501.             Invalidate()
  502.         End Set
  503.     End Property
  504.  
  505.     Private _Maximum As Integer = 100
  506.     Property Maximum() As Integer
  507.         Get
  508.             Return _Maximum
  509.         End Get
  510.         Set(ByVal value As Integer)
  511.             If value < 0 Then
  512.                 Throw New Exception("Property value is not valid.")
  513.             End If
  514.  
  515.             _Maximum = value
  516.             If value < _Value Then _Value = value
  517.             If value < _Minimum Then _Minimum = value
  518.             Invalidate()
  519.         End Set
  520.     End Property
  521.  
  522.     Private _Value As Integer
  523.     Property Value() As Integer
  524.         Get
  525.             Return _Value
  526.         End Get
  527.         Set(ByVal value As Integer)
  528.             If value > _Maximum OrElse value < _Minimum Then
  529.                 Throw New Exception("Property value is not valid.")
  530.             End If
  531.  
  532.             _Value = value
  533.             Invalidate()
  534.         End Set
  535.     End Property
  536.  
  537.     Private _LinesColor As Color
  538.     Public Property LinesColor() As Color
  539.         Get
  540.             Return _LinesColor
  541.         End Get
  542.         Set(ByVal v As Color)
  543.             _LinesColor = v
  544.             Invalidate()
  545.         End Set
  546.     End Property
  547.  
  548.     Private _BGColor As Color = Color.White
  549.     Public Property BGColor() As Color
  550.         Get
  551.             Return _BGColor
  552.         End Get
  553.         Set(ByVal v As Color)
  554.             _BGColor = v
  555.             Invalidate()
  556.         End Set
  557.     End Property
  558.  
  559. #End Region
  560.  
  561.     Sub New()
  562.         SetStyle(DirectCast(139286, ControlStyles), True)
  563.         SetStyle(ControlStyles.Selectable, False)
  564.         BackColor = Nothing
  565.         LinesColor = LC
  566.     End Sub
  567.  
  568.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  569.         Dim G As Graphics = e.Graphics
  570.         G.Clear(BGColor)
  571.  
  572.         Dim R1 As New Rectangle(0, 3, Width, Height - 6)
  573.  
  574.         G.DrawLine(New Pen(LinesColor), New Point(0, 0), New Point(Width - 1, 0))
  575.         G.DrawLine(New Pen(LinesColor), New Point(0, Height - 1), New Point(Width - 1, Height - 1))
  576.  
  577.         G.FillRectangle(New SolidBrush(BPBC), R1)
  578.         G.DrawLine(New Pen(LC), New Point(0, Height - 1), New Point(Width - 1, Height - 1))
  579.  
  580.         PROGRESS = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * Width)
  581.  
  582.         If PROGRESS > 1 Then G.FillRectangle(New SolidBrush(APBC), New Rectangle(0, 3, PROGRESS, Height - 6))
  583.     End Sub
  584. End Class
Advertisement
Add Comment
Please, Sign In to add comment