SqLasticSoftware

Avast

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