Advertisement
MrDxdiag

Avast Ui Theme

Jul 15th, 2014
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 32.09 KB | None | 0 0
  1. Imports System.Drawing.Text
  2. Imports System.IO
  3. Imports System.Drawing.Drawing2D
  4. Imports System.ComponentModel
  5. Imports System.ComponentModel.Design
  6. Imports System.Drawing.Design
  7. Imports System.Windows.Forms
  8.  
  9. Public Class AVTheme
  10.     Inherits ContainerControl
  11.  
  12.     Private C1 As Color = Color.FromArgb(242, 242, 242)
  13.     Private C2 As Color = Color.FromArgb(0, 166, 208)
  14.  
  15.     Private B1 As New SolidBrush(C1)
  16.     Private B2 As New SolidBrush(C2)
  17.  
  18.     Private F As Font
  19.  
  20.     Private T As String
  21.  
  22.  
  23.     Private _PageName As String = "Scan"
  24.     Private _PageImage As Image
  25.  
  26.  
  27.     Private MouseP As Point = New Point(0, 0)
  28.     Private Cap As Boolean = False
  29.     Private MoveHeight As Integer = 48
  30.  
  31.  
  32.     Public Property PageName() As String
  33.         Get
  34.             Return _PageName
  35.         End Get
  36.         Set(v As String)
  37.             _PageName = v : Invalidate()
  38.         End Set
  39.     End Property
  40.  
  41.     Public Property PageImage() As Image
  42.         Get
  43.             Return _PageImage
  44.         End Get
  45.         Set(v As Image)
  46.             _PageImage = v
  47.         End Set
  48.     End Property
  49.  
  50.     Sub New()
  51.         MyBase.New()
  52.         Me.BackColor = C1
  53.  
  54.         DoubleBuffered = True
  55.         Me.Dock = DockStyle.Fill
  56.  
  57.         F = New Font("Segoe UI", 13, FontStyle.Regular)
  58.     End Sub
  59.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  60.         MyBase.OnMouseDown(e)
  61.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  62.             Cap = True : MouseP = e.Location
  63.         End If
  64.     End Sub
  65.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  66.         MyBase.OnMouseUp(e) : Cap = False
  67.     End Sub
  68.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  69.         MyBase.OnMouseMove(e)
  70.         If Cap Then
  71.             Parent.Location = MousePosition - MouseP
  72.         End If
  73.     End Sub
  74.  
  75.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  76.         MyBase.OnPaint(e)
  77.         Dim G As Graphics
  78.         G = e.Graphics
  79.  
  80.         G.SmoothingMode = SmoothingMode.None
  81.  
  82.         Dim I As Bitmap = Me.ParentForm.Icon.ToBitmap
  83.         Dim IM As Image = I
  84.         T = Me.ParentForm.Text
  85.  
  86.         G.FillRectangle(B2, New Rectangle(0, 48, Me.Width, 70))
  87.         G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(203, 203, 203))), New Point(0, Me.Height - 49), New Point(Me.Width, Me.Height - 49))
  88.  
  89.         G.DrawString(T, F, Brushes.Black, Me.Width / 2 - G.MeasureString(T, F).Width / 2, 24 - G.MeasureString(T, F).Height / 2)
  90.         G.DrawImage(IM, New Point(Me.Width / 2 - G.MeasureString(T, F).Width / 2 - IM.Width - 2, IM.Height / 2 - 7))
  91.  
  92.         If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
  93.             Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  94.         End If
  95.  
  96.         G.TextRenderingHint = TextRenderingHint.AntiAlias
  97.         G.DrawString(_PageName, New Font("Verdana", 17, FontStyle.Regular), Brushes.White, 105, 70)
  98.  
  99.         If Not _PageImage Is Nothing Then
  100.             G.DrawImage(_PageImage, New Point(70, 84 - _PageImage.Height / 2))
  101.         End If
  102.     End Sub
  103. End Class
  104.  
  105. Public Class AVWindowButton : Inherits Control
  106.  
  107.     Private Hover As Color = Color.FromArgb(242, 242, 242)
  108.  
  109.     Private _SetImage As String = "Close"
  110.  
  111.     Sub New()
  112.         Me.Size = New Size(33, 33)
  113.         Me.DoubleBuffered = True
  114.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  115.         Me.BackColor = Color.Transparent
  116.     End Sub
  117.  
  118.     <TypeConverter(GetType(btnimProperty)), Category("Misc"), Description("Select Image from the list")>
  119.     Public Property SetImage() As String
  120.         Get
  121.             Return _SetImage
  122.         End Get
  123.         Set(value As String)
  124.             _SetImage = value
  125.         End Set
  126.     End Property
  127.  
  128.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  129.         Hover = Color.FromArgb(228, 228, 228)
  130.         MyBase.Invalidate()
  131.         MyBase.OnMouseEnter(e)
  132.     End Sub
  133.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  134.         Hover = Color.FromArgb(242, 242, 242)
  135.         MyBase.Invalidate()
  136.         MyBase.OnMouseEnter(e)
  137.     End Sub
  138.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  139.         Hover = Color.FromArgb(214, 214, 214)
  140.         MyBase.Invalidate()
  141.         MyBase.OnMouseUp(e)
  142.     End Sub
  143.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  144.         Hover = Color.FromArgb(151, 151, 151)
  145.         MyBase.Invalidate()
  146.         MyBase.OnMouseClick(e)
  147.     End Sub
  148.  
  149.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  150.         Dim P As GraphicsPath = New GraphicsPath()
  151.         Dim ArcRectangleWidth As Integer = Curve * 2
  152.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  153.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  154.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  155.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  156.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  157.         Return P
  158.     End Function
  159.  
  160.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  161.         MyBase.OnPaint(e)
  162.         Dim G As Graphics
  163.         G = e.Graphics
  164.  
  165.         G.SmoothingMode = SmoothingMode.HighQuality
  166.  
  167.         G.FillPath(New SolidBrush(Color.FromArgb(Hover.ToArgb)), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  168.  
  169.  
  170.         G.SmoothingMode = SmoothingMode.None
  171.  
  172.         If _SetImage = "Close" Then
  173.             Using P1 As New Pen(Brushes.DimGray, 2)
  174.                 P1.StartCap = LineCap.Triangle : P1.EndCap = LineCap.Triangle
  175.                 G.DrawLine(P1, 6, 6, Me.Width - 6, Me.Height - 6)
  176.                 G.DrawLine(P1, Me.Width - 6, 6, 6, Me.Height - 6)
  177.             End Using
  178.         ElseIf _SetImage = "Minimize" Then
  179.             Using P1 As New Pen(Brushes.DimGray, 2)
  180.                 P1.StartCap = LineCap.Triangle : P1.EndCap = LineCap.Triangle
  181.                 G.DrawLine(P1, 6, Me.Height - 6, Me.Width - 6, Me.Height - 6)
  182.             End Using
  183.         ElseIf _SetImage = "Maximize" Then
  184.             Using P1 As New Pen(Brushes.DimGray, 2)
  185.                 P1.StartCap = LineCap.Triangle : P1.EndCap = LineCap.Triangle
  186.                 G.FillRectangle(New SolidBrush(Color.FromArgb(Hover.ToArgb)), 6, 8, 16, 13)
  187.                 G.DrawRectangle(P1, 6, 8, 16, 13)
  188.                 G.FillRectangle(New SolidBrush(Color.FromArgb(Hover.ToArgb)), 12, Me.Height - 19, 16, 13)
  189.                 G.DrawRectangle(P1, 12, Me.Height - 19, 16, 13)
  190.             End Using
  191.         ElseIf _SetImage = "Stop" Then
  192.             Dim R1 As New Rectangle(Me.Height / 2 - 6, Me.Width / 2 - 6, 12, 12)
  193.             G.FillRectangle(New SolidBrush(Color.DimGray), R1)
  194.         ElseIf _SetImage = "Play" Then
  195.             G.SmoothingMode = SmoothingMode.AntiAlias
  196.             Dim ptsArray As PointF() = {New PointF(10, 10), New PointF(Me.Width - 10, Me.Height / 2), New PointF(10, Me.Height - 10), New PointF(10, 10)}
  197.             Dim gp As New Drawing2D.GraphicsPath(Drawing2D.FillMode.Alternate)
  198.             gp.AddLines(ptsArray)
  199.             gp.CloseFigure()
  200.             G.FillPath(Brushes.DimGray, gp)
  201.         End If
  202.     End Sub
  203. End Class
  204.  
  205. Public Class btnimProperty
  206.     Inherits System.ComponentModel.StringConverter
  207.  
  208.     Public Overrides Function GetStandardValues(context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection
  209.         Return New StandardValuesCollection(myList)
  210.     End Function
  211.  
  212.     Public Overrides Function GetStandardValuesSupported(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  213.         Return True
  214.     End Function
  215.  
  216.     Public Overrides Function GetStandardValuesExclusive(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  217.         Return True
  218.     End Function
  219.  
  220.     Private Function myList() As Collections.IList
  221.         Dim imgList As New Collection
  222.  
  223.         With imgList
  224.             .Add("Close")
  225.             .Add("Minimize")
  226.             .Add("Maximize")
  227.             .Add("Stop")
  228.             .Add("Play")
  229.         End With
  230.         Return imgList
  231.     End Function
  232. End Class
  233.  
  234. Public Class AVTextbox
  235.     Inherits Control
  236.  
  237.     Dim WithEvents txtbox As New TextBox
  238.  
  239.     Private _passmask As Boolean = False
  240.     Public Shadows Property UseSystemPasswordChar() As Boolean
  241.         Get
  242.             Return _passmask
  243.         End Get
  244.         Set(ByVal v As Boolean)
  245.             txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  246.             _passmask = v
  247.             Invalidate()
  248.         End Set
  249.     End Property
  250.     Private _maxchars As Integer = 32767
  251.     Public Shadows Property MaxLength() As Integer
  252.         Get
  253.             Return _maxchars
  254.         End Get
  255.         Set(ByVal v As Integer)
  256.             _maxchars = v
  257.             txtbox.MaxLength = MaxLength
  258.             Invalidate()
  259.         End Set
  260.     End Property
  261.     Private _align As HorizontalAlignment
  262.     Public Shadows Property TextAlignment() As HorizontalAlignment
  263.         Get
  264.             Return _align
  265.         End Get
  266.         Set(ByVal v As HorizontalAlignment)
  267.             _align = v
  268.             Invalidate()
  269.         End Set
  270.     End Property
  271.     Private _multiline As Boolean = False
  272.     Public Shadows Property MultiLine() As Boolean
  273.         Get
  274.             Return _multiline
  275.         End Get
  276.         Set(ByVal value As Boolean)
  277.             _multiline = value
  278.             Invalidate()
  279.         End Set
  280.     End Property
  281.  
  282.  
  283.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  284.         MyBase.OnTextChanged(e)
  285.         Invalidate()
  286.     End Sub
  287.     Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  288.         MyBase.OnBackColorChanged(e)
  289.         txtbox.BackColor = BackColor
  290.         Invalidate()
  291.     End Sub
  292.     Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  293.         MyBase.OnForeColorChanged(e)
  294.         txtbox.ForeColor = ForeColor
  295.         Invalidate()
  296.     End Sub
  297.     Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  298.         MyBase.OnFontChanged(e)
  299.         txtbox.Font = Font
  300.     End Sub
  301.     Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  302.         MyBase.OnGotFocus(e)
  303.         txtbox.Focus()
  304.     End Sub
  305.     Sub TextChngTxtBox() Handles txtbox.TextChanged
  306.         Text = txtbox.Text
  307.     End Sub
  308.     Sub TextChng() Handles MyBase.TextChanged
  309.         txtbox.Text = Text
  310.     End Sub
  311.     Sub NewTextBox()
  312.         With txtbox
  313.             .Multiline = False
  314.             .BackColor = Color.FromArgb(43, 43, 43)
  315.             .ForeColor = ForeColor
  316.             .Text = String.Empty
  317.             .TextAlign = HorizontalAlignment.Center
  318.             .BorderStyle = BorderStyle.None
  319.             .Location = New Point(7, 5)
  320.             .Font = New Font("Verdana", 10)
  321.             .Size = New Size(Width - 10, 33)
  322.             .UseSystemPasswordChar = UseSystemPasswordChar
  323.         End With
  324.  
  325.     End Sub
  326.  
  327.     Sub New()
  328.         MyBase.New()
  329.  
  330.         NewTextBox()
  331.         Controls.Add(txtbox)
  332.  
  333.         SetStyle(ControlStyles.UserPaint, True)
  334.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  335.  
  336.         Text = ""
  337.         BackColor = Color.White
  338.         ForeColor = Color.Gray
  339.         Font = New Font("Verdana", 10)
  340.         Size = New Size(135, 33)
  341.         DoubleBuffered = True
  342.     End Sub
  343.  
  344.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  345.         Dim B As New Bitmap(Width, Height)
  346.         Dim G As Graphics = Graphics.FromImage(B)
  347.         G.SmoothingMode = SmoothingMode.HighQuality
  348.         Height = 33
  349.         With txtbox
  350.             .Width = Width - 10
  351.             .TextAlign = TextAlignment
  352.             .UseSystemPasswordChar = UseSystemPasswordChar
  353.             .Height = 33
  354.         End With
  355.  
  356.         G.Clear(Color.Transparent)
  357.         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), New Rectangle(0, 0, Width - 1, Height - 1))
  358.  
  359.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  360.         G.Dispose() : B.Dispose()
  361.     End Sub
  362. End Class
  363.  
  364. Class AVTabControl
  365.     Inherits Windows.Forms.TabControl
  366.  
  367.     Private _DrawBottomBorder As Boolean
  368.     Public Property DrawBottomBorder() As Boolean
  369.         Get
  370.             Return _DrawBottomBorder
  371.         End Get
  372.         Set(ByVal value As Boolean)
  373.             _DrawBottomBorder = value
  374.             Invalidate()
  375.         End Set
  376.     End Property
  377.  
  378.     Private _BorderColor As Pen = Pens.Black
  379.     Public Property BorderColor() As Color
  380.         Get
  381.             Return _BorderColor.Color
  382.         End Get
  383.         Set(ByVal value As Color)
  384.             _BorderColor = New Pen(value)
  385.             Invalidate()
  386.         End Set
  387.     End Property
  388.  
  389.     Private _TextAlignment As StringAlignment = StringAlignment.Near
  390.     Public Property TextAlignment() As StringAlignment
  391.         Get
  392.             Return _TextAlignment
  393.         End Get
  394.         Set(ByVal value As StringAlignment)
  395.             _TextAlignment = value
  396.             Invalidate()
  397.         End Set
  398.     End Property
  399.  
  400.     Sub New()
  401.         SetStyle(DirectCast(139286, ControlStyles), True)
  402.  
  403.         SizeMode = TabSizeMode.Fixed
  404.         Alignment = TabAlignment.Left
  405.         ItemSize = New Size(50, 50)
  406.         Font = New Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point)
  407.         DrawMode = TabDrawMode.OwnerDrawFixed
  408.  
  409.         P1 = New Pen(Color.FromArgb(94, 94, 94))
  410.         P2 = New Pen(Color.FromArgb(17, 17, 17))
  411.  
  412.         B1 = New SolidBrush(Color.FromArgb(38, 38, 38))
  413.         B2 = New SolidBrush(Color.FromArgb(35, 35, 35))
  414.         B3 = New SolidBrush(Color.FromArgb(5, Color.White))
  415.  
  416.         SF1 = New StringFormat()
  417.         SF1.LineAlignment = StringAlignment.Center
  418.  
  419.         For Each pg As TabPage In Me.TabPages
  420.             pg.BackColor = Color.FromArgb(242, 242, 242)
  421.         Next
  422.     End Sub
  423.  
  424.     Protected Overrides Sub OnControlAdded(ByVal e As ControlEventArgs)
  425.         If TypeOf e.Control Is TabPage Then
  426.             For Each i As TabPage In Me.Controls
  427.                 i = New TabPage
  428.             Next
  429.             e.Control.BackColor = Color.FromArgb(242, 242, 242)
  430.         End If
  431.  
  432.         MyBase.OnControlAdded(e)
  433.     End Sub
  434.  
  435.     Private R1, R2 As Rectangle
  436.  
  437.     Private P1, P2 As Pen
  438.     Private B1, B2, B3 As SolidBrush
  439.  
  440.     Private GB1 As LinearGradientBrush
  441.     Private GB2 As LinearGradientBrush
  442.  
  443.     Private TP1 As TabPage
  444.     Private SF1 As StringFormat
  445.  
  446.     Private ItemHeight As Integer
  447.  
  448.     Dim S1 As Size
  449.     Dim REC As New Rectangle
  450.     Dim BR1 As LinearGradientBrush
  451.  
  452.     Private G As Graphics
  453.  
  454.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  455.         Dim F1 As New System.Drawing.Font("Segoe UI", 9, FontStyle.Bold, GraphicsUnit.Point)
  456.  
  457.         G = e.Graphics
  458.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  459.         G.SmoothingMode = SmoothingMode.AntiAlias
  460.  
  461.         G.Clear(Color.FromArgb(242, 242, 242))
  462.  
  463.  
  464.         ItemHeight = ItemSize.Height + 2
  465.         G.FillRectangle(B1, 0, 0, ItemHeight, Height)
  466.         G.DrawRectangle(Pens.Black, 0, 0, ItemHeight, Height)
  467.         Dim B5 As New SolidBrush(Color.FromArgb(51, 51, 51))
  468.         Dim P5 As New Pen(B5)
  469.         For I As Integer = 0 To TabCount - 1
  470.             R1 = GetTabRect(I)
  471.             R1.Y -= 1
  472.             R1.Width += 1
  473.             R1.X -= 1
  474.             TP1 = TabPages(I)
  475.             If SelectedIndex = I Then
  476.                 Using GB1 As New LinearGradientBrush(R1, Color.FromArgb(26, 26, 26), Color.FromArgb(17, 17, 17), 90.0F)
  477.  
  478.                     Dim ColorBlend As New ColorBlend()
  479.                     ColorBlend.Colors = {Color.FromArgb(25, 25, 25), Color.FromArgb(17, 17, 17), Color.FromArgb(25, 25, 25)}
  480.                     ColorBlend.Positions = {0.0F, 0.5F, 1.0F}
  481.                     GB1.InterpolationColors = ColorBlend
  482.                     G.FillRectangle(GB1, R1)
  483.                 End Using
  484.  
  485.                 G.DrawLine(P5, R1.Left, R1.Y - 1, R1.Width + 1, R1.Y - 1)
  486.                 If HoverIndex = I Then
  487.                     G.FillRectangle(B3, R1)
  488.                 End If
  489.                 R1.X += 5
  490.                 R1.Width -= 14
  491.  
  492.                 R2 = R1
  493.                 R2.Y += 1
  494.                 R2.X += 1
  495.  
  496.                 SF1.Alignment = _TextAlignment
  497.                 G.DrawString(TP1.Text, Font, Brushes.White, New Rectangle(R2.Left + 33, R2.Top - 1, R2.Width - 43, R2.Height), SF1)
  498.                 Try
  499.                     G.DrawImage(Me.ImageList.Images.Item(TabPages(I).ImageIndex), R1.X + 1, R1.Y + 11, 32, 32)
  500.                 Catch
  501.                 End Try
  502.             Else
  503.                 Dim BR2 As New SolidBrush(Color.FromArgb(38, 38, 38))
  504.                 R1.Y -= 1
  505.                 G.FillRectangle(BR2, R1)
  506.                 G.DrawLine(P5, R1.X, R1.Y, R1.Right, R1.Y)
  507.                 If HoverIndex = I Then
  508.                     G.FillRectangle(B3, R1)
  509.                 End If
  510.                 Dim BR As New SolidBrush(Color.FromArgb(140, Color.Black))
  511.                 G.DrawLine(P2, R1.X, R1.Bottom - 1, R1.Right, R1.Bottom - 1)
  512.                 R1.X += 5
  513.                 R1.Width -= 14
  514.                 R2 = R1
  515.                 R2.Y += 1
  516.                 R2.X += 1
  517.                 SF1.Alignment = _TextAlignment
  518.                 G.DrawString(TP1.Text, Font, Brushes.Gray, New Rectangle(R2.Left + 33, R2.Top - 1, R2.Width - 43, R2.Height), SF1)
  519.                 Try
  520.                     G.DrawImage(Me.ImageList.Images.Item(TabPages(I).ImageIndex), R1.X + 2, R1.Y + 11, 32, 32)
  521.                 Catch
  522.                 End Try
  523.             End If
  524.             G.DrawLine(P5, R1.Right + 8, R1.Top, R1.Right + 8, R1.Bottom - 3)
  525.         Next
  526.  
  527.         G.DrawLine(Pens.Black, 0, 0, R2.Height - 9, 0)
  528.         G.DrawLine(_BorderColor, ItemHeight, 0, ItemHeight, Height)
  529.         G.DrawLine(P5, R1.Left - 5, ItemSize.Width * (TabCount), R1.Right + 8, ItemSize.Width * (TabCount))
  530.  
  531.         If _DrawBottomBorder Then
  532.             G.DrawLine(_BorderColor, 0, Height - 1, Width, Height - 1)
  533.         End If
  534.         G.DrawLine(P5, R1.Left - 5, ((TabCount) * (R1.Width + 12)) + (TabCount * 2), R1.Left - 5, 1)
  535.     End Sub
  536.  
  537.     Private HoverIndex As Integer = -1
  538.  
  539.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  540.         For I As Integer = 0 To TabPages.Count - 1
  541.             If GetTabRect(I).Contains(e.Location) Then
  542.                 HoverIndex = I
  543.                 Exit For
  544.             End If
  545.         Next
  546.  
  547.         Invalidate()
  548.         MyBase.OnMouseMove(e)
  549.     End Sub
  550.  
  551.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  552.         HoverIndex = -1
  553.         Invalidate()
  554.         MyBase.OnMouseLeave(e)
  555.     End Sub
  556. End Class
  557.  
  558.  
  559. Public Class AVProgressBar
  560.     Inherits Control
  561.  
  562.     Private _Value As Integer = 50
  563.     Private _Thickness As Integer = 5
  564.     Private _Angle As Integer = 0
  565.     Private _Symbol As String = "%"
  566.  
  567.     Sub New()
  568.         Size = New Size(65, 65)
  569.         Invalidate()
  570.     End Sub
  571.  
  572.     Public Property Angle() As Integer
  573.         Get
  574.             Return _Angle
  575.         End Get
  576.         Set(ByVal v As Integer)
  577.             _Angle = v : Invalidate()
  578.         End Set
  579.     End Property
  580.  
  581.     Public Property Symbol() As String
  582.         Get
  583.             Return _Symbol
  584.         End Get
  585.         Set(ByVal v As String)
  586.             _Symbol = v : Invalidate()
  587.         End Set
  588.     End Property
  589.  
  590.     Public Property Thickness() As Integer
  591.         Get
  592.             Return _Thickness
  593.         End Get
  594.         Set(ByVal v As Integer)
  595.             _Thickness = v : Invalidate()
  596.         End Set
  597.     End Property
  598.  
  599.     Protected Overrides Sub OnPaintBackground(ByVal p As PaintEventArgs)
  600.     End Sub
  601.  
  602.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  603.         MyBase.OnPaint(e)
  604.         Me.Width = Me.Height
  605.         Using B1 As New Bitmap(Width, Height)
  606.  
  607.             Using G As Graphics = Graphics.FromImage(B1)
  608.                 G.SmoothingMode = SmoothingMode.AntiAlias
  609.  
  610.  
  611.                 G.Clear(BackColor)
  612.  
  613.                 Using LGB As New LinearGradientBrush(ClientRectangle, Color.FromArgb(217, 217, 217), Color.FromArgb(217, 217, 217), LinearGradientMode.Vertical)
  614.                     Using P1 As New Pen(LGB, Thickness + 3)
  615.                         G.DrawArc(P1, CInt(Thickness / 2) + 2, CInt(Thickness / 2) + 2, Width - Thickness - 4, Height - Thickness - 4, -90, 360)
  616.                     End Using
  617.                 End Using
  618.  
  619.                 Using LGB As New LinearGradientBrush(ClientRectangle, Color.FromArgb(0, 166, 208), Color.FromArgb(0, 166, 208), LinearGradientMode.Vertical)
  620.                     Using P1 As New Pen(LGB, Thickness + 3)
  621.                         G.DrawArc(P1, CInt(Thickness / 2) + 9, CInt(Thickness / 2) + 9, Width - Thickness - 18, Height - Thickness - 18, -90, 360)
  622.                     End Using
  623.                 End Using
  624.  
  625.                 Using LGB As New LinearGradientBrush(ClientRectangle, Color.FromArgb(255, 255, 255), Color.FromArgb(255, 255, 255), LinearGradientMode.Vertical)
  626.                     Using P1 As New Pen(LGB, Thickness - 2)
  627.                         Dim i As Integer = 360 / 100 * _Value
  628.                         G.DrawArc(P1, CInt(Thickness / 2) + 9, CInt(Thickness / 2) + 9, Width - Thickness - 18, Height - Thickness - 18, -90, i)
  629.                     End Using
  630.                 End Using
  631.  
  632.  
  633.                 G.DrawString(_Value & _Symbol, New Font("Arial", 13), Brushes.Black, New Point(Me.Width / 2 - G.MeasureString(_Value & _Symbol, New Font("Arial", 13)).Width / 2 + 1, Me.Height / 2 - G.MeasureString(_Value & "%", New Font("Arial", 13)).Height / 2 + 1))
  634.             End Using
  635.             e.Graphics.DrawImage(B1, 0, 0)
  636.         End Using
  637.     End Sub
  638. End Class
  639.  
  640. Public Class AVLabel : Inherits Control
  641.  
  642.     Sub New()
  643.         Me.Size = New Size(175, 25)
  644.     End Sub
  645.  
  646.  
  647.     Private _String1 As String = "Quick Scan"
  648.     Private _String2 As String = "/ Scan running..."
  649.     Private _Img As Image
  650.  
  651.     Public Property String1() As String
  652.         Get
  653.             Return _String1
  654.         End Get
  655.         Set(v As String)
  656.             _String1 = v : Invalidate()
  657.         End Set
  658.     End Property
  659.  
  660.     Public Property String2() As String
  661.         Get
  662.             Return _String2
  663.         End Get
  664.         Set(v As String)
  665.             _String2 = v : Invalidate()
  666.         End Set
  667.     End Property
  668.  
  669.     Public Property Image As Image
  670.         Get
  671.             Return _Img
  672.         End Get
  673.         Set(v As Image)
  674.             _Img = v : Invalidate()
  675.         End Set
  676.     End Property
  677.  
  678.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  679.         MyBase.OnPaint(e)
  680.  
  681.         Dim G As Graphics
  682.         G = e.Graphics
  683.  
  684.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  685.  
  686.         G.DrawString(_String1, New Font("Segoe UI", 9, FontStyle.Bold), Brushes.DimGray, 32, 6)
  687.         G.DrawString(_String2, New Font("Segoe UI", 9), Brushes.DimGray, 33 + G.MeasureString(_String1, New Font("Segoe UI", 9, FontStyle.Bold)).Width, 6)
  688.         If Not _Img Is Nothing Then
  689.             G.DrawImage(_Img, 0, 0)
  690.         End If
  691.     End Sub
  692. End Class
  693.  
  694. Public Class AVComboBox
  695.     Inherits ComboBox
  696.  
  697.     Private _StartIndex As Integer = 0
  698.     Private C1 As Color = Color.FromArgb(254, 254, 254)
  699.     Private C2 As Color = Color.FromArgb(244, 244, 244)
  700.  
  701.     Public Property StartIndex As Integer
  702.         Get
  703.             Return _StartIndex
  704.         End Get
  705.         Set(ByVal value As Integer)
  706.             _StartIndex = value
  707.             Try
  708.                 MyBase.SelectedIndex = value
  709.             Catch
  710.             End Try
  711.             Invalidate()
  712.         End Set
  713.     End Property
  714.  
  715.     Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  716.         e.DrawBackground()
  717.         Try
  718.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  719.                 e.Graphics.FillRectangle(New SolidBrush(Color.LightGray), e.Bounds)
  720.                 Using b As New SolidBrush(e.ForeColor)
  721.                     e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Verdana", 10), b, 1, e.Bounds.Top + 5)
  722.                 End Using
  723.             Else
  724.                 e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Verdana", 10), Brushes.Gray, 1, e.Bounds.Top + 5)
  725.             End If
  726.         Catch
  727.         End Try
  728.         e.DrawFocusRectangle()
  729.         Me.Invalidate()
  730.     End Sub
  731.  
  732.     Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
  733.         Dim points As New List(Of Point)()
  734.         points.Add(FirstPoint)
  735.         points.Add(SecondPoint)
  736.         points.Add(ThirdPoint)
  737.         G.FillPolygon(New SolidBrush(Clr), points.ToArray)
  738.     End Sub
  739.  
  740.     Sub New()
  741.         Me.Width = 163
  742.         Me.Font = New Font("Verdana", 15)
  743.         Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  744.         ControlStyles.ResizeRedraw Or _
  745.         ControlStyles.UserPaint Or _
  746.         ControlStyles.DoubleBuffer, True)
  747.         Me.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  748.         Me.BackColor = C1
  749.         Me.ForeColor = C1
  750.         Me.DropDownStyle = ComboBoxStyle.DropDownList
  751.         Me.DoubleBuffered = True
  752.     End Sub
  753.  
  754.     Protected Overrides Sub OnTextChanged(e As System.EventArgs)
  755.         MyBase.OnTextChanged(e)
  756.         Invalidate()
  757.     End Sub
  758.  
  759.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  760.         C2 = Color.FromArgb(233, 233, 233)
  761.         MyBase.Invalidate()
  762.         MyBase.OnMouseClick(e)
  763.     End Sub
  764.  
  765.     Protected Overrides Sub OnMouseUp(e As System.Windows.Forms.MouseEventArgs)
  766.         C2 = Color.FromArgb(244, 244, 244)
  767.         MyBase.Invalidate()
  768.         MyBase.OnMouseUp(e)
  769.     End Sub
  770.  
  771.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  772.         MyBase.OnPaint(e)
  773.         Dim G As Graphics
  774.         G = e.Graphics
  775.  
  776.         G.FillRectangle(New SolidBrush(Color.FromArgb(C2.ToArgb)), New Rectangle(Width - 20, 2, 17, Height - 5))
  777.         G.SmoothingMode = SmoothingMode.HighQuality
  778.         Try
  779.             G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), New Rectangle(Width - 20, 2, 17, Height - 5))
  780.  
  781.             Try
  782.                 G.DrawString(Text, New Font("Verdana", 10), Brushes.Gray, New Rectangle(3, 0, Width - 20, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  783.             Catch : End Try
  784.  
  785.             G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), 0, 0, 0, 0)
  786.             G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(216, 216, 216))), New Rectangle(0, 0, Width - 1, Height - 1))
  787.  
  788.             DrawTriangle(Color.FromArgb(216, 216, 216), New Point(Width - 15, 14), New Point(Width - 8, 14), New Point(Width - 12, 17), G)
  789.         Catch
  790.         End Try
  791.     End Sub
  792. End Class
  793.  
  794. Public Class AVButton
  795.     Inherits Control
  796.  
  797.     Private Hover As Color
  798.     Private _MainColor As String
  799.     Private Loaded As Boolean
  800.  
  801.     Sub New()
  802.         Me.Size = New Size(33, 33)
  803.         Me.DoubleBuffered = True
  804.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  805.         Me.BackColor = Color.Transparent
  806.     End Sub
  807.  
  808.     <TypeConverter(GetType(btnColorProperty)), Category("Misc"), Description("Select color from the list")>
  809.     Public Property MainColor() As String
  810.         Get
  811.             Return _MainColor
  812.         End Get
  813.         Set(value As String)
  814.             _MainColor = value
  815.         End Set
  816.     End Property
  817.  
  818.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  819.  
  820.         Hover = Color.FromArgb(228, 228, 228)
  821.  
  822.         If _MainColor = "Light" Then
  823.             Hover = Color.FromArgb(228, 228, 228)
  824.         Else
  825.             Hover = Color.FromArgb(117, 117, 117)
  826.         End If
  827.  
  828.         MyBase.Invalidate()
  829.         MyBase.OnMouseEnter(e)
  830.     End Sub
  831.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  832.  
  833.         Hover = Color.FromArgb(242, 242, 242)
  834.  
  835.         If _MainColor = "Light" Then
  836.             Hover = Color.FromArgb(242, 242, 242)
  837.         Else
  838.             Hover = Color.DimGray
  839.         End If
  840.  
  841.         MyBase.Invalidate()
  842.         MyBase.OnMouseEnter(e)
  843.     End Sub
  844.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  845.         If _MainColor = "Light" Then
  846.             Hover = Color.FromArgb(228, 228, 228)
  847.         Else
  848.             Hover = Color.FromArgb(117, 117, 117)
  849.         End If
  850.         MyBase.Invalidate()
  851.         MyBase.OnMouseUp(e)
  852.     End Sub
  853.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  854.         If _MainColor = "Light" Then
  855.             Hover = Color.FromArgb(151, 151, 151)
  856.         Else
  857.             Hover = Color.FromArgb(66, 66, 66)
  858.         End If
  859.         MyBase.Invalidate()
  860.         MyBase.OnMouseClick(e)
  861.     End Sub
  862.  
  863.  
  864.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  865.         Dim P As GraphicsPath = New GraphicsPath()
  866.         Dim ArcRectangleWidth As Integer = Curve * 2
  867.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  868.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  869.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  870.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  871.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  872.         Return P
  873.     End Function
  874.  
  875.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  876.         MyBase.OnPaint(e)
  877.         Dim G As Graphics
  878.         G = e.Graphics
  879.  
  880.         If Loaded = False Then
  881.             If MainColor = "Light" Then
  882.                 Hover = Color.FromArgb(242, 242, 242)
  883.             Else
  884.                 Hover = Color.DimGray
  885.             End If
  886.             Loaded = True
  887.         End If
  888.  
  889.         G.SmoothingMode = SmoothingMode.HighQuality
  890.  
  891.         If MainColor = "Light" Then
  892.             G.FillPath(New SolidBrush(Color.FromArgb(Hover.ToArgb)), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 5))
  893.         Else
  894.             G.FillPath(New SolidBrush(Color.FromArgb(Hover.ToArgb)), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 5))
  895.         End If
  896.  
  897.         G.DrawString(Text, New Font("Verdana", 10), Brushes.Black, Me.Width / 2 - G.MeasureString(Text, New Font("Verdana", 10)).Width / 2, Me.Height / 2 - G.MeasureString(Text, New Font("Verdana", 10)).Height / 2)
  898.  
  899.         G.SmoothingMode = SmoothingMode.None
  900.     End Sub
  901. End Class
  902.  
  903. Public Class btnColorProperty
  904.     Inherits System.ComponentModel.StringConverter
  905.  
  906.     Public Overrides Function GetStandardValues(context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection
  907.         Return New StandardValuesCollection(myList)
  908.     End Function
  909.  
  910.     Public Overrides Function GetStandardValuesSupported(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  911.         Return True
  912.     End Function
  913.  
  914.     Public Overrides Function GetStandardValuesExclusive(context As System.ComponentModel.ITypeDescriptorContext) As Boolean
  915.         Return True
  916.     End Function
  917.  
  918.     Private Function myList() As Collections.IList
  919.         Dim imgList As New Collection
  920.  
  921.         With imgList
  922.             .Add("Light")
  923.             .Add("Dark")
  924.         End With
  925.         Return imgList
  926.     End Function
  927. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement