Advertisement
Guest User

VB theme

a guest
May 4th, 2014
2,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. Imports System.Threading
  3. Imports System.ComponentModel
  4. Imports System.Drawing.Text
  5. Imports System.Security
  6.  
  7.  
  8. Class BitdefenderForm : Inherits ContainerControl
  9.  
  10. #Region "Init"
  11.     Sub New()
  12.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.SupportsTransparentBackColor, True)
  13.         DoubleBuffered = True
  14.         Dock = DockStyle.Fill
  15.         BackColor = Color.Fuchsia
  16.     End Sub
  17.     Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  18.         MyBase.OnHandleCreated(e)
  19.         If FindForm() IsNot Nothing Then
  20.             FindForm.FormBorderStyle = FormBorderStyle.None : FindForm.TransparencyKey = BackColor
  21.         End If
  22.  
  23.     End Sub
  24.  
  25. #Region "Property"
  26.  
  27.     Public Overrides Property Text As String
  28.         Get
  29.             Return MyBase.Text
  30.         End Get
  31.         Set(value As String)
  32.             MyBase.Text = value
  33.             Invalidate(New Rectangle(0, 0, Width, 70), False)
  34.         End Set
  35.     End Property
  36.  
  37.  
  38.  
  39.     Private _DisableMax As Boolean
  40.     Public Property DisableControlboxMax As Boolean
  41.         Get
  42.             Return _DisableMax
  43.         End Get
  44.         Set(value As Boolean)
  45.             _DisableMax = value
  46.             Invalidate(False)
  47.         End Set
  48.     End Property
  49.  
  50.     Private _DisableMin As Boolean
  51.     Public Property DisableControlboxMin As Boolean
  52.         Get
  53.             Return _DisableMin
  54.         End Get
  55.         Set(value As Boolean)
  56.             _DisableMin = value
  57.             Invalidate(False)
  58.         End Set
  59.     End Property
  60.  
  61.     Private _DisableClose As Boolean
  62.     Public Property DisableControlboxClose As Boolean
  63.         Get
  64.             Return _DisableClose
  65.         End Get
  66.         Set(value As Boolean)
  67.             _DisableClose = value
  68.             Invalidate(False)
  69.         End Set
  70.     End Property
  71. #End Region
  72.  
  73.  
  74. #Region "Flag mouse"
  75.     Dim mouseOffset As Point
  76.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  77.         MyBase.OnMouseDown(e)
  78.         mouseOffset = New Point(-e.X, -e.Y)
  79.     End Sub
  80.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  81.         MyBase.OnMouseMove(e)
  82.  
  83.         '#Zone " Move form "
  84.        For x As Integer = 0 To Width - 1
  85.             For y As Integer = 0 To 30
  86.                 If e.Button = MouseButtons.Left AndAlso e.Location.Equals(New Point(x, y)) Then
  87.                     Dim mousePos = Control.MousePosition
  88.                     mousePos.Offset(mouseOffset.X, mouseOffset.Y)
  89.                     FindForm.Location = mousePos
  90.                 End If
  91.             Next
  92.         Next
  93.         '#End Zone
  94.  
  95.         '#Zone " None mouse flag "
  96.        MouseState = State.None
  97.         Cursor = Cursors.Default
  98.         '#End Zone
  99.  
  100.         '#Zone " minRect "
  101.        Dim minRect As Rectangle = New Rectangle(Right - Padding - (controlSize.Width + 20), Padding, btnSize.Width, btnSize.Height)
  102.         If minRect.Contains(e.Location) Then
  103.             Cursor = Cursors.Hand
  104.             MouseState = State.HoverMin
  105.         End If
  106.         '#End Zone
  107.  
  108.         '#Zone " maxRect "
  109.        Dim maxRect As New Rectangle(minRect.X + 29, minRect.Y, btnSize.Width, btnSize.Height)
  110.         If maxRect.Contains(e.Location) Then
  111.             Cursor = Cursors.Hand
  112.             MouseState = State.HoverMax
  113.         End If
  114.         '#End Zone
  115.  
  116.         '#Zone " closeRect "
  117.        Dim closeRect As New Rectangle(maxRect.X + 29, minRect.Y, btnSize.Width, btnSize.Height)
  118.         If closeRect.Contains(e.Location) Then
  119.             Cursor = Cursors.Hand
  120.             MouseState = State.HoverClose
  121.         End If
  122.         '#End Zone
  123.  
  124.  
  125.  
  126.  
  127.     End Sub
  128.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  129.         MyBase.OnMouseUp(e)
  130.         Dim min As Rectangle = New Rectangle(Right - Padding - (controlSize.Width + 20), Padding, btnSize.Width, btnSize.Height)
  131.         Dim max As New Rectangle(min.X + 29, min.Y, btnSize.Width, btnSize.Height)
  132.         Dim close As New Rectangle(max.X + 29, max.Y, btnSize.Width, btnSize.Height)
  133.  
  134.         If min.Contains(e.Location) AndAlso e.Button = MouseButtons.Left AndAlso Not DisableControlboxMin Then
  135.             FindForm.WindowState = FormWindowState.Minimized
  136.         End If
  137.  
  138.         If max.Contains(e.Location) AndAlso e.Button = MouseButtons.Left AndAlso Not DisableControlboxMax Then
  139.             Select Case FindForm.WindowState
  140.                 Case FormWindowState.Maximized
  141.                     FindForm.WindowState = FormWindowState.Normal
  142.                 Case FormWindowState.Normal
  143.                     FindForm.WindowState = FormWindowState.Maximized
  144.             End Select
  145.  
  146.         End If
  147.  
  148.         If close.Contains(e.Location) AndAlso e.Button = MouseButtons.Left AndAlso Not DisableControlboxClose Then
  149.             FindForm.Close()
  150.         End If
  151.  
  152.     End Sub
  153.  
  154. #Region "Draw mouse state"
  155.     Private Enum State
  156.         None
  157.         HoverClose
  158.         HoverMax
  159.         HoverMin
  160.     End Enum
  161.     Private _MouseState As State
  162.     Private Property MouseState As State
  163.         Get
  164.             Return _MouseState
  165.         End Get
  166.         Set(value As State)
  167.             _MouseState = value
  168.             Invalidate(False)
  169.         End Set
  170.     End Property
  171. #End Region
  172.  
  173. #End Region 'Flag mouse
  174.  
  175.  
  176. #End Region 'Init
  177.  
  178. #Region "Draw"
  179.  
  180. #Region "Init Draw Object"
  181.  
  182. #Region "Draw Object Declarations"
  183.     Private G As Graphics
  184.     Private Shadows Const Padding As Integer = 10
  185.     '#Zone " Controlbox "
  186.    Private btnSize As Size = New Size(27, 30)
  187.     Private controlSize As Size = New Size(86, btnSize.Height)
  188.     Private controlboxPath As GraphicsPath
  189.     '#End Zone
  190.  
  191.     Private R1, R2, R4, R5, R6 As Rectangle
  192.     Private GP1, GP2, GP3, GP4 As GraphicsPath
  193.     Private P1, P2, P3, P4, P5, P6 As Pen
  194.     Private B1 As SolidBrush
  195.     Private LGB1, LGB2, LGB3, LGB4, LGB5, LGB6 As LinearGradientBrush
  196.     Private C1, C2, C3, C4, C5, C6, C7, C8, C9, C10 As Color
  197.  
  198.     Private containerDisposable As New ContainerObjectDisposable
  199.  
  200. #End Region 'Draw Object Declarations
  201.  
  202.     Private Sub Init(e As PaintEventArgs)
  203.  
  204.         G = e.Graphics
  205.  
  206.         '#Zone " Rectangle "
  207.        R1 = New Rectangle(Padding, Padding, Width - Padding * 2, Height - Padding * 2)
  208.         R2 = New Rectangle(R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2)
  209.         R4 = New Rectangle(Padding, Padding, Width, 20)
  210.         R5 = New Rectangle(Right - Padding - (controlSize.Width + 20), Padding, controlSize.Width, controlSize.Height)
  211.         R6 = New Rectangle(R5.X + 1, R5.Y + 1, R5.Width - 2, R5.Height - 2)
  212.         '#End Zone
  213.  
  214.         '#Zone " Graphic path "
  215.        GP1 = RoundRect(R1, 18)
  216.         GP2 = RoundRect(R2, 18)
  217.         GP3 = ControlRect(R5, 9)
  218.         GP4 = ControlRect(R6, 9)
  219.         controlboxPath = New GraphicsPath
  220.         containerDisposable.AddObjectRange({GP1, GP2, GP3, GP4, controlboxPath})
  221.         '#End Zone
  222.  
  223.         '#Zone " Brush "
  224.        B1 = New SolidBrush(Color.FromArgb(32, 32, 32))
  225.         containerDisposable.AddObject(B1)
  226.         '#End Zone
  227.  
  228.         '#Zone " Color "
  229.        C1 = Color.FromArgb(81, 81, 81)
  230.         C2 = Color.FromArgb(43, 43, 43)
  231.         C3 = Color.FromArgb(21, 21, 21)
  232.         C4 = Color.FromArgb(10, 10, 10)
  233.         C5 = Color.FromArgb(167, 167, 167)
  234.         C6 = Color.FromArgb(83, 83, 83)
  235.         C7 = Color.FromArgb(41, 41, 41)
  236.         C8 = Color.FromArgb(33, 33, 33)
  237.         C9 = Color.FromArgb(41, 41, 41)
  238.         C10 = Color.FromArgb(77, 77, 77)
  239.         '#End Zone
  240.  
  241.         '#Zone " Linear Gradient Brush "
  242.        LGB1 = New LinearGradientBrush(R4, C1, C2, LinearGradientMode.Vertical)
  243.         LGB2 = New LinearGradientBrush(R5, C6, C7, LinearGradientMode.Vertical)
  244.         LGB3 = New LinearGradientBrush(R5, C8, C7, LinearGradientMode.Vertical)
  245.         LGB4 = New LinearGradientBrush(New Point(R5.Left + 27, R5.Top + 2), New Point(R5.Left + 27, R5.Bottom - 2), C3, C4)
  246.         LGB5 = New LinearGradientBrush(New Point(R5.Left + 28, R5.Top + 2), New Point(R5.Left + 28, R5.Bottom - 1), C5, C6)
  247.         LGB6 = New LinearGradientBrush(R5, C9, C10, LinearGradientMode.Vertical)
  248.         containerDisposable.AddObjectRange({LGB1, LGB2, LGB3, LGB4, LGB5, LGB6})
  249.  
  250.         '#End Zone
  251.  
  252.         '#Zone " Pen "
  253.        P1 = New Pen(Color.FromArgb(33, 33, 33))
  254.         P2 = New Pen(Color.FromArgb(240, 240, 240))
  255.         P3 = New Pen(LGB3)
  256.         P4 = New Pen(New SolidBrush(Color.FromArgb(83, 83, 83)))
  257.         P5 = New Pen(LGB4)
  258.         P6 = New Pen(LGB5)
  259.         containerDisposable.AddObjectRange({P1, P2, P3, P4, P5, P6})
  260.         '#End Zone
  261.  
  262.  
  263.     End Sub
  264.  
  265. #End Region 'Init Draw Object
  266.  
  267.  
  268.  
  269.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  270.         MyBase.OnPaint(e)
  271.  
  272.         ''#Zone " DebugMode "
  273. #If DEBUG Then
  274.         'Dim ST As New Stopwatch : ST.Start()
  275. #End If
  276.  
  277.         '#End Zone
  278.  
  279.         Init(e)
  280.  
  281.         '#Zone " Draw background"
  282.        G.FillPath(B1, GP1)
  283.         '#End Zone
  284.  
  285.         '#Zone " Draw header "
  286.        G.SetClip(GP2)
  287.         G.FillRectangle(LGB1, R4)
  288.         G.ResetClip()
  289.         '#End Zone
  290.  
  291.         '#Zone " Draw title "
  292.        G.DrawString(Text, New Font("Microsoft Sans Serif", 10, FontStyle.Regular), Brushes.White, 27, 22)
  293.         '#End Zone
  294.  
  295.         '#Zone " Draw border "
  296.        G.DrawPath(P1, GP1)
  297.         G.DrawPath(P2, GP2)
  298.         '#End Zone
  299.  
  300.         '#Zone " Mouse state "
  301.        Select Case MouseState
  302.             Case State.HoverClose
  303.                 DrawControlBox_Close(G)
  304.             Case State.HoverMax
  305.                 DrawControlBox_Max(G)
  306.             Case State.HoverMin
  307.                 DrawControlBox_Min(G)
  308.             Case State.None
  309.                 DrawControlBox(G)
  310.         End Select
  311.         '#End Zone
  312.  
  313.         '#Zone " Dispose all draw object "
  314.        containerDisposable.Dispose()
  315.         '#End Zone
  316.  
  317.         '#Zone " DebugMode "
  318. #If DEBUG Then
  319.         'Debug.WriteLine(ST.Elapsed.ToString)
  320. #End If
  321.  
  322.         '#End Zone
  323.  
  324.     End Sub
  325.  
  326.     Private Sub DrawControlBox(ByVal G As Graphics)
  327.  
  328.         G.SmoothingMode = SmoothingMode.HighQuality
  329.  
  330.         G.FillPath(LGB2, GP3)
  331.         G.DrawPath(P3, GP3)
  332.         G.DrawPath(P4, GP4)
  333.         '#Zone " If you want white line "
  334.        G.DrawLine(P2, R5.Left, R5.Top + 1, R5.Right, R5.Top + 1)
  335.         '#End Zone
  336.        '#Zone " Fix     !important "
  337.        G.DrawLine(P3, R5.Right, R5.Top, R5.Right, R5.Bottom - 4)
  338.         G.DrawLine(P4, R6.Right, R6.Top + 1, R6.Right, R6.Bottom - 4)
  339.  
  340.         G.SmoothingMode = SmoothingMode.Default
  341.  
  342.         G.FillRectangle(P3.Brush, New Rectangle(R5.X, R5.Y + 1, 1, 1))
  343.         G.FillRectangle(P3.Brush, New Rectangle(R5.Right, R5.Top + 1, 1, 1))
  344.         '#End Zone
  345.        '#Zone " First line "
  346.        G.DrawLine(P5, R5.Left + 29, R5.Top + 2, R5.Left + 29, R5.Bottom - 2)
  347.         G.DrawLine(P6, R5.Left + 30, R5.Top + 2, R5.Left + 30, R5.Bottom - 2)
  348.         '#End Zone
  349.        '#Zone " Second line "
  350.        G.DrawLine(P5, R5.Left + 56, R5.Top + 2, R5.Left + 56, R5.Bottom - 2)
  351.         G.DrawLine(P6, R5.Left + 57, R5.Top + 2, R5.Left + 57, R5.Bottom - 2)
  352.         '#End Zone
  353.  
  354.  
  355.  
  356.         '#Zone " close string "
  357.        controlboxPath.AddString("r", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width + 20) + 2, Padding + 8), Nothing)
  358.         G.FillPath(Brushes.White, controlboxPath)
  359.         G.DrawPath(Pens.Black, controlboxPath)
  360.         '#End Zone
  361.  
  362.         '#Zone " max string "
  363.        Select Case FindForm.WindowState
  364.             Case FormWindowState.Maximized
  365.                 controlboxPath.AddString("2", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 4, Padding + 8), Nothing)
  366.                 G.DrawPath(Pens.Black, controlboxPath)
  367.                 G.FillPath(Brushes.White, controlboxPath)
  368.  
  369.             Case FormWindowState.Normal
  370.                 controlboxPath.AddString("1", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 2, Padding + 8), Nothing)
  371.                 G.DrawPath(Pens.Black, controlboxPath)
  372.                 G.FillPath(Brushes.White, controlboxPath)
  373.         End Select
  374.         '#End Zone
  375.  
  376.         '#Zone " min string "
  377.        controlboxPath.AddString("0", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 3 + 20) + 2, Padding + 8), Nothing)
  378.         G.DrawPath(Pens.Black, controlboxPath)
  379.         G.FillPath(Brushes.White, controlboxPath)
  380.         '#End Zone
  381.  
  382.     End Sub
  383.  
  384.     Private Sub DrawControlBox_Close(ByVal G As Graphics)
  385.         G.SmoothingMode = SmoothingMode.HighQuality
  386.  
  387.         G.FillPath(LGB2, GP3)
  388.  
  389.         G.SetClip(New Rectangle(Right - Padding - (btnSize.Width + 23) + 1, Padding, btnSize.Width + 3, btnSize.Height))
  390.         G.FillPath(LGB6, GP3)
  391.         G.ResetClip()
  392.  
  393.         G.DrawPath(P3, GP3)
  394.         G.DrawPath(P4, GP4)
  395.  
  396.         '#Zone " If you want white line "
  397.        G.DrawLine(P2, R5.Left, R5.Top + 1, R5.Right, R5.Top + 1)
  398.         '#End Zone
  399.  
  400.         '#Zone " Fix     !important "
  401.        G.DrawLine(P3, R5.Right, R5.Top, R5.Right, R5.Bottom - 4)
  402.         G.DrawLine(P4, R6.Right, R6.Top + 1, R6.Right, R6.Bottom - 4)
  403.  
  404.         G.SmoothingMode = SmoothingMode.Default
  405.  
  406.         G.FillRectangle(P3.Brush, New Rectangle(R5.X, R5.Y + 1, 1, 1))
  407.         G.FillRectangle(P3.Brush, New Rectangle(R5.Right, R5.Top + 1, 1, 1))
  408.         '#End Zone
  409.  
  410.         '#Zone " First line "
  411.        G.DrawLine(P5, R5.Left + 29, R5.Top + 2, R5.Left + 29, R5.Bottom - 2)
  412.         G.DrawLine(P6, R5.Left + 30, R5.Top + 2, R5.Left + 30, R5.Bottom - 2)
  413.         '#End Zone
  414.  
  415.         '#Zone " Second line "
  416.        G.DrawLine(P5, R5.Left + 56, R5.Top + 2, R5.Left + 56, R5.Bottom - 2)
  417.         '#End Zone
  418.  
  419.         '#Zone " close string "
  420.        controlboxPath.AddString("r", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width + 20) + 2, Padding + 10), Nothing)
  421.         G.FillPath(Brushes.White, controlboxPath)
  422.         G.DrawPath(Pens.Black, controlboxPath)
  423.         '#End Zone
  424.  
  425.         '#Zone " max string "
  426.        Select Case FindForm.WindowState
  427.             Case FormWindowState.Maximized
  428.                 controlboxPath.AddString("2", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 4, Padding + 8), Nothing)
  429.                 G.DrawPath(Pens.Black, controlboxPath)
  430.                 G.FillPath(Brushes.White, controlboxPath)
  431.  
  432.             Case FormWindowState.Normal
  433.                 controlboxPath.AddString("1", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 2, Padding + 8), Nothing)
  434.                 G.DrawPath(Pens.Black, controlboxPath)
  435.                 G.FillPath(Brushes.White, controlboxPath)
  436.         End Select
  437.         '#End Zone
  438.  
  439.         '#Zone " min string "
  440.        controlboxPath.AddString("0", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 3 + 20) + 2, Padding + 8), Nothing)
  441.         G.DrawPath(Pens.Black, controlboxPath)
  442.         G.FillPath(Brushes.White, controlboxPath)
  443.         '#End Zone
  444.  
  445.     End Sub
  446.  
  447.     Private Sub DrawControlBox_Max(ByVal G As Graphics)
  448.         G.SmoothingMode = SmoothingMode.HighQuality
  449.  
  450.         G.FillPath(LGB2, GP3)
  451.  
  452.         G.SetClip(New Rectangle(Right - Padding - (btnSize.Width * 2 + 23) + 1, Padding, btnSize.Width, btnSize.Height))
  453.         G.FillPath(LGB6, GP3)
  454.         G.ResetClip()
  455.  
  456.         G.DrawPath(P3, GP3)
  457.         G.DrawPath(P4, GP4)
  458.  
  459.         '#Zone " If you want white line "
  460.        G.DrawLine(P2, R5.Left, R5.Top + 1, R5.Right, R5.Top + 1)
  461.         '#End Zone
  462.  
  463.         '#Zone " Fix     !important "
  464.        G.DrawLine(P3, R5.Right, R5.Top, R5.Right, R5.Bottom - 4)
  465.         G.DrawLine(P4, R6.Right, R6.Top + 1, R6.Right, R6.Bottom - 4)
  466.  
  467.         G.SmoothingMode = SmoothingMode.Default
  468.  
  469.         G.FillRectangle(P3.Brush, New Rectangle(R5.X, R5.Y + 1, 1, 1))
  470.         G.FillRectangle(P3.Brush, New Rectangle(R5.Right, R5.Top + 1, 1, 1))
  471.         '#End Zone
  472.  
  473.         '#Zone " First line "
  474.        G.DrawLine(P5, R5.Left + 29, R5.Top + 2, R5.Left + 29, R5.Bottom - 2)
  475.         '#End Zone
  476.  
  477.         '#Zone " Second line "
  478.        G.DrawLine(P5, R5.Left + 56, R5.Top + 2, R5.Left + 56, R5.Bottom - 2)
  479.         G.DrawLine(P6, R5.Left + 57, R5.Top + 2, R5.Left + 57, R5.Bottom - 2)
  480.         '#End Zone
  481.  
  482.         '#Zone " close string "
  483.        controlboxPath.AddString("r", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width + 20) + 2, Padding + 8), Nothing)
  484.         G.FillPath(Brushes.White, controlboxPath)
  485.         G.DrawPath(Pens.Black, controlboxPath)
  486.         '#End Zone
  487.  
  488.         '#Zone " max string "
  489.        Select Case FindForm.WindowState
  490.             Case FormWindowState.Maximized
  491.                 controlboxPath.AddString("2", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 4, Padding + 10), Nothing)
  492.                 G.DrawPath(Pens.Black, controlboxPath)
  493.                 G.FillPath(Brushes.White, controlboxPath)
  494.  
  495.             Case FormWindowState.Normal
  496.                 controlboxPath.AddString("1", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 2, Padding + 10), Nothing)
  497.                 G.DrawPath(Pens.Black, controlboxPath)
  498.                 G.FillPath(Brushes.White, controlboxPath)
  499.         End Select
  500.         '#End Zone
  501.  
  502.         '#Zone " min string "
  503.        controlboxPath.AddString("0", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 3 + 20) + 2, Padding + 8), Nothing)
  504.         G.DrawPath(Pens.Black, controlboxPath)
  505.         G.FillPath(Brushes.White, controlboxPath)
  506.         '#End Zone
  507.    End Sub
  508.  
  509.     Private Sub DrawControlBox_Min(ByVal G As Graphics)
  510.         G.SmoothingMode = SmoothingMode.HighQuality
  511.  
  512.         G.FillPath(LGB2, GP3)
  513.  
  514.         G.SetClip(New Rectangle(Right - Padding - (controlSize.Width + 20) + 1, Padding, btnSize.Width + 3, btnSize.Height))
  515.         G.FillPath(LGB6, GP3)
  516.         G.ResetClip()
  517.  
  518.         G.DrawPath(P3, GP3)
  519.         G.DrawPath(P4, GP4)
  520.  
  521.         '#Zone " If you want white line "
  522.        G.DrawLine(P2, R5.Left, R5.Top + 1, R5.Right, R5.Top + 1)
  523.         '#End Zone
  524.  
  525.         '#Zone " Fix     !important "
  526.        G.DrawLine(P3, R5.Right, R5.Top, R5.Right, R5.Bottom - 4)
  527.         G.DrawLine(P4, R6.Right, R6.Top + 1, R6.Right, R6.Bottom - 4)
  528.  
  529.         G.SmoothingMode = SmoothingMode.Default
  530.  
  531.         G.FillRectangle(P3.Brush, New Rectangle(R5.X, R5.Y + 1, 1, 1))
  532.         G.FillRectangle(P3.Brush, New Rectangle(R5.Right, R5.Top + 1, 1, 1))
  533.         '#End Zone
  534.  
  535.         '#Zone " First line "
  536.        G.DrawLine(P5, R5.Left + 29, R5.Top + 2, R5.Left + 29, R5.Bottom - 2)
  537.         G.DrawLine(P6, R5.Left + 30, R5.Top + 2, R5.Left + 30, R5.Bottom - 2)
  538.         '#End Zone
  539.  
  540.         '#Zone " Second line "
  541.        G.DrawLine(P5, R5.Left + 56, R5.Top + 2, R5.Left + 56, R5.Bottom - 2)
  542.         G.DrawLine(P6, R5.Left + 57, R5.Top + 2, R5.Left + 57, R5.Bottom - 2)
  543.  
  544.         '#End Zone
  545.  
  546.         '#Zone " close string "
  547.        controlboxPath.AddString("r", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width + 20) + 2, Padding + 8), Nothing)
  548.         G.FillPath(Brushes.White, controlboxPath)
  549.         G.DrawPath(Pens.Black, controlboxPath)
  550.         '#End Zone
  551.  
  552.         '#Zone " max string "
  553.        Select Case FindForm.WindowState
  554.             Case FormWindowState.Maximized
  555.                 controlboxPath.AddString("2", New FontFamily("Webdings"), FontStyle.Regular, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 4, Padding + 8), Nothing)
  556.                 G.DrawPath(Pens.Black, controlboxPath)
  557.                 G.FillPath(Brushes.White, controlboxPath)
  558.  
  559.             Case FormWindowState.Normal
  560.                 controlboxPath.AddString("1", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 2 + 20) + 2, Padding + 8), Nothing)
  561.                 G.DrawPath(Pens.Black, controlboxPath)
  562.                 G.FillPath(Brushes.White, controlboxPath)
  563.         End Select
  564.         '#End Zone
  565.  
  566.         '#Zone " min string "
  567.        controlboxPath.AddString("0", New FontFamily("Webdings"), FontStyle.Bold, 15, New Point(Right - Padding - (btnSize.Width * 3 + 20) + 2, Padding + 10), Nothing)
  568.         G.DrawPath(Pens.Black, controlboxPath)
  569.         G.FillPath(Brushes.White, controlboxPath)
  570.         '#End Zone
  571.    End Sub
  572.  
  573.  
  574.     Private Function ControlRect(ByVal R As Rectangle, ByVal radius As Integer)
  575.         Dim GP As New GraphicsPath
  576.         GP.AddArc(R.Right - radius, R.Bottom - radius, radius, radius, 0, 90)
  577.         GP.AddArc(R.X, R.Bottom - radius, radius, radius, 90, 90)
  578.         GP.AddLine(R.Left, R.Top, R.Right, R.Top)
  579.         Return GP
  580.     End Function
  581.  
  582.  
  583. #End Region 'Draw
  584.  
  585. End Class
  586.  
  587. Class BitdefenderSeparator : Inherits Control
  588.     Sub New()
  589.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  590.         Width = 400
  591.         Height = 3
  592.         BackColor = Color.Transparent
  593.     End Sub
  594.  
  595. #Region "Declarations"
  596.     Private G As Graphics
  597.     Private LGB1, LGB2 As LinearGradientBrush
  598.     Private P1, P2 As Pen
  599.     Private CB1, CB2 As ColorBlend
  600.     Private C1, C2 As Color
  601.     Private conObj As New ContainerObjectDisposable
  602. #End Region 'Declarations
  603.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  604.         MyBase.OnPaint(e)
  605.         '#Zone " Declarations "
  606.        Dim Colors1, Colors2 As New List(Of Color)
  607.  
  608.         C1 = Color.FromArgb(62, 62, 62)
  609.         C2 = Color.FromArgb(1, 1, 1)
  610.  
  611.         G = e.Graphics
  612.  
  613.         LGB1 = New LinearGradientBrush(New Point(0, 0), New Point(Width, 0), Nothing, Nothing)
  614.         LGB2 = New LinearGradientBrush(New Point(0, 1), New Point(Width, 1), Nothing, Nothing)
  615.         conObj.AddObjectRange({LGB1, LGB2})
  616.  
  617.         CB1 = New ColorBlend
  618.         CB2 = New ColorBlend
  619.         '#End Zone
  620.  
  621.         '#Zone " Colors first line "
  622.        For i As Integer = 0 To 255 Step 51
  623.             Colors1.Add(Color.FromArgb(i, C1))
  624.         Next
  625.         For i As Integer = 255 To 0 Step -51
  626.             Colors1.Add(Color.FromArgb(i, C1))
  627.         Next
  628.         '#End Zone
  629.  
  630.         '#Zone " Colors Second line "
  631.        For i As Integer = 0 To 255 Step 51
  632.             Colors2.Add(Color.FromArgb(i, C2))
  633.         Next
  634.         For i As Integer = 255 To 0 Step -51
  635.             Colors2.Add(Color.FromArgb(i, C2))
  636.         Next
  637.         '#End Zone
  638.  
  639.         '#Zone " colorblend first line  "
  640.        CB1.Colors = Colors1.ToArray
  641.         CB1.Positions = {0.0, 0.08, 0.16, 0.24, 0.32, 0.4, 0.48, 0.56, 0.64, 0.72, 0.8, 1.0}
  642.         '#End Zone
  643.  
  644.         '#Zone " colorblend second line "
  645.        CB2.Colors = Colors2.ToArray
  646.         CB2.Positions = {0.0, 0.08, 0.16, 0.24, 0.32, 0.4, 0.48, 0.56, 0.64, 0.72, 0.8, 1.0}
  647.         '#End Zone
  648.  
  649.         '#Zone " Pen "
  650.        LGB1.InterpolationColors = CB1
  651.         LGB2.InterpolationColors = CB2
  652.  
  653.         P1 = New Pen(LGB1)
  654.         P2 = New Pen(LGB2)
  655.         conObj.AddObjectRange({P1, P2})
  656.         '#End Zone
  657.  
  658.         G.DrawLine(P1, 0, 0, Width, 0)
  659.         G.DrawLine(P2, 0, 1, Width, 1)
  660.  
  661.         conObj.Dispose()
  662.     End Sub
  663. End Class
  664.  
  665. <DefaultEvent("ChangeChecked")>
  666. Class BitdefenderCheckbox : Inherits Control
  667. #Region "Init"
  668. #Region "Event"
  669.     Public Event ChangeChecked(ByVal sender As Object, ByVal check As Boolean)
  670.     Private _Check As Boolean
  671.     Public Property Checked As Boolean
  672.         Get
  673.             Return _Check
  674.         End Get
  675.         Set(value As Boolean)
  676.             _Check = value
  677.             Invalidate()
  678.  
  679.             RaiseEvent ChangeChecked(Me, value)
  680.         End Set
  681.     End Property
  682.  
  683.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  684.         MyBase.OnMouseUp(e) : Checked = Not Checked
  685.     End Sub
  686.  
  687. #End Region 'Event
  688.  
  689.     Sub New()
  690.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  691.         Width = 55
  692.         Height = 25
  693.         BackColor = Color.Transparent
  694.         oldsize = New Size(55, 25)
  695.     End Sub
  696. #End Region 'Init
  697.  
  698. #Region "draw"
  699.  
  700. #Region "draw init object"
  701.  
  702. #Region "Declaration draw object"
  703.     Private cn As ContainerObjectDisposable
  704.     Private R1, R2, R3, R4, R5, R6 As Rectangle
  705.     Private GP1, GP2, GP3, GP4, GP5, GP6 As GraphicsPath
  706.     Private LGB1, LGB2, LGB3, LGB4 As LinearGradientBrush
  707.     Private PGB1 As PathGradientBrush
  708.     Private B1, B2, B3 As SolidBrush
  709.     Private G As Graphics
  710.     Private P1, P2 As Pen
  711.     Dim CheckSize As Size
  712. #End Region 'Declaration draw object
  713.    Private Sub Init(e As PaintEventArgs)
  714.         G = e.Graphics
  715.         cn = New ContainerObjectDisposable
  716.         R1 = New Rectangle(1, 1, Width - 2, Height - 2)
  717.         R2 = New Rectangle(2, 2, Width - 4, Height - 4)
  718.  
  719.         GP1 = RoundRect(R1, 11) : cn.AddObject(GP1)
  720.         GP2 = RoundRect(R2, 11) : cn.AddObject(GP2)
  721.  
  722.         B1 = New SolidBrush(Color.FromArgb(40, 40, 40)) : cn.AddObject(B1)
  723.         If Checked Then
  724.             B2 = New SolidBrush(Color.FromArgb(84, 135, 171))
  725.             PGB1 = New PathGradientBrush(GP2) With {.CenterColor = Color.FromArgb(84, 135, 171), .SurroundColors = {Color.FromArgb(113, 176, 200)}, .FocusScales = New PointF(0.85, 0.65)}
  726.  
  727.         Else
  728.             B2 = New SolidBrush(Color.FromArgb(29, 29, 29))
  729.             PGB1 = New PathGradientBrush(GP2) With {.CenterColor = Color.FromArgb(29, 29, 29), .SurroundColors = {Color.FromArgb(39, 39, 39)}, .FocusScales = New PointF(0.85, 0.65)}
  730.         End If
  731.         cn.AddObjectRange({B2, PGB1})
  732.         B3 = New SolidBrush(Color.FromArgb(107, 107, 107))
  733.         cn.AddObject(B3)
  734.  
  735.         CheckSize = New Size(22, R2.Height)
  736.         R3 = New Rectangle(Width - 2 - 22, 2, CheckSize.Width, CheckSize.Height)
  737.         GP3 = RoundRect(R3, 11)
  738.         R4 = New Rectangle(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2)
  739.         GP4 = RoundRect(R4, 11)
  740.  
  741.         R5 = New Rectangle(0, 2, CheckSize.Width, CheckSize.Height)
  742.         GP5 = RoundRect(R5, 11)
  743.         R6 = New Rectangle(R5.X + 1, R5.Y + 1, R5.Width - 2, R5.Height - 2)
  744.         GP6 = RoundRect(R6, 11)
  745.         cn.AddObjectRange({GP3, GP4, GP5, GP6})
  746.         If Hover Then
  747.             LGB1 = New LinearGradientBrush(R3, Color.FromArgb(86, 86, 86), Color.FromArgb(42, 42, 42), LinearGradientMode.Vertical)
  748.             LGB2 = New LinearGradientBrush(New Rectangle(R4.X - 1, R4.Y - 1, R4.Width + 2, R4.Height + 2), Color.FromArgb(147, 147, 147), Color.FromArgb(68, 68, 68), LinearGradientMode.Vertical)
  749.             P1 = New Pen(LGB2)
  750.  
  751.             LGB3 = New LinearGradientBrush(R5, Color.FromArgb(86, 86, 86), Color.FromArgb(42, 42, 42), LinearGradientMode.Vertical)
  752.             LGB4 = New LinearGradientBrush(New Rectangle(R6.X - 1, R6.Y - 1, R6.Width + 2, R6.Height + 2), Color.FromArgb(147, 147, 147), Color.FromArgb(68, 68, 68), LinearGradientMode.Vertical)
  753.             P2 = New Pen(LGB4)
  754.  
  755.         Else
  756.             LGB1 = New LinearGradientBrush(R3, Color.FromArgb(59, 59, 59), Color.FromArgb(29, 29, 29), LinearGradientMode.Vertical)
  757.             LGB2 = New LinearGradientBrush(New Rectangle(R4.X - 1, R4.Y - 1, R4.Width + 2, R4.Height + 2), Color.FromArgb(101, 101, 101), Color.FromArgb(42, 42, 42), LinearGradientMode.Vertical)
  758.             P1 = New Pen(LGB2)
  759.  
  760.             LGB3 = New LinearGradientBrush(R5, Color.FromArgb(59, 59, 59), Color.FromArgb(29, 29, 29), LinearGradientMode.Vertical)
  761.             LGB4 = New LinearGradientBrush(New Rectangle(R6.X - 1, R6.Y - 1, R6.Width + 2, R6.Height + 2), Color.FromArgb(101, 101, 101), Color.FromArgb(42, 42, 42), LinearGradientMode.Vertical)
  762.             P2 = New Pen(LGB4)
  763.  
  764.         End If
  765.         cn.AddObjectRange({LGB1, LGB2, LGB3, LGB4, P1, P2})
  766.  
  767.  
  768.     End Sub
  769. #End Region 'draw init object
  770.  
  771.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  772.         MyBase.OnPaint(e)
  773.         Init(e)
  774.         G.SmoothingMode = SmoothingMode.AntiAlias
  775.         G.InterpolationMode = InterpolationMode.HighQualityBicubic
  776.         G.FillPath(B1, GP1)
  777.  
  778.         If Checked Then
  779.  
  780.             G.FillPath(B2, GP2)
  781.             G.FillPath(PGB1, GP2)
  782.             G.DrawPath(Pens.Black, GP2)
  783.             If Hover Then
  784.                 G.FillPath(LGB1, GP3)
  785.                 G.DrawPath(Pens.Black, GP3)
  786.                 G.DrawPath(P1, GP4)
  787.                 G.DrawString("ON", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), Brushes.Black, 7, 6)
  788.                 G.DrawString("ON", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), Brushes.White, 7, 7)
  789.             Else
  790.                 G.FillPath(LGB1, GP3)
  791.                 G.DrawPath(Pens.Black, GP3)
  792.                 G.DrawPath(P1, GP4)
  793.                 G.DrawString("ON", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), Brushes.Black, 7, 6)
  794.                 G.DrawString("ON", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), Brushes.White, 7, 7)
  795.             End If
  796.         Else
  797.             G.FillPath(B1, GP1)
  798.             G.FillPath(B2, GP2)
  799.             G.FillPath(PGB1, GP2)
  800.             G.DrawPath(Pens.Black, GP2)
  801.             If Hover Then
  802.                 G.FillPath(LGB3, GP5)
  803.                 G.DrawPath(Pens.Black, GP5)
  804.                 G.DrawPath(P2, GP6)
  805.                 G.DrawString("OFF", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), Brushes.Black, Width - 29, 6)
  806.                 G.DrawString("OFF", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), B3, Width - 29, 7)
  807.             Else
  808.                 G.FillPath(LGB3, GP5)
  809.                 G.DrawPath(Pens.Black, GP5)
  810.                 G.DrawPath(P2, GP6)
  811.                 G.DrawString("OFF", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), Brushes.Black, Width - 29, 6)
  812.                 G.DrawString("OFF", New Font("Microsoft Sans Serif", 7, FontStyle.Bold), B3, Width - 29, 7)
  813.             End If
  814.  
  815.         End If
  816.         cn.Dispose()
  817.     End Sub
  818.     Private _Hover As Boolean
  819.     Private Property Hover As Boolean
  820.         Get
  821.             Return _Hover
  822.         End Get
  823.         Set(value As Boolean)
  824.             _Hover = value
  825.             Invalidate()
  826.         End Set
  827.     End Property
  828.     Protected Overrides Sub onmouseenter(ByVal e As EventArgs)
  829.         MyBase.OnMouseEnter(e)
  830.         Hover = True
  831.     End Sub
  832.     Protected Overrides Sub onmouseleave(ByVal e As EventArgs)
  833.         MyBase.OnMouseLeave(e)
  834.         Hover = False
  835.     End Sub
  836.     Dim oldsize As Size
  837.  
  838.     Protected Overrides Sub onclientsizechanged(e As EventArgs)
  839.         MyBase.OnClientSizeChanged(e)
  840.         Me.Size = oldsize
  841.  
  842.     End Sub
  843. #End Region 'draw
  844.  
  845. End Class
  846.  
  847. Class BitdefenderButton : Inherits Control
  848.  
  849. #Region "Init"
  850.     Sub New()
  851.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  852.         Width = 100
  853.         Height = 55
  854.         BackColor = Color.Transparent
  855.     End Sub
  856.  
  857.  
  858.     Public Overrides Property Text As String
  859.         Get
  860.             Return MyBase.Text
  861.         End Get
  862.         Set(value As String)
  863.             MyBase.Text = value
  864.             Invalidate()
  865.         End Set
  866.     End Property
  867.  
  868.     Private _Down As Boolean
  869.     Private Property Down As Boolean
  870.         Get
  871.             Return _Down
  872.         End Get
  873.         Set(value As Boolean)
  874.             _Down = value
  875.             Invalidate()
  876.         End Set
  877.     End Property
  878.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  879.         MyBase.OnMouseDown(e) : Down = True
  880.     End Sub
  881.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  882.         MyBase.OnMouseUp(e) : Down = False
  883.     End Sub
  884.  
  885. #Region "Mouse state"
  886.  
  887.     Private OpenT As Thread
  888.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  889.         MyBase.OnMouseEnter(e)
  890.         OpenT = New Thread(AddressOf EnterAnimation)
  891.         If Not OpenT.IsAlive Then
  892.             OpenT.IsBackground = True
  893.             OpenT.Start()
  894.         End If
  895.     End Sub
  896.     Private Sub EnterAnimation()
  897.         Dim G As Graphics = Me.CreateGraphics()
  898.         R2 = New Rectangle(5, 5, Width - 10, Height - 10)
  899.         GP2 = RoundRect(R2, 11)
  900.         G.SetClip(GP2)
  901.         For fade As Integer = 0 To 5 Step 0.85
  902.             Thread.Sleep(50)
  903.             G.FillRectangle(New SolidBrush(Color.FromArgb(fade, Color.White)), ClientRectangle)
  904.         Next
  905.     End Sub
  906.  
  907.  
  908. #End Region 'Mouse state
  909.  
  910. #End Region 'Init
  911.  
  912.  
  913. #Region "Draw"
  914. #Region "Draw init Object"
  915.     Private C1, C3, C4, C5, C6 As Color
  916.     Private R1, R2, R3 As Rectangle
  917.     Private GP1, GP2, GP3 As GraphicsPath
  918.     Private B1, B2 As SolidBrush
  919.     Private P1, P2 As Pen
  920.     Private LGB1, LGB2 As LinearGradientBrush
  921.     Private SF1 As StringFormat
  922.     Private G As Graphics
  923.  
  924.     Private Sub Init(e As PaintEventArgs)
  925.         G = e.Graphics
  926.         R1 = New Rectangle(3, 3, Width - 6, Height - 6)
  927.         R2 = New Rectangle(5, 5, Width - 10, Height - 10)
  928.         R3 = New Rectangle(6, 6, Width - 12, Height - 12)
  929.  
  930.         GP1 = RoundRect(R1, 11)
  931.         GP2 = RoundRect(R2, 11)
  932.         GP3 = RoundRect(R3, 11)
  933.  
  934.        
  935.         C1 = Color.FromArgb(100, 41, 41, 41)
  936.         C3 = Color.FromArgb(101, 101, 101)
  937.         C4 = Color.FromArgb(60, 60, 60)
  938.         C5 = Color.FromArgb(28, 28, 28)
  939.         C6 = Color.FromArgb(45, 45, 45)
  940.  
  941.         B1 = New SolidBrush(C1)
  942.         B2 = Brushes.White
  943.         LGB1 = New LinearGradientBrush(R2, C4, C5, LinearGradientMode.Vertical)
  944.         LGB2 = New LinearGradientBrush(R3, C3, C6, LinearGradientMode.Vertical)
  945.  
  946.         P1 = New Pen(Brushes.Black)
  947.         P2 = New Pen(LGB2)
  948.  
  949.         SF1 = New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.Character}
  950.  
  951.  
  952.     End Sub
  953. #End Region 'Draw init Object
  954.  
  955.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  956.         MyBase.OnPaint(e)
  957.         Init(e)
  958.         G.SmoothingMode = SmoothingMode.HighQuality
  959.         G.FillPath(B1, GP1)
  960.         G.FillPath(LGB1, GP2)
  961.         G.DrawPath(P1, GP2)
  962.         G.DrawPath(P2, GP3)
  963.         If Not Down Then
  964.             G.DrawString(Text, Font, B2, R3, SF1)
  965.         Else
  966.             R3.X += 1 : R3.Y += 1
  967.             G.DrawString(Text, Font, B2, R3, SF1)
  968.         End If
  969.  
  970.  
  971.     End Sub
  972.  
  973.  
  974. #End Region 'Draw
  975.  
  976. End Class
  977.  
  978. Class BitdefenderGroupbox : Inherits ContainerControl
  979.     Sub New()
  980.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  981.         Width = 100
  982.         Height = 55
  983.         BackColor = Color.Transparent
  984.     End Sub
  985.  
  986. #Region "property"
  987.     <Browsable(False)>
  988.     Public Overloads Property Text As String
  989.  
  990.     Private _Title As String = "Title"
  991.     Private _SubTitle As String = "Subtitle"
  992.  
  993.     Public Property Title As String
  994.         Get
  995.             Return _Title
  996.         End Get
  997.         Set(value As String)
  998.             _Title = value
  999.             Invalidate(False)
  1000.         End Set
  1001.     End Property
  1002.     Public Property Subtitle As String
  1003.         Get
  1004.             Return _SubTitle
  1005.         End Get
  1006.         Set(value As String)
  1007.             _SubTitle = value
  1008.             Invalidate(False)
  1009.         End Set
  1010.     End Property
  1011. #End Region 'property
  1012.  
  1013.  
  1014.     Private R1, R2 As Rectangle
  1015.     Private GP1, GP2 As GraphicsPath
  1016.     Private P1, P2 As Pen
  1017.     Private B1, B2 As SolidBrush
  1018.     Private SZ1, SZ2 As Size
  1019.     Private F1, F2 As Font
  1020.     Private S1, S2 As String
  1021.     Private G As Graphics
  1022.     Private Sub Init(e As PaintEventArgs)
  1023.         G = e.Graphics
  1024.  
  1025.         R1 = New Rectangle(3, 3, Width - 6, Height - 6)
  1026.         R2 = New Rectangle(4, 4, Width - 8, Height - 8)
  1027.  
  1028.         GP1 = RoundRect(R1, 11)
  1029.         GP2 = RoundRect(R2, 11)
  1030.  
  1031.         P1 = Pens.Black
  1032.         P2 = New Pen(New SolidBrush(Color.FromArgb(68, 68, 68)))
  1033.  
  1034.         B1 = New SolidBrush(Color.FromArgb(41, 41, 41))
  1035.         B2 = Brushes.White
  1036.  
  1037.         F1 = New Font("Verdana", 10, FontStyle.Bold)
  1038.         F2 = New Font("Verdana", 7, FontStyle.Regular)
  1039.  
  1040.         S1 = Title.ToUpper
  1041.         S2 = Subtitle
  1042.  
  1043.         SZ1 = G.MeasureString(S1, F1, Width).ToSize
  1044.         SZ2 = G.MeasureString(S2, F2, Width).ToSize
  1045.  
  1046.     End Sub
  1047.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1048.         MyBase.OnPaint(e) : Init(e)
  1049.         G.SmoothingMode = SmoothingMode.HighQuality
  1050.         G.FillPath(B1, GP1)
  1051.  
  1052.         G.DrawPath(P1, GP1)
  1053.         G.DrawPath(P2, GP2)
  1054.  
  1055.         G.DrawString(S1, F1, B2, CInt((Width - SZ1.Width) / 2), 20)
  1056.         G.DrawString(S2, F2, B2, CInt((Width - SZ2.Width) / 2), 32)
  1057.  
  1058.     End Sub
  1059. End Class
  1060.  
  1061. Class BitdefenderRadiobutton : Inherits Control
  1062. #Region "Init"
  1063. #Region "Event"
  1064.     Public Event ChangeChecked(ByVal sender As Object, ByVal check As Boolean)
  1065.     Private _Check As Boolean
  1066.     Public Property Checked As Boolean
  1067.         Get
  1068.             Return _Check
  1069.         End Get
  1070.         Set(value As Boolean)
  1071.             _Check = value
  1072.             Invalidate()
  1073.  
  1074.             RaiseEvent ChangeChecked(Me, value)
  1075.         End Set
  1076.     End Property
  1077.  
  1078.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1079.         MyBase.OnMouseUp(e) : Checked = Not Checked
  1080.     End Sub
  1081.  
  1082. #End Region 'Event
  1083.    Private oldHeight As Integer
  1084.     Sub New()
  1085.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
  1086.         Width = 100
  1087.         Height = 15
  1088.         BackColor = Color.Transparent
  1089.         oldHeight = 15
  1090.     End Sub
  1091.  
  1092.     Protected Overrides Sub OnClientSizeChanged(ByVal e As EventArgs)
  1093.         MyBase.OnClientSizeChanged(e) : Height = oldHeight
  1094.     End Sub
  1095.  
  1096.     Public Overrides Property Text() As String
  1097.         Get
  1098.             Return MyBase.Text
  1099.         End Get
  1100.         Set(value As String)
  1101.             MyBase.Text = value
  1102.             Invalidate()
  1103.         End Set
  1104.     End Property
  1105. #End Region 'Init
  1106.  
  1107.  
  1108.  
  1109.     Private R1, R2, R3 As Rectangle
  1110.     Private GP1, GP2, GP3 As GraphicsPath
  1111.     Private LGB1, LGB2 As LinearGradientBrush
  1112.     Private P1, P2 As Pen
  1113.     Private G As Graphics
  1114.     Private S1 As String
  1115.     Private F1 As Font
  1116.     Private Sub Init(e As PaintEventArgs)
  1117.         G = e.Graphics
  1118.  
  1119.         R1 = New Rectangle(0, 0, Height - 1, Height - 1)
  1120.         R2 = New Rectangle(R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2)
  1121.         R3 = New Rectangle(r2.X + 1, r2.Y + 1, R2.width-2,R2.Height-2)
  1122.  
  1123.         GP1 = New GraphicsPath : GP1.AddEllipse(R1)
  1124.         GP2 = New GraphicsPath : GP2.AddEllipse(R2)
  1125.         GP3 = New GraphicsPath : GP3.AddEllipse(R3)
  1126.  
  1127.         LGB1 = New LinearGradientBrush(R1, Color.FromArgb(29, 29, 29), Color.FromArgb(39, 39, 39), LinearGradientMode.Vertical)
  1128.         LGB2 = New LinearGradientBrush(R3, Color.FromArgb(84, 135, 171), Color.FromArgb(113, 176, 200), LinearGradientMode.Vertical)
  1129.  
  1130.         P1 = Pens.Black
  1131.         P2 = New Pen(New SolidBrush(Color.FromArgb(68, 68, 68)))
  1132.  
  1133.         S1 = Text
  1134.  
  1135.         F1 = New Font("Verdana", 8, FontStyle.Regular)
  1136.     End Sub
  1137.  
  1138.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1139.         MyBase.OnPaint(e) : Init(e)
  1140.         G.InterpolationMode = InterpolationMode.HighQualityBicubic
  1141.         G.SmoothingMode = SmoothingMode.AntiAlias
  1142.         If Checked Then
  1143.             G.FillPath(LGB2, GP3)
  1144.             G.DrawPath(P1, GP3)
  1145.             G.DrawPath(P2, GP2)
  1146.             G.DrawString(S1, F1, New SolidBrush(Color.FromArgb(106, 166, 193)), 18, 1)
  1147.         Else
  1148.             G.FillPath(LGB1, GP1)
  1149.             G.DrawPath(P1, GP1)
  1150.             G.DrawPath(P2, GP2)
  1151.             G.DrawString(S1, F1, New SolidBrush(Color.FromArgb(147, 147, 147)), 18, 1)
  1152.         End If
  1153.  
  1154.     End Sub
  1155. End Class
  1156.  
  1157.  
  1158. Class ContainerObjectDisposable : Implements IDisposable
  1159.     Private iList As New List(Of IDisposable)
  1160.  
  1161.     Public Sub AddObject(ByVal Obj As IDisposable)
  1162.         iList.Add(Obj)
  1163.     End Sub
  1164.     Public Sub AddObjectRange(ByVal Obj() As IDisposable)
  1165.         iList.AddRange(Obj)
  1166.     End Sub
  1167. #Region "IDisposable Support"
  1168.     Private disposedValue As Boolean
  1169.     Protected Overridable Sub Dispose(disposing As Boolean)
  1170.         If Not Me.disposedValue Then
  1171.             If disposing Then
  1172.                 For Each ObjectDisposable As IDisposable In iList
  1173.                     ObjectDisposable.Dispose()
  1174. #If DEBUG Then
  1175.                     Debug.WriteLine("Dispose : " & ObjectDisposable.ToString)
  1176. #End If
  1177.                 Next
  1178.             End If
  1179.  
  1180.         End If
  1181.         iList.Clear()
  1182.         Me.disposedValue = True
  1183.     End Sub
  1184.     Public Sub Dispose() Implements IDisposable.Dispose
  1185.         Dispose(True)
  1186.         GC.SuppressFinalize(Me)
  1187.     End Sub
  1188. #End Region
  1189.  
  1190. End Class
  1191.  
  1192. Module Helper
  1193.  
  1194.     Friend Function RoundRect(ByVal R As Rectangle, radius As Integer) As GraphicsPath
  1195.         Dim GP As New GraphicsPath
  1196.         GP.AddArc(R.X, R.Y, radius, radius, 180, 90)
  1197.         GP.AddArc(R.Right - radius, R.Y, radius, radius, 270, 90)
  1198.         GP.AddArc(R.Right - radius, R.Bottom - radius, radius, radius, 0, 90)
  1199.         GP.AddArc(R.X, R.Bottom - radius, radius, radius, 90, 90)
  1200.         GP.CloseFigure()
  1201.         Return GP
  1202.     End Function
  1203.  
  1204. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement