Advertisement
Guest User

Firefox Theme : AeroRev9 [28/07]

a guest
Jul 28th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 28.98 KB | None | 0 0
  1. ' Firefox Theme.
  2. ' Made by AeroRev9.
  3. ' 25/07/2015.
  4. ' Updated : 27/07/2015.
  5. ' Credits : Mavaamarten, Xertz.
  6.  
  7.  
  8. Imports System.ComponentModel
  9. Imports System.Drawing.Drawing2D
  10. Imports System.Drawing.Text
  11.  
  12. Module Theme
  13.  
  14.     Public ReadOnly Property GlobalFont(B As FontStyle, S As Integer) As Font
  15.         Get
  16.             Return New Font("Segoe UI", S, B)
  17.         End Get
  18.     End Property
  19.  
  20.     Public Function GetCheckMark() As String
  21.         Return "iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAYAAAD0xERiAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEySURBVDhPY/hPRUBdw/79+/efVHz77bf/X37+wRAn2bDff/7+91l+83/YmtsYBpJs2ITjz/8rTbrwP2Dlrf9XXn5FkSPJsD13P/y3nHsVbNjyy28w5Ik27NWXX//TNt8DG1S19zFWNRiGvfzy8//ccy9RxEB4wvFnYIMMZl7+//brLwx5EEYx7MP33/9dF18Ha1py8RVcHBR7mlMvgsVXX8X0Hgwz/P379z8yLtz5AKxJdcpFcBj9+v3nf/CqW2Cx5E13UdSiYwzDvv36/d9/BUSzzvRL/0t2PQSzQd57+vEHilp0jGEYCJ9+8hnuGhiee+4Vhjp0jNUwEN566/1/m/mQZJC/48H/zz9+YVWHjHEaBsKgwAZ59eH771jl0TFew0D48osvWMWxYYKGEY///gcAqiuA6kEmfEMAAAAASUVORK5CYII="
  22.     End Function
  23.  
  24. End Module
  25.  
  26. Module Helpers
  27.  
  28.     Public Enum MouseState As Byte
  29.         None = 0
  30.         Over = 1
  31.         Down = 2
  32.     End Enum
  33.  
  34.     Public Function FullRectangle(S As Size, Subtract As Boolean) As Rectangle
  35.         If Subtract Then
  36.             Return New Rectangle(0, 0, S.Width - 1, S.Height - 1)
  37.         Else
  38.             Return New Rectangle(0, 0, S.Width, S.Height)
  39.         End If
  40.     End Function
  41.  
  42.     Public Function GreyColor(G As UInteger) As Color
  43.         Return Color.FromArgb(G, G, G)
  44.     End Function
  45.  
  46.     Public Sub CenterString(G As Graphics, T As String, F As Font, C As Color, R As Rectangle)
  47.         Dim TS As SizeF = G.MeasureString(T, F)
  48.  
  49.         Using B As New SolidBrush(C)
  50.             G.DrawString(T, F, B, New Point(R.Width / 2 - (TS.Width / 2), R.Height / 2 - (TS.Height / 2)))
  51.         End Using
  52.     End Sub
  53.  
  54.     Public Sub FillRoundRect(G As Graphics, R As Rectangle, Curve As Integer, C As Color)
  55.  
  56.         Using B As New SolidBrush(C)
  57.             G.FillPie(B, R.X, R.Y, Curve, Curve, 180, 90)
  58.             G.FillPie(B, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
  59.             G.FillPie(B, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
  60.             G.FillPie(B, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
  61.             G.FillRectangle(B, CInt(R.X + Curve / 2), R.Y, R.Width - Curve, CInt(Curve / 2))
  62.             G.FillRectangle(B, R.X, CInt(R.Y + Curve / 2), R.Width, R.Height - Curve)
  63.             G.FillRectangle(B, CInt(R.X + Curve / 2), CInt(R.Y + R.Height - Curve / 2), R.Width - Curve, CInt(Curve / 2))
  64.         End Using
  65.  
  66.     End Sub
  67.  
  68.     Public Sub DrawRoundRect(G As Graphics, R As Rectangle, Curve As Integer, C As Color)
  69.  
  70.         Using P As New Pen(C)
  71.             G.DrawArc(P, R.X, R.Y, Curve, Curve, 180, 90)
  72.             G.DrawLine(P, CInt(R.X + Curve / 2), R.Y, CInt(R.X + R.Width - Curve / 2), R.Y)
  73.             G.DrawArc(P, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
  74.             G.DrawLine(P, R.X, CInt(R.Y + Curve / 2), R.X, CInt(R.Y + R.Height - Curve / 2))
  75.             G.DrawLine(P, CInt(R.X + R.Width), CInt(R.Y + Curve / 2), CInt(R.X + R.Width), CInt(R.Y + R.Height - Curve / 2))
  76.             G.DrawLine(P, CInt(R.X + Curve / 2), CInt(R.Y + R.Height), CInt(R.X + R.Width - Curve / 2), CInt(R.Y + R.Height))
  77.             G.DrawArc(P, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
  78.             G.DrawArc(P, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
  79.         End Using
  80.  
  81.     End Sub
  82.  
  83.     Public Sub CenterStringTab(G As Graphics, text As String, font As Font, brush As Brush, rect As Rectangle, Optional shadow As Boolean = False, Optional yOffset As Integer = 0)
  84.  
  85.         Dim textSize As SizeF = G.MeasureString(text, font)
  86.         Dim textX As Integer = rect.X + (rect.Width / 2) - (textSize.Width / 2)
  87.         Dim textY As Integer = rect.Y + (rect.Height / 2) - (textSize.Height / 2) + yOffset
  88.  
  89.         If shadow Then G.DrawString(text, font, Brushes.Black, textX + 1, textY + 1)
  90.         G.DrawString(text, font, brush, textX, textY + 1)
  91.  
  92.     End Sub
  93.  
  94. End Module
  95.  
  96.  
  97. <DefaultEvent("CheckedChanged")>
  98. Class FirefoxRadioButton
  99.     Inherits Control
  100.  
  101. #Region " Public "
  102.     Public Event CheckedChanged(sender As Object, e As EventArgs)
  103. #End Region
  104.  
  105. #Region " Private "
  106.     Private State As MouseState
  107.     Private ETC As Color = Nothing
  108.     Private G As Graphics
  109.  
  110.     Private _EnabledCalc As Boolean
  111.     Private _Checked As Boolean
  112.     Private _Bold As Boolean
  113. #End Region
  114.  
  115. #Region " Properties "
  116.  
  117.     Public Property Checked As Boolean
  118.         Get
  119.             Return _Checked
  120.         End Get
  121.         Set(value As Boolean)
  122.             _Checked = value
  123.             Invalidate()
  124.         End Set
  125.     End Property
  126.  
  127.     Public Shadows Property Enabled As Boolean
  128.         Get
  129.             Return EnabledCalc
  130.         End Get
  131.         Set(value As Boolean)
  132.             _EnabledCalc = value
  133.             Invalidate()
  134.         End Set
  135.     End Property
  136.  
  137.     <DisplayName("Enabled")>
  138.     Public Property EnabledCalc As Boolean
  139.         Get
  140.             Return _EnabledCalc
  141.         End Get
  142.         Set(value As Boolean)
  143.             Enabled = value
  144.             Invalidate()
  145.         End Set
  146.     End Property
  147.  
  148.     Public Property Bold As Boolean
  149.         Get
  150.             Return _Bold
  151.         End Get
  152.         Set(value As Boolean)
  153.             _Bold = value
  154.             Invalidate()
  155.         End Set
  156.     End Property
  157.  
  158. #End Region
  159.  
  160. #Region " Control "
  161.  
  162.     Sub New()
  163.         DoubleBuffered = True
  164.         ForeColor = Color.FromArgb(66, 78, 90)
  165.         Font = GlobalFont(FontStyle.Regular, 10)
  166.         Size = New Size(160, 27)
  167.         Enabled = True
  168.     End Sub
  169.  
  170.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  171.  
  172.         G = e.Graphics
  173.         G.SmoothingMode = SmoothingMode.HighQuality
  174.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  175.  
  176.         MyBase.OnPaint(e)
  177.  
  178.         G.Clear(Parent.BackColor)
  179.  
  180.         If Enabled Then
  181.             ETC = Color.FromArgb(66, 78, 90)
  182.  
  183.             Select Case State
  184.  
  185.                 Case MouseState.Over, MouseState.Down
  186.  
  187.                     Using P As New Pen(Color.FromArgb(34, 146, 208))
  188.                         G.DrawEllipse(P, New Rectangle(2, 2, 22, 22))
  189.                     End Using
  190.  
  191.                 Case Else
  192.  
  193.                     Using P As New Pen(GreyColor(190))
  194.                         G.DrawEllipse(P, New Rectangle(2, 2, 22, 22))
  195.                     End Using
  196.  
  197.             End Select
  198.  
  199.             If Checked Then
  200.  
  201.                 Using B As New SolidBrush(Color.FromArgb(34, 146, 208))
  202.                     G.FillEllipse(B, New Rectangle(7, 7, 12, 12))
  203.                 End Using
  204.  
  205.             End If
  206.  
  207.         Else
  208.             ETC = GreyColor(170)
  209.  
  210.             Using P As New Pen(GreyColor(210))
  211.                 G.DrawEllipse(P, New Rectangle(2, 2, 22, 22))
  212.             End Using
  213.  
  214.             If Checked Then
  215.  
  216.                 Using B As New SolidBrush(Color.FromArgb(34, 146, 208))
  217.                     G.FillEllipse(B, New Rectangle(7, 7, 12, 12))
  218.                 End Using
  219.  
  220.             End If
  221.  
  222.         End If
  223.  
  224.         Using B As New SolidBrush(ETC)
  225.  
  226.             If Bold Then
  227.                 G.DrawString(Text, GlobalFont(FontStyle.Bold, 10), B, New Point(32, 4))
  228.             Else
  229.                 G.DrawString(Text, GlobalFont(FontStyle.Regular, 10), B, New Point(32, 4))
  230.             End If
  231.  
  232.         End Using
  233.  
  234.  
  235.     End Sub
  236.  
  237.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  238.         MyBase.OnMouseDown(e)
  239.         State = MouseState.Down : Invalidate()
  240.     End Sub
  241.  
  242.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  243.         MyBase.OnMouseUp(e)
  244.  
  245.         If Enabled Then
  246.  
  247.             If Not Checked Then
  248.  
  249.                 For Each C As Control In Parent.Controls
  250.                     If TypeOf C Is FirefoxRadioButton Then
  251.                         DirectCast(C, FirefoxRadioButton).Checked = False
  252.                     End If
  253.                 Next
  254.  
  255.             End If
  256.  
  257.             Checked = True
  258.             RaiseEvent CheckedChanged(Me, e)
  259.         End If
  260.  
  261.         State = MouseState.Over : Invalidate()
  262.     End Sub
  263.  
  264.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  265.         MyBase.OnMouseEnter(e)
  266.         State = MouseState.Over : Invalidate()
  267.     End Sub
  268.  
  269.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  270.         MyBase.OnMouseLeave(e)
  271.         State = MouseState.None : Invalidate()
  272.     End Sub
  273.  
  274. #End Region
  275.  
  276. End Class
  277.  
  278. <DefaultEvent("CheckedChanged")>
  279. Class FirefoxCheckBox
  280.     Inherits Control
  281.  
  282. #Region " Public "
  283.     Public Event CheckedChanged(sender As Object, e As EventArgs)
  284. #End Region
  285.  
  286. #Region " Private "
  287.     Private State As MouseState
  288.     Private ETC As Color = Nothing
  289.     Private G As Graphics
  290.  
  291.     Private _EnabledCalc As Boolean
  292.     Private _Checked As Boolean
  293.     Private _Bold As Boolean
  294. #End Region
  295.  
  296. #Region " Properties "
  297.  
  298.     Public Property Checked As Boolean
  299.         Get
  300.             Return _Checked
  301.         End Get
  302.         Set(value As Boolean)
  303.             _Checked = value
  304.             Invalidate()
  305.         End Set
  306.     End Property
  307.  
  308.     Public Shadows Property Enabled As Boolean
  309.         Get
  310.             Return EnabledCalc
  311.         End Get
  312.         Set(value As Boolean)
  313.             _EnabledCalc = value
  314.             Invalidate()
  315.         End Set
  316.     End Property
  317.  
  318.     <DisplayName("Enabled")>
  319.     Public Property EnabledCalc As Boolean
  320.         Get
  321.             Return _EnabledCalc
  322.         End Get
  323.         Set(value As Boolean)
  324.             Enabled = value
  325.             Invalidate()
  326.         End Set
  327.     End Property
  328.  
  329.     Public Property Bold As Boolean
  330.         Get
  331.             Return _Bold
  332.         End Get
  333.         Set(value As Boolean)
  334.             _Bold = value
  335.             Invalidate()
  336.         End Set
  337.     End Property
  338.  
  339. #End Region
  340.  
  341. #Region " Control "
  342.  
  343.     Sub New()
  344.         DoubleBuffered = True
  345.         ForeColor = Color.FromArgb(66, 78, 90)
  346.         Font = GlobalFont(FontStyle.Regular, 10)
  347.         Size = New Size(160, 27)
  348.         Enabled = True
  349.     End Sub
  350.  
  351.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  352.  
  353.         G = e.Graphics
  354.         G.SmoothingMode = SmoothingMode.HighQuality
  355.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  356.  
  357.         MyBase.OnPaint(e)
  358.  
  359.         G.Clear(Parent.BackColor)
  360.  
  361.         If Enabled Then
  362.             ETC = Color.FromArgb(66, 78, 90)
  363.  
  364.             Select Case State
  365.  
  366.                 Case MouseState.Over, MouseState.Down
  367.                     DrawRoundRect(G, New Rectangle(3, 3, 20, 20), 3, Color.FromArgb(44, 156, 218))
  368.  
  369.                 Case Else
  370.                     DrawRoundRect(G, New Rectangle(3, 3, 20, 20), 3, GreyColor(200))
  371.  
  372.             End Select
  373.  
  374.             If Checked Then
  375.  
  376.                 Using I As Image = Image.FromStream(New IO.MemoryStream(Convert.FromBase64String(GetCheckMark)))
  377.                     G.DrawImage(I, New Point(4, 5))
  378.                 End Using
  379.  
  380.             End If
  381.  
  382.         Else
  383.  
  384.             ETC = GreyColor(170)
  385.             DrawRoundRect(G, New Rectangle(3, 3, 20, 20), 3, GreyColor(220))
  386.  
  387.             If Checked Then
  388.  
  389.                 Using I As Image = Image.FromStream(New IO.MemoryStream(Convert.FromBase64String(GetCheckMark)))
  390.                     G.DrawImage(I, New Point(4, 5))
  391.                 End Using
  392.  
  393.             End If
  394.  
  395.         End If
  396.  
  397.  
  398.         Using B As New SolidBrush(ETC)
  399.  
  400.             If Bold Then
  401.                 G.DrawString(Text, GlobalFont(FontStyle.Bold, 10), B, New Point(32, 4))
  402.             Else
  403.                 G.DrawString(Text, GlobalFont(FontStyle.Regular, 10), B, New Point(32, 4))
  404.             End If
  405.  
  406.         End Using
  407.  
  408.  
  409.     End Sub
  410.  
  411.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  412.         MyBase.OnMouseDown(e)
  413.         State = MouseState.Down : Invalidate()
  414.     End Sub
  415.  
  416.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  417.         MyBase.OnMouseUp(e)
  418.  
  419.         If Enabled Then
  420.             Checked = Not Checked
  421.             RaiseEvent CheckedChanged(Me, e)
  422.         End If
  423.  
  424.         State = MouseState.Over : Invalidate()
  425.     End Sub
  426.  
  427.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  428.         MyBase.OnMouseEnter(e)
  429.         State = MouseState.Over : Invalidate()
  430.     End Sub
  431.  
  432.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  433.         MyBase.OnMouseLeave(e)
  434.         State = MouseState.None : Invalidate()
  435.     End Sub
  436.  
  437. #End Region
  438.  
  439. End Class
  440.  
  441. Class FirefoxH1
  442.     Inherits Label
  443.  
  444. #Region " Private "
  445.     Private G As Graphics
  446. #End Region
  447.  
  448. #Region " Control "
  449.  
  450.     Sub New()
  451.         DoubleBuffered = True
  452.         AutoSize = False
  453.         Font = New Font("Segoe UI Semibold", 20)
  454.         ForeColor = Color.FromArgb(76, 88, 100)
  455.     End Sub
  456.  
  457.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  458.  
  459.         G = e.Graphics
  460.         G.SmoothingMode = SmoothingMode.HighQuality
  461.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  462.  
  463.         MyBase.OnPaint(e)
  464.  
  465.         Using P As New Pen(GreyColor(200))
  466.             G.DrawLine(P, New Point(0, 50), New Point(Width, 50))
  467.         End Using
  468.  
  469.     End Sub
  470.  
  471. #End Region
  472.  
  473. End Class
  474.  
  475. Class FirefoxH2
  476.     Inherits Label
  477.  
  478. #Region " Control "
  479.  
  480.     Sub New()
  481.         Font = GlobalFont(FontStyle.Bold, 10)
  482.         ForeColor = Color.FromArgb(76, 88, 100)
  483.         BackColor = Color.White
  484.     End Sub
  485.  
  486. #End Region
  487.  
  488. End Class
  489.  
  490. Class FirefoxButton
  491.     Inherits Control
  492.  
  493. #Region " Private "
  494.     Private State As MouseState
  495.     Private ETC As Color = Nothing
  496.     Private G As Graphics
  497.  
  498.     Private _EnabledCalc As Boolean
  499. #End Region
  500.  
  501. #Region " Properties "
  502.  
  503.     Public Shadows Property Enabled As Boolean
  504.         Get
  505.             Return EnabledCalc
  506.         End Get
  507.         Set(value As Boolean)
  508.             _EnabledCalc = value
  509.             Invalidate()
  510.         End Set
  511.     End Property
  512.  
  513.     <DisplayName("Enabled")>
  514.     Public Property EnabledCalc As Boolean
  515.         Get
  516.             Return _EnabledCalc
  517.         End Get
  518.         Set(value As Boolean)
  519.             Enabled = value
  520.             Invalidate()
  521.         End Set
  522.     End Property
  523.  
  524. #End Region
  525.  
  526. #Region " Control "
  527.  
  528.     Sub New()
  529.         DoubleBuffered = True
  530.         Enabled = True
  531.         ForeColor = Color.FromArgb(56, 68, 80)
  532.         Font = GlobalFont(FontStyle.Regular, 10)
  533.     End Sub
  534.  
  535.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  536.  
  537.         G = e.Graphics
  538.         G.SmoothingMode = SmoothingMode.HighQuality
  539.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  540.  
  541.         MyBase.OnPaint(e)
  542.  
  543.         G.Clear(Parent.BackColor)
  544.  
  545.         If Enabled Then
  546.             ETC = Color.FromArgb(56, 68, 80)
  547.  
  548.             Select Case State
  549.  
  550.                 Case MouseState.None
  551.  
  552.                     Using B As New SolidBrush(GreyColor(245))
  553.                         G.FillRectangle(B, New Rectangle(1, 1, Width - 2, Height - 2))
  554.                     End Using
  555.  
  556.                     DrawRoundRect(G, FullRectangle(Size, True), 2, GreyColor(193))
  557.  
  558.                 Case MouseState.Over
  559.  
  560.                     Using B As New SolidBrush(GreyColor(232))
  561.                         G.FillRectangle(B, New Rectangle(1, 1, Width - 2, Height - 2))
  562.                     End Using
  563.  
  564.                     DrawRoundRect(G, FullRectangle(Size, True), 2, GreyColor(193))
  565.  
  566.                 Case Else
  567.  
  568.                     Using B As New SolidBrush(GreyColor(212))
  569.                         G.FillRectangle(B, New Rectangle(1, 1, Width - 2, Height - 2))
  570.                     End Using
  571.  
  572.                     DrawRoundRect(G, FullRectangle(Size, True), 2, GreyColor(193))
  573.  
  574.             End Select
  575.  
  576.         Else
  577.             ETC = GreyColor(170)
  578.  
  579.             Using B As New SolidBrush(GreyColor(245))
  580.                 G.FillRectangle(B, New Rectangle(1, 1, Width - 2, Height - 2))
  581.             End Using
  582.  
  583.             DrawRoundRect(G, FullRectangle(Size, True), 2, GreyColor(223))
  584.  
  585.         End If
  586.  
  587.         CenterString(G, Text, GlobalFont(FontStyle.Regular, 10), ETC, FullRectangle(Size, False))
  588.  
  589.     End Sub
  590.  
  591.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  592.         MyBase.OnMouseUp(e)
  593.         State = MouseState.Over : Invalidate()
  594.     End Sub
  595.  
  596.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  597.         MyBase.OnMouseUp(e)
  598.         State = MouseState.Down : Invalidate()
  599.     End Sub
  600.  
  601.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  602.         MyBase.OnMouseEnter(e)
  603.         State = MouseState.Over : Invalidate()
  604.     End Sub
  605.  
  606.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  607.         MyBase.OnMouseEnter(e)
  608.         State = MouseState.None : Invalidate()
  609.     End Sub
  610.  
  611. #End Region
  612.  
  613. End Class
  614.  
  615. Class FirefoxRedirect
  616.     Inherits Control
  617.  
  618. #Region " Private "
  619.     Private State As MouseState
  620.     Private G As Graphics
  621.  
  622.     Private FC As Color = Nothing
  623.     Private FF As Font = Nothing
  624. #End Region
  625.  
  626. #Region " Control "
  627.  
  628.     Sub New()
  629.         DoubleBuffered = True
  630.         Cursor = Cursors.Hand
  631.         BackColor = Color.White
  632.     End Sub
  633.  
  634.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  635.  
  636.         G = e.Graphics
  637.         G.SmoothingMode = SmoothingMode.HighQuality
  638.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  639.  
  640.         MyBase.OnPaint(e)
  641.  
  642.         Select Case State
  643.  
  644.             Case MouseState.Over
  645.                 FC = Color.FromArgb(23, 140, 229)
  646.                 FF = GlobalFont(FontStyle.Underline, 10)
  647.  
  648.             Case MouseState.Down
  649.                 FC = Color.FromArgb(255, 149, 0)
  650.                 FF = GlobalFont(FontStyle.Regular, 10)
  651.  
  652.             Case Else
  653.                 FC = Color.FromArgb(0, 149, 221)
  654.                 FF = GlobalFont(FontStyle.Regular, 10)
  655.  
  656.         End Select
  657.  
  658.         Using B As New SolidBrush(FC)
  659.             G.DrawString(Text, FF, B, New Point(0, 0))
  660.         End Using
  661.  
  662.     End Sub
  663.  
  664.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  665.         MyBase.OnMouseUp(e)
  666.         State = MouseState.Over : Invalidate()
  667.     End Sub
  668.  
  669.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  670.         MyBase.OnMouseUp(e)
  671.         State = MouseState.Down : Invalidate()
  672.     End Sub
  673.  
  674.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  675.         MyBase.OnMouseEnter(e)
  676.         State = MouseState.Over : Invalidate()
  677.     End Sub
  678.  
  679.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  680.         MyBase.OnMouseEnter(e)
  681.         State = MouseState.None : Invalidate()
  682.     End Sub
  683.  
  684. #End Region
  685.  
  686. End Class
  687.  
  688. Class FirefoxSubTabControl
  689.     Inherits TabControl
  690.  
  691. #Region " Private "
  692.     Private G As Graphics
  693.     Private TabRect As Rectangle
  694. #End Region
  695.  
  696. #Region " Control "
  697.  
  698.     Sub New()
  699.         DoubleBuffered = True
  700.         Alignment = TabAlignment.Top
  701.     End Sub
  702.  
  703.     Protected Overrides Sub OnCreateControl()
  704.         MyBase.OnCreateControl()
  705.         SetStyle(ControlStyles.UserPaint, True)
  706.         ItemSize = New Size(100, 40)
  707.         SizeMode = TabSizeMode.Fixed
  708.     End Sub
  709.  
  710.     Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
  711.         MyBase.OnControlAdded(e)
  712.         Try
  713.             For i As Integer = 0 To TabPages.Count - 1
  714.                 TabPages(i).BackColor = Color.White
  715.                 TabPages(i).ForeColor = Color.FromArgb(66, 79, 90)
  716.                 TabPages(i).Font = GlobalFont(FontStyle.Regular, 10)
  717.             Next
  718.         Catch
  719.         End Try
  720.     End Sub
  721.  
  722.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  723.  
  724.         G = e.Graphics
  725.         G.SmoothingMode = SmoothingMode.HighQuality
  726.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  727.  
  728.         MyBase.OnPaint(e)
  729.  
  730.         G.Clear(Parent.BackColor)
  731.  
  732.         For i As Integer = 0 To TabPages.Count - 1
  733.  
  734.             TabRect = GetTabRect(i)
  735.  
  736.             If GetTabRect(i).Contains(Me.PointToClient(Cursor.Position)) And Not SelectedIndex = i Then
  737.  
  738.                 Using B As New SolidBrush(GreyColor(240))
  739.                     G.FillRectangle(B, New Rectangle(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2, GetTabRect(i).Width, GetTabRect(i).Height + 1))
  740.                 End Using
  741.  
  742.             ElseIf SelectedIndex = i
  743.  
  744.                 Using B As New SolidBrush(GreyColor(240))
  745.                     G.FillRectangle(B, New Rectangle(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2, GetTabRect(i).Width, GetTabRect(i).Height + 1))
  746.                 End Using
  747.  
  748.                 Using P As New Pen(Color.FromArgb(255, 149, 0), 4)
  749.                     G.DrawLine(P, New Point(TabRect.X - 2, TabRect.Y + ItemSize.Height - 2), New Point(TabRect.X + TabRect.Width - 2, TabRect.Y + ItemSize.Height - 2))
  750.                 End Using
  751.  
  752.             ElseIf Not SelectedIndex = i
  753.                 G.FillRectangle(Brushes.White, GetTabRect(i))
  754.             End If
  755.  
  756.             Using B As New SolidBrush(Color.FromArgb(56, 69, 80))
  757.                 CenterStringTab(G, TabPages(i).Text, GlobalFont(FontStyle.Regular, 10), B, GetTabRect(i))
  758.             End Using
  759.  
  760.         Next
  761.  
  762.         Using P As New Pen(GreyColor(200))
  763.             G.DrawLine(P, New Point(0, ItemSize.Height + 2), New Point(Width, ItemSize.Height + 2))
  764.         End Using
  765.  
  766.     End Sub
  767.  
  768. #End Region
  769.  
  770. End Class
  771.  
  772. Class FirefoxMainTabControl
  773.     Inherits TabControl
  774.  
  775. #Region " Private "
  776.     Private G As Graphics
  777.     Private TabRect As Rectangle
  778.     Private FC As Color = Nothing
  779. #End Region
  780.  
  781. #Region " Control "
  782.  
  783.     Sub New()
  784.         DoubleBuffered = True
  785.         ItemSize = New Size(43, 152)
  786.         Alignment = TabAlignment.Left
  787.         SizeMode = TabSizeMode.Fixed
  788.     End Sub
  789.  
  790.     Protected Overrides Sub OnCreateControl()
  791.         MyBase.OnCreateControl()
  792.         SetStyle(ControlStyles.UserPaint, True)
  793.     End Sub
  794.  
  795.     Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
  796.         MyBase.OnControlAdded(e)
  797.         Try
  798.             For i As Integer = 0 To TabPages.Count - 1
  799.                 TabPages(i).BackColor = Color.White
  800.                 TabPages(i).ForeColor = Color.FromArgb(66, 79, 90)
  801.                 TabPages(i).Font = GlobalFont(FontStyle.Regular, 10)
  802.             Next
  803.         Catch
  804.         End Try
  805.     End Sub
  806.  
  807.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  808.  
  809.         G = e.Graphics
  810.         G.SmoothingMode = SmoothingMode.HighQuality
  811.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  812.  
  813.         MyBase.OnPaint(e)
  814.  
  815.         G.Clear(Color.FromArgb(66, 79, 90))
  816.  
  817.         For i As Integer = 0 To TabPages.Count - 1
  818.  
  819.             TabRect = GetTabRect(i)
  820.  
  821.             If SelectedIndex = i Then
  822.  
  823.                 Using B As New SolidBrush(Color.FromArgb(52, 63, 72))
  824.                     G.FillRectangle(B, TabRect)
  825.                 End Using
  826.  
  827.                 FC = GreyColor(245)
  828.  
  829.                 Using B As New SolidBrush(Color.FromArgb(255, 175, 54))
  830.                     G.FillRectangle(B, New Rectangle(TabRect.Location.X - 3, TabRect.Location.Y + 1, 5, TabRect.Height - 2))
  831.                 End Using
  832.  
  833.             Else
  834.                 FC = GreyColor(192)
  835.  
  836.                 Using B As New SolidBrush(Color.FromArgb(66, 79, 90))
  837.                     G.FillRectangle(B, TabRect)
  838.                 End Using
  839.  
  840.             End If
  841.  
  842.             Using B As New SolidBrush(FC)
  843.                 G.DrawString(TabPages(i).Text, GlobalFont(FontStyle.Regular, 10), B, New Point(TabRect.X + 50, TabRect.Y + 12))
  844.             End Using
  845.  
  846.             If Not IsNothing(ImageList) Then
  847.                 If Not TabPages(i).ImageIndex < 0 Then
  848.                     G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Rectangle(TabRect.X + 19, TabRect.Y + ((TabRect.Height / 2) - 10), 18, 18))
  849.                 End If
  850.             End If
  851.  
  852.         Next
  853.  
  854.     End Sub
  855.  
  856. #End Region
  857.  
  858. End Class
  859.  
  860. <DefaultEvent("TextChanged")>
  861. Class FirefoxTextbox
  862.     Inherits Control
  863.  
  864. #Region " Private "
  865.     Private WithEvents TB As New TextBox
  866.     Private G As Graphics
  867.     Private State As MouseState
  868.     Private IsDown As Boolean
  869.  
  870.     Private _watermark As String = ""
  871.     Private _allowpassword As Boolean = False
  872.     Private _maxChars As Integer = 32767
  873.     Private _textAlignment As HorizontalAlignment
  874.     Private _multiLine As Boolean = False
  875.     Private _readOnly As Boolean = False
  876. #End Region
  877.  
  878. #Region " Properties "
  879.  
  880.     Public Shadows Property UseSystemPasswordChar() As Boolean
  881.         Get
  882.             Return _allowpassword
  883.         End Get
  884.         Set(ByVal value As Boolean)
  885.             TB.UseSystemPasswordChar = UseSystemPasswordChar
  886.             _allowpassword = value
  887.             Invalidate()
  888.         End Set
  889.     End Property
  890.  
  891.     Public Shadows Property MaxLength() As Integer
  892.         Get
  893.             Return _maxChars
  894.         End Get
  895.         Set(ByVal value As Integer)
  896.             _maxChars = value
  897.             TB.MaxLength = MaxLength
  898.             Invalidate()
  899.         End Set
  900.     End Property
  901.  
  902.     Public Shadows Property TextAlign() As HorizontalAlignment
  903.         Get
  904.             Return _textAlignment
  905.         End Get
  906.         Set(ByVal value As HorizontalAlignment)
  907.             _textAlignment = value
  908.             Invalidate()
  909.         End Set
  910.     End Property
  911.  
  912.     Public Shadows Property MultiLine() As Boolean
  913.         Get
  914.             Return _multiLine
  915.         End Get
  916.         Set(ByVal value As Boolean)
  917.             _multiLine = value
  918.             TB.Multiline = value
  919.             OnResize(EventArgs.Empty)
  920.             Invalidate()
  921.         End Set
  922.     End Property
  923.  
  924.     Public Shadows Property [ReadOnly]() As Boolean
  925.         Get
  926.             Return _readOnly
  927.         End Get
  928.         Set(ByVal value As Boolean)
  929.             _readOnly = value
  930.             If TB IsNot Nothing Then
  931.                 TB.ReadOnly = value
  932.             End If
  933.         End Set
  934.     End Property
  935.  
  936. #End Region
  937.  
  938. #Region " Control "
  939.  
  940.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  941.         MyBase.OnTextChanged(e)
  942.         Invalidate()
  943.     End Sub
  944.  
  945.     Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  946.         MyBase.OnBackColorChanged(e)
  947.         Invalidate()
  948.     End Sub
  949.  
  950.     Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  951.         MyBase.OnForeColorChanged(e)
  952.         TB.ForeColor = ForeColor
  953.         Invalidate()
  954.     End Sub
  955.  
  956.     Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  957.         MyBase.OnFontChanged(e)
  958.         TB.Font = Font
  959.     End Sub
  960.  
  961.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  962.         MyBase.OnGotFocus(e)
  963.         TB.Focus()
  964.     End Sub
  965.  
  966.     Private Sub TextChangeTb() Handles TB.TextChanged
  967.         Text = TB.Text
  968.     End Sub
  969.  
  970.     Private Sub TextChng() Handles MyBase.TextChanged
  971.         TB.Text = Text
  972.     End Sub
  973.  
  974.     Public Sub NewTextBox()
  975.         With TB
  976.             .Text = String.Empty
  977.             .BackColor = Color.White
  978.             .ForeColor = Color.FromArgb(66, 78, 90)
  979.             .TextAlign = HorizontalAlignment.Left
  980.             .BorderStyle = BorderStyle.None
  981.             .Location = New Point(3, 3)
  982.             .Font = GlobalFont(FontStyle.Regular, 10)
  983.             .Size = New Size(Width - 3, Height - 3)
  984.             .UseSystemPasswordChar = UseSystemPasswordChar
  985.         End With
  986.     End Sub
  987.  
  988.     Sub New()
  989.         MyBase.New()
  990.         NewTextBox()
  991.         Controls.Add(TB)
  992.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  993.         DoubleBuffered = True
  994.         TextAlign = HorizontalAlignment.Left
  995.         ForeColor = Color.FromArgb(66, 78, 90)
  996.         Font = GlobalFont(FontStyle.Regular, 10)
  997.         Size = New Size(130, 29)
  998.     End Sub
  999.  
  1000.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1001.  
  1002.         G = e.Graphics
  1003.         G.SmoothingMode = SmoothingMode.HighQuality
  1004.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  1005.  
  1006.         MyBase.OnPaint(e)
  1007.  
  1008.         G.Clear(Parent.BackColor)
  1009.  
  1010.         If Enabled Then
  1011.  
  1012.             If State = MouseState.Down Then
  1013.                 DrawRoundRect(G, FullRectangle(Size, True), 3, Color.FromArgb(44, 156, 218))
  1014.             Else
  1015.                 DrawRoundRect(G, FullRectangle(Size, True), 3, GreyColor(200))
  1016.             End If
  1017.  
  1018.         Else
  1019.             DrawRoundRect(G, FullRectangle(Size, True), 3, GreyColor(230))
  1020.         End If
  1021.  
  1022.         TB.TextAlign = TextAlign
  1023.         TB.UseSystemPasswordChar = UseSystemPasswordChar
  1024.  
  1025.     End Sub
  1026.  
  1027.     Protected Overrides Sub OnResize(e As EventArgs)
  1028.         MyBase.OnResize(e)
  1029.         If Not MultiLine Then
  1030.             Dim tbheight As Integer = TB.Height
  1031.             TB.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer))
  1032.             TB.Size = New Size(Width - 20, tbheight)
  1033.         Else
  1034.             TB.Location = New Point(10, 10)
  1035.             TB.Size = New Size(Width - 20, Height - 20)
  1036.         End If
  1037.     End Sub
  1038.  
  1039.     Protected Overrides Sub OnEnter(e As EventArgs)
  1040.         MyBase.OnEnter(e)
  1041.         State = MouseState.Down : Invalidate()
  1042.     End Sub
  1043.  
  1044.     Protected Overrides Sub OnLeave(e As EventArgs)
  1045.         MyBase.OnLeave(e)
  1046.         State = MouseState.None : Invalidate()
  1047.     End Sub
  1048.  
  1049. #End Region
  1050.  
  1051. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement