Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '--------------------- [ THEME ] ---------------------
- 'Name: Kobo theme
- 'Creator: Ashlanfox
- 'Contact: Ashlanfox (Skype)
- 'Created: 27.07.2014
- 'Changed: 02.08.2014
- 'Thanks to: Aeonhack (theme base), ibennz (progressbar example) and iSynthesis (tabcontrol example)!
- 'Inspirated of: Kobo desktop
- '-------------------- [ /THEME ] ---------------------
- Class KoboTheme
- Inherits ThemeContainer154
- #Region "Variables | Colors"
- Private BGC As Color = Color.FromArgb(75, 75, 75) 'BACKGROUND COLOR
- Private LC As Color = Color.FromArgb(32, 175, 206) 'LINE COLOR
- #End Region
- Sub New()
- BackColor = Color.FromArgb(75, 75, 75)
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(BGC)
- G.DrawLine(New Pen(New SolidBrush(LC), 2), 0, 50, Width, 50)
- End Sub
- End Class
- Class KoboTabControlB
- Inherits TabControl
- #Region "Properties | TabControl"
- Private _HighlightTab As Boolean = True
- Public Property HighlightTab() As Boolean
- Get
- Return _HighlightTab
- End Get
- Set(ByVal v As Boolean)
- _HighlightTab = v
- Invalidate()
- End Set
- End Property
- Private _ShowBorders As Boolean = False
- Public Property ShowBorders() As Boolean
- Get
- Return _ShowBorders
- End Get
- Set(ByVal v As Boolean)
- _ShowBorders = v
- Invalidate()
- End Set
- End Property
- Private _DisableTabIndex As String
- Public Property DisableTabIndex() As String
- Get
- Return _DisableTabIndex
- End Get
- Set(ByVal v As String)
- _DisableTabIndex = v
- Invalidate()
- End Set
- End Property
- Private _BGColor As Color = Color.FromArgb(75, 75, 75)
- Public Property BGColor() As Color
- Get
- Return _BGColor
- End Get
- Set(ByVal v As Color)
- _BGColor = v
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Variables | Colors, Integer, Point"
- Private BC As Color = Color.FromArgb(32, 175, 206) 'BACK COLOR
- Private AC As Color = Color.White 'ACTIVE COLOR
- Private _MOUSEPOS As Point
- Private LSI As Integer 'LAST SELECTED INDEX
- Private MOUSE_STATE As MouseState
- #End Region
- #Region "Functions | Disabled tab page(s)"
- Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
- MOUSE_STATE = MouseState.None
- _MOUSEPOS.X = New Integer
- _MOUSEPOS.Y = New Integer
- MyBase.OnMouseLeave(e)
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
- MOUSE_STATE = MouseState.Over
- MyBase.OnMouseEnter(e)
- End Sub
- Protected Overrides Sub OnSelecting(ByVal e As System.Windows.Forms.TabControlCancelEventArgs)
- If DisabledTabList.Contains(e.TabPageIndex) = True Then e.Cancel = True
- MyBase.OnSelecting(e)
- End Sub
- Private Function DisabledTabList() As List(Of Integer)
- Dim l As New List(Of Integer)
- If IsNumeric(DisableTabIndex.Replace(":", Nothing)) = False Then Return l
- Try
- Dim x As Integer = 0
- Do
- l.Add(DisableTabIndex.Split(":")(x))
- x += 1
- Loop
- Catch
- End Try
- Return l
- End Function
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- _MOUSEPOS.X = e.X
- _MOUSEPOS.Y = e.Y
- MyBase.OnMouseMove(e)
- End Sub
- Private Function IsMouseOver(ByVal r As Rectangle) As Boolean
- 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
- Return True
- Else
- Return False
- End If
- End Function
- #End Region
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Alignment = TabAlignment.Top
- End Sub
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- ShowBorders = True
- HighlightTab = True
- DisableTabIndex = "example: '0:1'"
- BackColor = Color.White
- BGColor = Color.FromArgb(75, 75, 75)
- Font = New Font("Segoe UI", 9)
- SizeMode = TabSizeMode.FillToRight
- ItemSize = New Size(140, 47)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim B As New Bitmap(Width, Height)
- Dim G As Graphics = Graphics.FromImage(B)
- G.Clear(Color.White)
- G.SmoothingMode = SmoothingMode.HighQuality
- G.FillRectangle(New SolidBrush(BGColor), New Rectangle(-1, -1, Width + 1, ItemSize.Height - 6))
- G.DrawLine(New Pen(BC, 2), New Point(-1, ItemSize.Height - 6), New Point(Width, ItemSize.Height - 6))
- If ShowBorders = True Then
- G.DrawLine(New Pen(BC, 3), New Point(1, ItemSize.Height - 6), New Point(1, Height))
- G.DrawLine(New Pen(BC, 3), New Point(1, Height - 2), New Point(Width, Height - 2))
- G.DrawLine(New Pen(BC, 3), New Point(Width - 2, Height - 2), New Point(Width - 2, ItemSize.Height - 6))
- End If
- For i = 0 To TabCount - 1
- Dim Base As Rectangle = GetTabRect(i)
- Dim Custom As Rectangle = Base
- Custom.Width -= 2
- Custom.Height -= 10
- Custom.Y += 1
- Custom.X += 1
- Dim P As New GraphicsPath
- Dim PS As New List(Of Point)
- PS.Add(New Point(Custom.X + 3, Custom.Y))
- PS.Add(New Point(Custom.X + Custom.Width - 3, Custom.Y))
- PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + 3))
- If DisabledTabList.Contains(i) = True Then
- PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height))
- PS.Add(New Point(Custom.X, Custom.Y + Custom.Height))
- PS.Add(New Point(Custom.X, Custom.Y + 3))
- P.AddPolygon(PS.ToArray)
- Dim BR As New LinearGradientBrush(New Rectangle(0, 0, ItemSize.Width, ItemSize.Height), Color.FromArgb(57, 139, 154), Color.FromArgb(21, 122, 144), 90S)
- G.FillPath(BR, P)
- Custom.Height += 3
- 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})
- GoTo 1
- End If
- If i = SelectedIndex Then
- 2:
- LSI = i
- Custom.Height -= 1
- PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height + 2))
- PS.Add(New Point((Custom.X + (Custom.Width / 2)) + 8, Custom.Y + Custom.Height + 2))
- PS.Add(New Point((Custom.X + (Custom.Width / 2)), Custom.Y + Custom.Height + 9))
- PS.Add(New Point((Custom.X + (Custom.Width / 2)) - 8, Custom.Y + Custom.Height + 2))
- PS.Add(New Point(Custom.X, Custom.Y + Custom.Height + 2))
- PS.Add(New Point(Custom.X, Custom.Y + 3))
- P.AddPolygon(PS.ToArray)
- Dim BR As New LinearGradientBrush(New Rectangle(0, 0, ItemSize.Width, ItemSize.Height + 7), Color.White, Color.FromArgb(235, 236, 237), 90S)
- G.FillPath(BR, P)
- Dim L As New List(Of Point)
- L.Add(New Point(Custom.X + Custom.Width - 1, Custom.Y + 4))
- L.Add(New Point(Custom.X + Custom.Width - 1, Custom.Y + Custom.Height + 1))
- L.Add(New Point((Custom.X + (Custom.Width / 2)) + 7, Custom.Y + Custom.Height + 1))
- L.Add(New Point((Custom.X + (Custom.Width / 2)), Custom.Y + Custom.Height + 8))
- L.Add(New Point((Custom.X + (Custom.Width / 2)) - 7, Custom.Y + Custom.Height + 1))
- L.Add(New Point(Custom.X + 1, Custom.Y + Custom.Height + 1))
- L.Add(New Point(Custom.X + 1, Custom.Y + 4))
- G.DrawLines(New Pen(New SolidBrush(AC), 2), L.ToArray)
- L.Clear()
- L.Add(New Point(Custom.X, Custom.Y + Custom.Height + 3))
- L.Add(New Point((Custom.X + (Custom.Width / 2)) - 8, Custom.Y + Custom.Height + 3))
- L.Add(New Point((Custom.X + (Custom.Width / 2)), Custom.Y + Custom.Height + 10))
- L.Add(New Point((Custom.X + (Custom.Width / 2)) + 8, Custom.Y + Custom.Height + 3))
- L.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height + 3))
- G.DrawLines(New Pen(New SolidBrush(AC), 2), L.ToArray)
- G.DrawLines(New Pen(New SolidBrush(Color.FromArgb(20, Color.Black))), L.ToArray)
- G.DrawLines(New Pen(New SolidBrush(Color.FromArgb(10, Color.Black)), 4), L.ToArray)
- Custom.Height += 3
- 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})
- Else
- For Each k In DisabledTabList()
- If k > TabCount - 1 Then Exit For
- If IsMouseOver(GetTabRect(k)) = True And LSI = i Then
- GoTo 2
- End If
- Next
- PS.Add(New Point(Custom.X + Custom.Width, Custom.Y + Custom.Height))
- PS.Add(New Point(Custom.X, Custom.Y + Custom.Height))
- PS.Add(New Point(Custom.X, Custom.Y + 3))
- P.AddPolygon(PS.ToArray)
- Dim BR As New LinearGradientBrush(New Rectangle(0, 0, ItemSize.Width, ItemSize.Height), Color.FromArgb(79, 198, 219), Color.FromArgb(32, 175, 206), 90S)
- 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)
- G.FillPath(BR, P)
- Custom.Height += 3
- G.DrawString(Space(0) & TabPages(i).Text.ToUpper & Space(6), Font, New SolidBrush(AC), Custom, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- 1:
- Next
- e.Graphics.DrawImage(B.Clone, 0, 0)
- G.Dispose()
- B.Dispose()
- MyBase.OnPaint(e)
- End Sub
- End Class
- Class KoboTabControlS
- Inherits TabControl
- #Region "Properties | TabControl"
- Private _BGColor As Color = Color.White
- Public Property BGColor() As Color
- Get
- Return _BGColor
- End Get
- Set(ByVal v As Color)
- _BGColor = v
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Variables | Colors"
- Private TC As Color = Color.FromArgb(64, 64, 64) 'TEXT COLOR
- Private AC As Color = Color.FromArgb(232, 232, 232) 'ACTIVE COLOR
- #End Region
- #Region "Functions | Create round"
- Private Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
- Dim CreateRoundPath As GraphicsPath
- CreateRoundPath = New GraphicsPath(FillMode.Winding)
- CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
- CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
- CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
- CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
- CreateRoundPath.CloseFigure()
- Return CreateRoundPath
- End Function
- #End Region
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Alignment = TabAlignment.Top
- End Sub
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- Dock = DockStyle.Top
- BGColor = Color.White
- Font = New Font("Segoe UI", 9)
- SizeMode = TabSizeMode.FillToRight
- ItemSize = New Size(120, 30)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim B As New Bitmap(Width, Height)
- Dim G As Graphics = Graphics.FromImage(B)
- G.Clear(BGColor)
- G.SmoothingMode = SmoothingMode.HighQuality
- Dim BR As New LinearGradientBrush(New Rectangle(-1, 0, Width, 5), Color.FromArgb(30, Color.Black), BGColor, 90S)
- G.FillRectangle(BR, New Rectangle(-1, ItemSize.Height - 5, Width, 5))
- For i = 0 To TabCount - 1
- Dim Base As Rectangle = GetTabRect(i)
- Dim Custom As Rectangle = Base
- Custom.Y -= 2
- Custom.Height -= 12
- If i = SelectedIndex Then
- Dim GP As New GraphicsPath
- GP = CreateRound(Custom, 10)
- G.FillPath(New SolidBrush(AC), GP)
- Else
- G.FillRectangle(New SolidBrush(BGColor), Custom)
- End If
- G.DrawString(TabPages(i).Text.ToUpper, Font, New SolidBrush(TC), Custom, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Next
- e.Graphics.DrawImage(B.Clone, 0, 0)
- G.Dispose()
- B.Dispose()
- MyBase.OnPaint(e)
- End Sub
- End Class
- Class KoboButton
- Inherits ThemeControl154
- #Region "Properties | Button"
- Private _TextUpper As Boolean = True
- Public Property TextUpper() As Boolean
- Get
- Return _TextUpper
- End Get
- Set(ByVal v As Boolean)
- _TextUpper = v
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Variables | Colors"
- Private WL As Color = Color.FromArgb(55, Color.White) 'WHITE LINE
- Private SC As Color = Color.FromArgb(31, 147, 174) 'SURROUND COLOR
- Private TC As Color = Color.White 'TEXT COLOR
- #End Region
- #Region "Themebase | DrawTheText functions"
- Private DrawTextPoint As Point
- Private DrawTextSize As Size
- 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)
- DrawTheText(b1, Text, a, x, y, Upper)
- End Sub
- 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)
- If text.Length = 0 Then Return
- If Upper = True Then text = text.ToUpper
- DrawTextSize = Measure(text)
- DrawTextPoint = Center(DrawTextSize)
- Select Case a
- Case HorizontalAlignment.Left
- G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
- Case HorizontalAlignment.Center
- G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
- Case HorizontalAlignment.Right
- G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
- End Select
- End Sub
- Protected Sub DrawTheText(ByVal b1 As Brush, ByVal p1 As Point)
- If Text.Length = 0 Then Return
- G.DrawString(Text, Font, b1, p1)
- End Sub
- Protected Sub DrawTheText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
- If Text.Length = 0 Then Return
- G.DrawString(Text, Font, b1, x, y)
- End Sub
- #End Region
- Sub New()
- Font = New Font("Segoe UI", 9)
- TextUpper = True
- End Sub
- Protected Overrides Sub ColorHook()
- End Sub
- Protected Overrides Sub PaintHook()
- G.SmoothingMode = SmoothingMode.HighQuality
- G.Clear(BackColor)
- Select Case State
- Case MouseState.None
- 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)
- Dim GP As GraphicsPath = CreateRound(0, 1, Width - 2, Height - 2, 5)
- G.FillPath(BR, GP)
- G.DrawPath(New Pen(SC), GP)
- G.DrawLine(New Pen(WL, 2), New Point(2, 2), New Point(Width - 2, 2))
- Case MouseState.Over
- 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)
- Dim GP As GraphicsPath = CreateRound(0, 1, Width - 2, Height - 2, 5)
- G.FillPath(BR, GP)
- G.DrawPath(New Pen(SC), GP)
- G.DrawLine(New Pen(WL, 2), New Point(2, 2), New Point(Width - 2, 2))
- Case MouseState.Down
- 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)
- Dim GP As GraphicsPath = CreateRound(0, 1, Width - 2, Height - 2, 5)
- G.FillPath(BR, GP)
- G.DrawPath(New Pen(SC), GP)
- G.DrawLine(New Pen(WL, 2), New Point(2, 2), New Point(Width - 2, 2))
- End Select
- DrawTheText(New SolidBrush(TC), HorizontalAlignment.Center, 0, 0, True)
- End Sub
- End Class
- Class KoboProgressBar
- Inherits Control
- #Region "Variables | Colors, Integer"
- Private LC As Color = Color.FromArgb(32, 175, 206) 'LINE COLOR
- Private APBC As Color = Color.FromArgb(177, 58, 134) 'ACTIVE PROGRESSBAR COLOR
- Private BPBC As Color = Color.FromArgb(56, 56, 56) 'BACK PROGRESSBAR COLOR
- Private PROGRESS As Integer
- #End Region
- #Region "Properties | ProgressBar"
- Private _Minimum As Integer
- Property Minimum() As Integer
- Get
- Return _Minimum
- End Get
- Set(ByVal value As Integer)
- If value < 0 Then
- Throw New Exception("Property value is not valid.")
- End If
- _Minimum = value
- If value > _Value Then _Value = value
- If value > _Maximum Then _Maximum = value
- Invalidate()
- End Set
- End Property
- Private _Maximum As Integer = 100
- Property Maximum() As Integer
- Get
- Return _Maximum
- End Get
- Set(ByVal value As Integer)
- If value < 0 Then
- Throw New Exception("Property value is not valid.")
- End If
- _Maximum = value
- If value < _Value Then _Value = value
- If value < _Minimum Then _Minimum = value
- Invalidate()
- End Set
- End Property
- Private _Value As Integer
- Property Value() As Integer
- Get
- Return _Value
- End Get
- Set(ByVal value As Integer)
- If value > _Maximum OrElse value < _Minimum Then
- Throw New Exception("Property value is not valid.")
- End If
- _Value = value
- Invalidate()
- End Set
- End Property
- Private _LinesColor As Color
- Public Property LinesColor() As Color
- Get
- Return _LinesColor
- End Get
- Set(ByVal v As Color)
- _LinesColor = v
- Invalidate()
- End Set
- End Property
- Private _BGColor As Color = Color.White
- Public Property BGColor() As Color
- Get
- Return _BGColor
- End Get
- Set(ByVal v As Color)
- _BGColor = v
- Invalidate()
- End Set
- End Property
- #End Region
- Sub New()
- SetStyle(DirectCast(139286, ControlStyles), True)
- SetStyle(ControlStyles.Selectable, False)
- BackColor = Nothing
- LinesColor = LC
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.Clear(BGColor)
- Dim R1 As New Rectangle(0, 3, Width, Height - 6)
- G.DrawLine(New Pen(LinesColor), New Point(0, 0), New Point(Width - 1, 0))
- G.DrawLine(New Pen(LinesColor), New Point(0, Height - 1), New Point(Width - 1, Height - 1))
- G.FillRectangle(New SolidBrush(BPBC), R1)
- G.DrawLine(New Pen(LC), New Point(0, Height - 1), New Point(Width - 1, Height - 1))
- PROGRESS = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * Width)
- If PROGRESS > 1 Then G.FillRectangle(New SolidBrush(APBC), New Rectangle(0, 3, PROGRESS, Height - 6))
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment