Advertisement
Yamatano

MetroTheme 1.0

Jul 30th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Thanks to Aeonhack and other
  2. 'You need paste here ThemeBase 1.5.4, then delete first two lines
  3. 'VERSION 1.0, 30.07.2015   
  4. Imports System.Drawing.Drawing2D
  5. Imports System.ComponentModel
  6. Class MetroButton
  7.     Inherits ThemeControl154
  8.     Sub New()
  9.         Height = 45
  10.         Width = 120
  11.         SetColor("ButtonColor", Color.Black)
  12.         SetColor("TextColor", Color.White)
  13.         Font = New Font("Segoe UI", 12)
  14.     End Sub
  15.     Dim buttonc As Color
  16.     Dim textc As Brush
  17.     Protected Overrides Sub ColorHook()
  18.         buttonc = GetColor("ButtonColor")
  19.         textc = GetBrush("TextColor")
  20.     End Sub
  21.     Protected Overrides Sub PaintHook()
  22.         G.Clear(buttonc)
  23.         Select Case State
  24.             Case MouseState.None
  25.                 DrawText(textc, HorizontalAlignment.Center, 0, 0)
  26.             Case MouseState.Over
  27.                 G.FillRectangle(New SolidBrush(Color.FromArgb(25, Color.Black)), New Rectangle(0, 0, Width, Height))
  28.                 DrawText(textc, HorizontalAlignment.Center, 0, 0)
  29.             Case MouseState.Down
  30.                 G.FillRectangle(New SolidBrush(Color.FromArgb(50, Color.Black)), New Rectangle(0, 0, Width, Height))
  31.                 DrawText(textc, HorizontalAlignment.Center, 0, 0)
  32.         End Select
  33.     End Sub
  34. End Class
  35. Class MetroTheme
  36.     Inherits ThemeContainer154
  37.     Sub New()
  38.         TransparencyKey = Color.Fuchsia
  39.         BackColor = Color.White
  40.         Font = New Font("Segoe UI", 10)
  41.         SetColor("BorderColor", Color.Black)
  42.         SetColor("TextColor", Color.White)
  43.     End Sub
  44.     Dim Borderc As Color
  45.     Dim Textc As Brush
  46.     Protected Overrides Sub ColorHook()
  47.         Borderc = GetColor("BorderColor")
  48.         Textc = GetBrush("TextColor")
  49.     End Sub
  50.     Protected Overrides Sub PaintHook()
  51.         G.Clear(Borderc)
  52.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(6, 36, Width - 13, Height - 43))
  53.         G.DrawString(FindForm.Text, Font, Textc, New Point(30, 9))
  54.         G.DrawIcon(FindForm.Icon, New Rectangle(6, 10, 16, 16))
  55.         DrawCorners(Color.Fuchsia)
  56.     End Sub
  57. End Class
  58. Class MetroProgressBar
  59.     Inherits ThemeControl154
  60.     Dim backgroundc As Color
  61.     Dim progressc As Brush
  62.     Dim borderc As Pen
  63.     Private _Maximum As Integer = 100
  64.     Public Property Maximum() As Integer
  65.         Get
  66.             Return _Maximum
  67.         End Get
  68.         Set(ByVal v As Integer)
  69.             If v < 0 Then v = 0
  70.             If v < _Value Then _Value = v
  71.             _Maximum = v
  72.             Invalidate()
  73.         End Set
  74.     End Property
  75.     Private _Value As Integer
  76.     Public Property Value() As Integer
  77.         Get
  78.             Return _Value
  79.         End Get
  80.         Set(ByVal v As Integer)
  81.             If v > _Maximum Then v = _Maximum
  82.             _Value = v
  83.             Invalidate()
  84.         End Set
  85.     End Property
  86.     Sub New()
  87.         SetColor("ProgressColor", Color.Black)
  88.         SetColor("BackgroundColor", Color.White)
  89.         SetColor("BorderColor", Color.Black)
  90.     End Sub
  91.     Protected Overrides Sub ColorHook()
  92.         backgroundc = GetColor("BackgroundColor")
  93.         progressc = GetBrush("ProgressColor")
  94.         borderc = GetPen("BorderColor")
  95.     End Sub
  96.     Protected Overrides Sub PaintHook()
  97.         G.Clear(backgroundc)
  98.         G.FillRectangle(progressc, 0, 0, CInt(_Value / _Maximum * Width), Height)
  99.         G.FillRectangle(progressc, New Rectangle(0, 0, CInt(_Value / _Maximum * Width), Height))
  100.         DrawGradient(Color.FromArgb(0, Color.White), Color.FromArgb(0, Color.White), ClientRectangle)
  101.         DrawBorders(borderc, ClientRectangle)
  102.     End Sub
  103. End Class
  104. <DefaultEvent("TextChanged")>
  105. Class MetroTextBox
  106.     Inherits ThemeControl154
  107.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  108.     Property TextAlign() As HorizontalAlignment
  109.         Get
  110.             Return _TextAlign
  111.         End Get
  112.         Set(ByVal value As HorizontalAlignment)
  113.             _TextAlign = value
  114.             If Base IsNot Nothing Then
  115.                 Base.TextAlign = value
  116.             End If
  117.         End Set
  118.     End Property
  119.     Private _MaxLength As Integer = 32767
  120.     Property MaxLength() As Integer
  121.         Get
  122.             Return _MaxLength
  123.         End Get
  124.         Set(ByVal value As Integer)
  125.             _MaxLength = value
  126.             If Base IsNot Nothing Then
  127.                 Base.MaxLength = value
  128.             End If
  129.         End Set
  130.     End Property
  131.     Private _ReadOnly As Boolean
  132.     Property [ReadOnly]() As Boolean
  133.         Get
  134.             Return _ReadOnly
  135.         End Get
  136.         Set(ByVal value As Boolean)
  137.             _ReadOnly = value
  138.             If Base IsNot Nothing Then
  139.                 Base.ReadOnly = value
  140.             End If
  141.         End Set
  142.     End Property
  143.     Private _UseSystemPasswordChar As Boolean
  144.     Property UseSystemPasswordChar() As Boolean
  145.         Get
  146.             Return _UseSystemPasswordChar
  147.         End Get
  148.         Set(ByVal value As Boolean)
  149.             _UseSystemPasswordChar = value
  150.             If Base IsNot Nothing Then
  151.                 Base.UseSystemPasswordChar = value
  152.             End If
  153.         End Set
  154.     End Property
  155.     Private _Multiline As Boolean
  156.     Property Multiline() As Boolean
  157.         Get
  158.             Return _Multiline
  159.         End Get
  160.         Set(ByVal value As Boolean)
  161.             _Multiline = value
  162.             If Base IsNot Nothing Then
  163.                 Base.Multiline = value
  164.  
  165.                 If value Then
  166.                     LockHeight = 0
  167.                     Base.Height = Height - 11
  168.                 Else
  169.                     LockHeight = Base.Height + 11
  170.                 End If
  171.             End If
  172.         End Set
  173.     End Property
  174.     Overrides Property Text() As String
  175.         Get
  176.             Return MyBase.Text
  177.         End Get
  178.         Set(ByVal value As String)
  179.             MyBase.Text = value
  180.             If Base IsNot Nothing Then
  181.                 Base.Text = value
  182.             End If
  183.         End Set
  184.     End Property
  185.     Overrides Property Font() As Font
  186.         Get
  187.             Return MyBase.Font
  188.         End Get
  189.         Set(ByVal value As Font)
  190.             MyBase.Font = value
  191.             If Base IsNot Nothing Then
  192.                 Base.Font = value
  193.                 Base.Location = New Point(3, 5)
  194.                 Base.Width = Width - 6
  195.                 If Not _Multiline Then
  196.                     LockHeight = Base.Height + 11
  197.                 End If
  198.             End If
  199.         End Set
  200.     End Property
  201.     Protected Overrides Sub OnCreation()
  202.         If Not Controls.Contains(Base) Then
  203.             Controls.Add(Base)
  204.         End If
  205.     End Sub
  206.     Private Base As TextBox
  207.     Sub New()
  208.         Base = New TextBox
  209.         Base.Font = Font
  210.         Base.Text = Text
  211.         Base.MaxLength = _MaxLength
  212.         Base.Multiline = _Multiline
  213.         Base.ReadOnly = _ReadOnly
  214.         Base.UseSystemPasswordChar = _UseSystemPasswordChar
  215.         Base.BorderStyle = BorderStyle.None
  216.         Base.Location = New Point(4, 4)
  217.         Base.Width = Width - 10
  218.         If _Multiline Then
  219.             Base.Height = Height - 11
  220.         Else
  221.             LockHeight = Base.Height + 11
  222.         End If
  223.         AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
  224.         AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
  225.         SetColor("TextColor", Color.Black)
  226.         SetColor("BackgroundColor", Color.White)
  227.         SetColor("BorderColor", Color.Black)
  228.     End Sub
  229.     Private backgroundc As Color
  230.     Private borderc As Pen
  231.     Private textc As Brush
  232.     Protected Overrides Sub ColorHook()
  233.         backgroundc = GetColor("BackgroundColor")
  234.         borderc = GetPen("BorderColor")
  235.         textc = GetBrush("TextColor")
  236.         Base.BackColor = GetColor("BackgroundColor")
  237.         Base.ForeColor = GetColor("TextColor")
  238.     End Sub
  239.     Protected Overrides Sub PaintHook()
  240.         G.Clear(backgroundc)
  241.         DrawBorders(borderc)
  242.     End Sub
  243.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  244.         Text = Base.Text
  245.     End Sub
  246.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  247.         If e.Control AndAlso e.KeyCode = Keys.A Then
  248.             Base.SelectAll()
  249.             e.SuppressKeyPress = True
  250.         End If
  251.     End Sub
  252.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  253.         Base.Location = New Point(4, 5)
  254.         Base.Width = Width - 8
  255.         If _Multiline Then
  256.             Base.Height = Height - 5
  257.         End If
  258.         MyBase.OnResize(e)
  259.     End Sub
  260. End Class
  261. <DefaultEvent("CheckedChanged")>
  262. Class MetroCheckBox
  263.     Inherits ThemeControl154
  264.     Sub New()
  265.         LockHeight = 20
  266.         Width = 120
  267.         SetColor("TextColor", Color.Black)
  268.         SetColor("BackgroundColor", Color.White)
  269.         SetColor("CheckColor", Color.Black)
  270.         SetColor("BorderColor", Color.Black)
  271.         SetColor("CheckBackgroundColor", Color.White)
  272.         Font = New Font("Arial", 12)
  273.     End Sub
  274.     Private X As Integer
  275.     Private textc As Color
  276.     Private backgroundc As Color
  277.     Private checkc As Brush
  278.     Private borderc As Color
  279.     Private checkbackgroundc As Color
  280.     Protected Overrides Sub ColorHook()
  281.         textc = GetColor("TextColor")
  282.         backgroundc = GetColor("BackgroundColor")
  283.         checkc = GetBrush("CheckColor")
  284.         borderc = GetColor("BorderColor")
  285.         checkbackgroundc = GetColor("CheckBackgroundColor")
  286.     End Sub
  287.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  288.         MyBase.OnMouseMove(e)
  289.         X = e.Location.X
  290.         Invalidate()
  291.     End Sub
  292.     Protected Overrides Sub PaintHook()
  293.         G.Clear(backgroundc)
  294.         If _Checked Then
  295.             G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
  296.             G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
  297.         Else
  298.             G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
  299.             G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
  300.         End If
  301.         If State = MouseState.Over And X < 15 Then
  302.             G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
  303.             G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
  304.         ElseIf State = MouseState.Down And X < 15 Then
  305.             G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
  306.             G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
  307.         End If
  308.         If _Checked Then G.DrawString("a", New Font("Marlett", 20), checkc, New Point(-7, -5))
  309.         DrawText(New SolidBrush(textc), HorizontalAlignment.Left, 25, 0)
  310.     End Sub
  311.     Private _Checked As Boolean
  312.     Property Checked() As Boolean
  313.         Get
  314.             Return _Checked
  315.         End Get
  316.         Set(ByVal value As Boolean)
  317.             _Checked = value
  318.             Invalidate()
  319.         End Set
  320.     End Property
  321.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  322.         _Checked = Not _Checked
  323.         RaiseEvent CheckedChanged(Me)
  324.         MyBase.OnMouseDown(e)
  325.     End Sub
  326.     Event CheckedChanged(ByVal sender As Object)
  327. End Class
  328. <DefaultEvent("CheckedChanged")>
  329. Class MetroRadioButton
  330.     Inherits ThemeControl154
  331.     Sub New()
  332.         LockHeight = 20
  333.         SetColor("TextColor", Color.Black)
  334.         SetColor("BackgroundColor", Color.White)
  335.         SetColor("CheckColor", Color.Black)
  336.         SetColor("BorderColor", Color.Black)
  337.         Font = New Font("Segoe UI", 12)
  338.         Width = 120
  339.     End Sub
  340.     Private X As Integer
  341.     Private textc As Color
  342.     Private backgroundc As Color
  343.     Private checkc As Color
  344.     Private borderc As Color
  345.     Protected Overrides Sub ColorHook()
  346.         textc = GetColor("TextColor")
  347.         backgroundc = GetColor("BackgroundColor")
  348.         checkc = GetColor("CheckColor")
  349.         borderc = GetColor("BorderColor")
  350.     End Sub
  351.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  352.         MyBase.OnMouseMove(e)
  353.         X = e.Location.X
  354.         Invalidate()
  355.     End Sub
  356.     Protected Overrides Sub PaintHook()
  357.         G.Clear(backgroundc)
  358.         G.SmoothingMode = SmoothingMode.HighQuality
  359.         If _Checked Then
  360.             G.DrawEllipse(New Pen(borderc), New Rectangle(New Point(0, 0), New Size(20, 20)))
  361.             G.FillEllipse(New SolidBrush(checkc), New Rectangle(New Point(3, 3), New Size(14, 14)))
  362.         Else
  363.             G.DrawEllipse(New Pen(borderc), New Rectangle(New Point(0, 0), New Size(20, 20)))
  364.             DrawText(New SolidBrush(textc), HorizontalAlignment.Left, 22, 0)
  365.         End If
  366.         If _Checked Then DrawText(New SolidBrush(textc), HorizontalAlignment.Left, 22, 0)
  367.     End Sub
  368.     Private _Field As Integer = 21
  369.     Property Field() As Integer
  370.         Get
  371.             Return _Field
  372.         End Get
  373.         Set(ByVal value As Integer)
  374.             If value < 4 Then Return
  375.             _Field = value
  376.             LockHeight = value
  377.             Invalidate()
  378.         End Set
  379.     End Property
  380.     Private _Checked As Boolean
  381.     Property Checked() As Boolean
  382.         Get
  383.             Return _Checked
  384.         End Get
  385.         Set(ByVal value As Boolean)
  386.             _Checked = value
  387.             InvalidateControls()
  388.             RaiseEvent CheckedChanged(Me)
  389.             Invalidate()
  390.         End Set
  391.     End Property
  392.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  393.         If Not _Checked Then Checked = True
  394.         MyBase.OnMouseDown(e)
  395.     End Sub
  396.     Event CheckedChanged(ByVal sender As Object)
  397.     Protected Overrides Sub OnCreation()
  398.         InvalidateControls()
  399.     End Sub
  400.     Private Sub InvalidateControls()
  401.         If Not IsHandleCreated OrElse Not _Checked Then Return
  402.         For Each C As Control In Parent.Controls
  403.             If C IsNot Me AndAlso TypeOf C Is MetroRadioButton Then
  404.                 DirectCast(C, MetroRadioButton).Checked = False
  405.             End If
  406.         Next
  407.     End Sub
  408. End Class
  409. Class MetroGroupBox
  410.     Inherits ThemeContainer154
  411.     Sub New()
  412.         ControlMode = True
  413.         SetColor("BackgroundColor", Color.Black)
  414.         SetColor("InsideBackgroundColor", Color.White)
  415.         SetColor("TextColor", Color.White)
  416.     End Sub
  417.     Dim backgroundc As Color
  418.     Dim insidebackgroundc As Color
  419.     Dim textc As Brush
  420.     Protected Overrides Sub ColorHook()
  421.         backgroundc = GetColor("BackgroundColor")
  422.         insidebackgroundc = GetColor("InsideBackgroundColor")
  423.         textc = GetBrush("TextColor")
  424.     End Sub
  425.     Protected Overrides Sub PaintHook()
  426.         G.Clear(backgroundc)
  427.         G.FillRectangle(New SolidBrush(insidebackgroundc), New Rectangle(1, 25, Width - 2, Height - 26))
  428.         DrawText(textc, HorizontalAlignment.Left, 2, 0)
  429.     End Sub
  430. End Class
  431. Class MetroControls
  432.     Inherits ThemeControl154
  433.     Private X As Integer
  434.     Dim backgroundc As Color
  435.     Dim edgec As Pen
  436.     Dim iconsc As Color
  437.     Dim glowc As SolidBrush
  438.     Dim a, b, c As Integer
  439.     Protected Overrides Sub ColorHook()
  440.         iconsc = GetColor("IconsColor")
  441.         backgroundc = GetColor("BackgroundColor")
  442.     End Sub
  443.     Sub New()
  444.         IsAnimated = True
  445.         SetColor("IconsColor", Color.White)
  446.         SetColor("BackgroundColor", Color.Transparent)
  447.         Me.Size = New Size(84, 18)
  448.         Me.Anchor = AnchorStyles.Top Or AnchorStyles.Right
  449.     End Sub
  450.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  451.         MyBase.OnMouseMove(e)
  452.         X = e.X
  453.         Invalidate()
  454.     End Sub
  455.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  456.         MyBase.OnClick(e)
  457.         If X <= 22 Then
  458.             FindForm.WindowState = FormWindowState.Minimized
  459.         ElseIf X > 22 And X <= 46 Then
  460.             If FindForm.WindowState = FormWindowState.Maximized Then FindForm.WindowState = FormWindowState.Normal Else FindForm.WindowState = FormWindowState.Maximized
  461.         Else
  462.             FindForm.Close()
  463.         End If
  464.     End Sub
  465.     Protected Overrides Sub OnAnimation()
  466.         MyBase.OnAnimation()
  467.         Select Case State
  468.             Case MouseState.Over
  469.                 If a < 24 And X <= 22 Then
  470.                     a += 4
  471.                     If b > 0 Then
  472.                         b -= 4
  473.                     End If
  474.                     If c > 0 Then
  475.                         c -= 4
  476.                     End If
  477.                     If b < 0 Then b = 0
  478.                     If c < 0 Then c = 0
  479.                     Invalidate()
  480.                     Application.DoEvents()
  481.                 End If
  482.                 If b < 24 And X > 22 And X <= 46 Then
  483.                     b += 4
  484.                     If a > 0 Then
  485.                         a -= 4
  486.                     End If
  487.                     If a < 0 Then a = 0
  488.                     If c > 0 Then
  489.                         c -= 4
  490.                     End If
  491.                     If c < 0 Then c = 0
  492.                     Invalidate()
  493.                     Application.DoEvents()
  494.                 End If
  495.                 If c < 32 And X > 46 Then
  496.                     c += 4
  497.                     If a > 0 Then
  498.                         a -= 4
  499.                     End If
  500.                     If b > 0 Then
  501.                         b -= 4
  502.                     End If
  503.                     If a < 0 Then a = 0
  504.                     If b < 0 Then b = 0
  505.                     Invalidate()
  506.                     Application.DoEvents()
  507.                 End If
  508.             Case MouseState.None
  509.                 If a > 0 Then
  510.                     a -= 4
  511.                 End If
  512.                 If b > 0 Then
  513.                     b -= 4
  514.                 End If
  515.                 If c > 0 Then
  516.                     c -= 4
  517.                 End If
  518.                 If a < 0 Then a = 0
  519.                 If b < 0 Then b = 0
  520.                 If c < 0 Then c = 0
  521.                 Invalidate()
  522.                 Application.DoEvents()
  523.         End Select
  524.     End Sub
  525.     Protected Overrides Sub PaintHook()
  526.         G.Clear(backgroundc)
  527.         Dim SB1 As New SolidBrush(Color.FromArgb(a, Color.Black))
  528.         Dim SB1_ As New SolidBrush(Color.FromArgb(b, Color.Black))
  529.         Dim SB2 As New SolidBrush(Color.FromArgb(c, Color.Black))
  530.         Dim SB3 As New SolidBrush(Color.FromArgb(20, Color.Black))
  531.         Select Case State
  532.             Case MouseState.Down
  533.                 If X <= 22 Then
  534.                     a = 0
  535.                     G.FillRectangle(SB3, New Rectangle(0, 0, 21, 17))
  536.                 ElseIf X > 22 And X <= 46 Then
  537.                     b = 0
  538.                     G.FillRectangle(SB3, New Rectangle(23, 0, 22, 17))
  539.                 Else
  540.                     c = 0
  541.                     G.FillRectangle(SB3, New Rectangle(47, 0, 36, 17))
  542.                 End If
  543.             Case Else
  544.                 If X <= 22 Then
  545.                     G.FillRectangle(SB1, New Rectangle(0, 0, 21, 17))
  546.                 ElseIf X > 22 And X <= 46 Then
  547.                     G.FillRectangle(SB1_, New Rectangle(23, 0, 22, 17))
  548.                 Else
  549.                     G.FillRectangle(SB2, New Rectangle(47, 0, 36, 17))
  550.                 End If
  551.         End Select
  552.         G.DrawString("0", New Font("Marlett", 8.25), GetBrush("IconsColor"), New Point(5, 4))
  553.         If FindForm.WindowState <> FormWindowState.Maximized Then G.DrawString("1", New Font("Marlett", 8), GetBrush("IconsColor"), New Point(28, 4)) Else G.DrawString("2", New Font("Marlett", 8.25), GetBrush("IconsColor"), New Point(28, 4))
  554.         G.DrawString("r", New Font("Marlett", 10), GetBrush("IconsColor"), New Point(56, 3))
  555.     End Sub
  556. End Class
  557. Class MetroLabel
  558.     Inherits Label
  559.     Sub New()
  560.         Font = New Font("Segoe UI", 12)
  561.         ForeColor = Color.Black
  562.         BackColor = Color.Transparent
  563.     End Sub
  564. End Class
  565. Class MetroTabControl
  566.     Inherits TabControl
  567.     Sub New()
  568.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or
  569.                  ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  570.         ItemSize = New Size(0, 30)
  571.         Font = New Font("Segoe UI", 8)
  572.     End Sub
  573.     Protected Overrides Sub CreateHandle()
  574.         MyBase.CreateHandle()
  575.         Alignment = TabAlignment.Top
  576.     End Sub
  577.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  578.         Dim G As Graphics = e.Graphics
  579.         Dim borderc As New Pen(Color.Black)
  580.         Dim fontc As New Color
  581.         Dim fillRect As New Rectangle(2, ItemSize.Height + 2, Width - 6, Height - ItemSize.Height - 3)
  582.         G.SmoothingMode = SmoothingMode.HighQuality
  583.         G.Clear(Parent.BackColor)
  584.         G.FillRectangle(Brushes.White, fillRect)
  585.         G.DrawRectangle(borderc, fillRect)
  586.         For i = 0 To TabCount - 1
  587.             Dim mainRect As Rectangle = GetTabRect(i)
  588.             If i = SelectedIndex Then
  589.                 G.FillRectangle(New SolidBrush(Color.White), mainRect)
  590.                 G.DrawRectangle(borderc, mainRect)
  591.                 G.DrawLine(New Pen(Color.Black), New Point(mainRect.X + 1, mainRect.Y), New Point(mainRect.X + mainRect.Width - 1, mainRect.Y))
  592.                 G.DrawLine(Pens.White, New Point(mainRect.X + 1, mainRect.Y + mainRect.Height), New Point(mainRect.X + mainRect.Width - 1, mainRect.Y + mainRect.Height))
  593.                 fontc = Color.Black
  594.             Else
  595.                 G.FillRectangle(New SolidBrush(Color.White), mainRect)
  596.                 G.DrawRectangle(borderc, mainRect)
  597.                 fontc = Color.Black
  598.             End If
  599.             Dim titleX As Integer = (mainRect.Location.X + mainRect.Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2)
  600.             Dim titleY As Integer = (mainRect.Location.Y + mainRect.Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2)
  601.             G.DrawString(TabPages(i).Text, Font, New SolidBrush(fontc), New Point(titleX, titleY))
  602.             Try : TabPages(i).BackColor = Color.White : Catch : End Try
  603.         Next
  604.     End Sub
  605. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement