Advertisement
Guest User

Kaspersky Theme

a guest
May 4th, 2014
2,481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '
  2. ' * Kaspersky 2014 Theme
  3. ' * v1.0.0.0
  4. ' * by Guilherme Santos
  5. ' * guilhermesantos97@live.com
  6. '
  7.  
  8.  
  9. Imports System.Collections.Generic
  10. Imports System.Drawing
  11. Imports System.Drawing.Drawing2D
  12. Imports System.Runtime.InteropServices
  13. Imports System.Text
  14. Imports System.Windows.Forms
  15.  
  16. Namespace Themes_CSharp
  17.     Public Class Kaspersky2014Form
  18.         Inherits Form
  19.  
  20.         Protected Const WM_NCLBUTTONDOWN As Integer = &Ha1
  21.         Protected Const HT_CAPTION As Integer = &H2
  22.  
  23.         <DllImport("user32.dll")> _
  24.         Private Shared Function SendMessage(hWnd As IntPtr, Msg As Integer, wParam As Integer, lParam As Integer) As IntPtr
  25.         End Function
  26.  
  27.         Public Declare Auto Function ReleaseCapture Lib "user32.dll" () As Boolean
  28.  
  29.         Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  30.             If e.Button = MouseButtons.Left Then
  31.                 ReleaseCapture()
  32.                 SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
  33.             End If
  34.         End Sub
  35.  
  36.         Private closeButton As Kaspersky2014CloseButton
  37.         Private minimizeButton As Kaspersky2014MinimizeButton
  38.  
  39.         Public Sub New()
  40.             Me.FormBorderStyle = FormBorderStyle.None
  41.  
  42.             closeButton = New Kaspersky2014CloseButton()
  43.             minimizeButton = New Kaspersky2014MinimizeButton()
  44.  
  45.             closeButton.Size = New Size(40, 23)
  46.             minimizeButton.Size = New Size(32, 23)
  47.  
  48.             closeButton.Left = (Me.Width - closeButton.Width) - 15
  49.             minimizeButton.Left = closeButton.Left - minimizeButton.Width
  50.  
  51.             closeButton.Top = border + 1
  52.             minimizeButton.Top = border + 1
  53.  
  54.             Me.Controls.Add(closeButton)
  55.             Me.Controls.Add(minimizeButton)
  56.         End Sub
  57.  
  58.         Private m_headerHeight As Integer = 80
  59.         Public Property HeaderHeight() As Integer
  60.             Get
  61.                 Return m_headerHeight
  62.             End Get
  63.             Set
  64.                 m_headerHeight = value
  65.                 Me.Invalidate()
  66.             End Set
  67.         End Property
  68.  
  69.         Private m_footerHeight As Integer = 50
  70.         Public Property FooterHeight() As Integer
  71.             Get
  72.                 Return m_footerHeight
  73.             End Get
  74.             Set
  75.                 m_footerHeight = value
  76.                 Me.Invalidate()
  77.             End Set
  78.         End Property
  79.  
  80.         Private m_headerText As String
  81.         Public Property HeaderText() As String
  82.             Get
  83.                 Return m_headerText
  84.             End Get
  85.             Set
  86.                 m_headerText = value
  87.                 Me.Invalidate()
  88.             End Set
  89.         End Property
  90.  
  91.         Private m_headerFont As New Font("Tahoma", 12F)
  92.         Public Property HeaderFont() As Font
  93.             Get
  94.                 Return m_headerFont
  95.             End Get
  96.             Set
  97.                 m_headerFont = value
  98.                 Me.Invalidate()
  99.             End Set
  100.         End Property
  101.  
  102.         Private m_showDropShadow As Boolean = True
  103.         Public Property ShowDropShadow() As Boolean
  104.             Get
  105.                 Return m_showDropShadow
  106.             End Get
  107.             Set
  108.                 m_showDropShadow = value
  109.                 Me.Invalidate()
  110.             End Set
  111.         End Property
  112.  
  113.         Private border As Integer = 4
  114.         Private dropShadowHeight As Integer = 25
  115.  
  116.         Protected Overrides Sub OnResize(e As EventArgs)
  117.             MyBase.OnResize(e)
  118.             closeButton.Left = (Me.Width - closeButton.Width) - 15
  119.             minimizeButton.Left = closeButton.Left - minimizeButton.Width
  120.         End Sub
  121.  
  122.         Protected Overrides Sub OnPaint(e As PaintEventArgs)
  123.             Dim g As Graphics = e.Graphics
  124.             g.Clear(Color.White)
  125.  
  126.             Dim bg As New LinearGradientBrush(Me.ClientRectangle, Color.FromArgb(138, 157, 158), Color.FromArgb(58, 63, 66), LinearGradientMode.Vertical)
  127.  
  128.             g.FillRectangle(bg, Me.ClientRectangle)
  129.  
  130.             Dim headerRectangle As New Rectangle(border, border, Me.Width - (border * 2), m_headerHeight)
  131.  
  132.             Dim hbg As New HatchBrush(HatchStyle.DashedHorizontal, Color.FromArgb(50, 171, 157), Color.FromArgb(43, 163, 147))
  133.             g.FillRectangle(hbg, headerRectangle)
  134.  
  135.             Dim grad As New LinearGradientBrush(headerRectangle, Color.FromArgb(20, Color.White), Color.FromArgb(120, Color.Black), LinearGradientMode.Vertical)
  136.             g.FillRectangle(grad, headerRectangle)
  137.  
  138.             Dim sz As SizeF = g.MeasureString(m_headerText, Me.Font)
  139.  
  140.             g.DrawString(m_headerText, m_headerFont, Brushes.WhiteSmoke, New PointF(30, (headerRectangle.Height - sz.Height) / 2))
  141.  
  142.             g.DrawRectangle(New Pen(Color.FromArgb(80, Color.Black)), headerRectangle)
  143.  
  144.             Dim contentRectangle As New Rectangle(border, m_headerHeight, Me.Width - (border * 2), ((Me.Height - m_headerHeight) - (border)) - m_footerHeight)
  145.  
  146.             g.FillRectangle(Brushes.WhiteSmoke, contentRectangle)
  147.  
  148.             If m_showDropShadow Then
  149.                 Dim shadowRectangle As New Rectangle(contentRectangle.X, contentRectangle.Y, contentRectangle.Width, dropShadowHeight)
  150.  
  151.                 Dim sbg As New LinearGradientBrush(shadowRectangle, Color.FromArgb(120, 50, 171, 157), Color.WhiteSmoke, LinearGradientMode.Vertical)
  152.                 g.FillRectangle(sbg, shadowRectangle)
  153.             End If
  154.  
  155.             Dim footerRectangle As New Rectangle(border, (Me.Height - border) - m_footerHeight, Me.Width - (border * 2), m_footerHeight)
  156.  
  157.             Dim fbg As New LinearGradientBrush(footerRectangle, Color.FromArgb(54, 57, 62), Color.FromArgb(44, 47, 52), LinearGradientMode.Vertical)
  158.  
  159.             g.FillRectangle(fbg, footerRectangle)
  160.  
  161.             g.DrawRectangle(Pens.Black, footerRectangle)
  162.  
  163.             g.DrawRectangle(New Pen(Color.FromArgb(180, Color.Black)), contentRectangle)
  164.         End Sub
  165.  
  166.     End Class
  167.  
  168.     Class Kaspersky2014ProgressBar
  169.         Inherits Button
  170.  
  171.         ' x-coordinate of upper-left corner
  172.         ' y-coordinate of upper-left corner
  173.         ' x-coordinate of lower-right corner
  174.         ' y-coordinate of lower-right corner
  175.         ' height of ellipse
  176.         <DllImport("Gdi32.dll", EntryPoint := "CreateRoundRectRgn")> _
  177.         Private Shared Function CreateRoundRectRgn(nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer, nWidthEllipse As Integer, nHeightEllipse As Integer) As IntPtr
  178.             ' width of ellipse
  179.         End Function
  180.  
  181.         Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  182.             radius As Single)
  183.             Dim gp As New GraphicsPath()
  184.             gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  185.             gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  186.             gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  187.             gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  188.             gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  189.             gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  190.             gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  191.             gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  192.             gp.CloseFigure()
  193.             g.DrawPath(p, gp)
  194.             gp.Dispose()
  195.         End Sub
  196.  
  197.  
  198.  
  199.         Private m_maximum As Single = 100F
  200.         Public Property Maximum() As Single
  201.             Get
  202.                 Return m_maximum
  203.             End Get
  204.             Set
  205.                 m_maximum = value
  206.                 Me.Invalidate()
  207.             End Set
  208.         End Property
  209.  
  210.         Private mValue As Single = 0F
  211.         Public Property Value() As Single
  212.             Get
  213.                 Return mValue
  214.             End Get
  215.             Set
  216.                 mValue = value
  217.                 Me.Invalidate()
  218.             End Set
  219.         End Property
  220.  
  221.         Protected Overrides Sub OnResize(e As EventArgs)
  222.             MyBase.OnResize(e)
  223.             Me.Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Me.Width - 1, Me.Height - 1, 3, 3))
  224.         End Sub
  225.  
  226.         Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  227.             Dim g As Graphics = pevent.Graphics
  228.             g.Clear(Color.White)
  229.  
  230.  
  231.             Dim progressWidth As Integer = CInt(Math.Truncate((mValue / m_maximum) * Me.Width))
  232.  
  233.             Dim progressRect As New Rectangle(0, 0, progressWidth, Me.Height)
  234.  
  235.             If mValue > 0 Then
  236.                 Dim pbg As New LinearGradientBrush(progressRect, Color.FromArgb(2, 158, 131), Color.FromArgb(4, 129, 107), LinearGradientMode.Vertical)
  237.  
  238.                 g.FillRectangle(pbg, New Rectangle(0, 0, progressWidth, Me.Height))
  239.             End If
  240.             Dim r1 As New RectangleF(1, 1, Me.Width - 2, Me.Height - 4)
  241.             r1.Width = CSng(r1.Width * mValue / m_maximum)
  242.             Dim reg1 As New Region(r1)
  243.             Dim reg2 As New Region(Me.ClientRectangle)
  244.             reg2.Exclude(reg1)
  245.  
  246.             Dim textSize As SizeF = g.MeasureString(Me.Text, Me.Font)
  247.  
  248.             Dim y As Single = (Me.ClientRectangle.Height - textSize.Height) / 2
  249.  
  250.             g.Clip = reg1
  251.             g.DrawString(Me.Text, Me.Font, Brushes.WhiteSmoke, 10, y)
  252.             g.Clip = reg2
  253.             g.DrawString(Me.Text, Me.Font, Brushes.Gray, 10, y)
  254.  
  255.             reg1.Dispose()
  256.             reg2.Dispose()
  257.  
  258.             DrawRoundRect(g, Pens.Gray, 0, 0, Me.Width - 3, Me.Height - 3, _
  259.                 3)
  260.         End Sub
  261.  
  262.     End Class
  263.  
  264.     Class Kaspersky2014CloseButton
  265.         Inherits Button
  266.  
  267.         ' x-coordinate of upper-left corner
  268.         ' y-coordinate of upper-left corner
  269.         ' x-coordinate of lower-right corner
  270.         ' y-coordinate of lower-right corner
  271.         ' height of ellipse
  272.         <DllImport("Gdi32.dll", EntryPoint := "CreateRoundRectRgn")> _
  273.         Private Shared Function CreateRoundRectRgn(nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer, nWidthEllipse As Integer, nHeightEllipse As Integer) As IntPtr
  274.             ' width of ellipse
  275.         End Function
  276.  
  277.         Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  278.             radius As Single)
  279.             Dim gp As New GraphicsPath()
  280.             gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  281.             gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  282.             gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  283.             gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  284.             gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  285.             gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  286.             gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  287.             gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  288.             gp.CloseFigure()
  289.             g.DrawPath(p, gp)
  290.             gp.Dispose()
  291.         End Sub
  292.  
  293.         Private Enum MouseState
  294.             None
  295.             Over
  296.             Down
  297.         End Enum
  298.  
  299.         Private state As MouseState = MouseState.None
  300.  
  301.         Protected Overrides Sub OnMouseEnter(e As EventArgs)
  302.             state = MouseState.Over
  303.             MyBase.OnMouseEnter(e)
  304.         End Sub
  305.  
  306.         Protected Overrides Sub OnMouseLeave(e As EventArgs)
  307.             state = MouseState.None
  308.             MyBase.OnMouseLeave(e)
  309.         End Sub
  310.  
  311.         Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  312.             state = MouseState.Down
  313.             MyBase.OnMouseDown(mevent)
  314.         End Sub
  315.  
  316.         Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  317.             state = MouseState.Over
  318.             MyBase.OnMouseUp(mevent)
  319.         End Sub
  320.  
  321.         Protected Overrides Sub OnClick(e As EventArgs)
  322.             MyBase.OnClick(e)
  323.             Environment.[Exit](0)
  324.         End Sub
  325.  
  326.         Private font As New Font("Marlett", 11F)
  327.  
  328.         Protected Overrides Sub OnResize(e As EventArgs)
  329.             MyBase.OnResize(e)
  330.             Me.Region = Region.FromHrgn(CreateRoundRectRgn(-5, -5, Me.Width - 1, Me.Height - 1, 12, 12))
  331.         End Sub
  332.  
  333.         Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  334.             Dim g As Graphics = pevent.Graphics
  335.             g.SmoothingMode = SmoothingMode.AntiAlias
  336.             g.Clear(Color.White)
  337.  
  338.             g.FillRectangle(New SolidBrush(Color.FromArgb(160, 46, 37)), Me.ClientRectangle)
  339.             g.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), New Rectangle(0, 0, Me.Width, Me.Height \ 2))
  340.  
  341.             Select Case state
  342.                 Case MouseState.Over
  343.                     g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.White)), Me.ClientRectangle)
  344.                     Exit Select
  345.  
  346.                 Case MouseState.Down
  347.                     g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  348.                     Exit Select
  349.             End Select
  350.  
  351.             TextRenderer.DrawText(g, "r", font, Me.ClientRectangle, Color.WhiteSmoke, TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)
  352.  
  353.             DrawRoundRect(g, New Pen(Color.DarkRed), -5, -5, Me.Width + 2, Me.Height + 2, _
  354.                 8)
  355.         End Sub
  356.  
  357.     End Class
  358.  
  359.     Class Kaspersky2014MinimizeButton
  360.         Inherits Button
  361.  
  362.         ' x-coordinate of upper-left corner
  363.         ' y-coordinate of upper-left corner
  364.         ' x-coordinate of lower-right corner
  365.         ' y-coordinate of lower-right corner
  366.         ' height of ellipse
  367.         <DllImport("Gdi32.dll", EntryPoint := "CreateRoundRectRgn")> _
  368.         Private Shared Function CreateRoundRectRgn(nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer, nWidthEllipse As Integer, nHeightEllipse As Integer) As IntPtr
  369.             ' width of ellipse
  370.         End Function
  371.  
  372.         Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  373.             radius As Single)
  374.             Dim gp As New GraphicsPath()
  375.             gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  376.             gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  377.             gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  378.             gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  379.             gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  380.             gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  381.             gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  382.             gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  383.             gp.CloseFigure()
  384.             g.DrawPath(p, gp)
  385.             gp.Dispose()
  386.         End Sub
  387.  
  388.         Private Enum MouseState
  389.             None
  390.             Over
  391.             Down
  392.         End Enum
  393.  
  394.         Private state As MouseState = MouseState.None
  395.  
  396.         Protected Overrides Sub OnMouseEnter(e As EventArgs)
  397.             state = MouseState.Over
  398.             MyBase.OnMouseEnter(e)
  399.         End Sub
  400.  
  401.         Protected Overrides Sub OnMouseLeave(e As EventArgs)
  402.             state = MouseState.None
  403.             MyBase.OnMouseLeave(e)
  404.         End Sub
  405.  
  406.         Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  407.             state = MouseState.Down
  408.             MyBase.OnMouseDown(mevent)
  409.         End Sub
  410.  
  411.         Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  412.             state = MouseState.Over
  413.             MyBase.OnMouseUp(mevent)
  414.         End Sub
  415.  
  416.         Protected Overrides Sub OnMouseClick(e As MouseEventArgs)
  417.             MyBase.OnMouseClick(e)
  418.             DirectCast(Me.Parent, Form).WindowState = FormWindowState.Minimized
  419.         End Sub
  420.  
  421.         Private font As New Font("Marlett", 11F)
  422.  
  423.         Protected Overrides Sub OnResize(e As EventArgs)
  424.             MyBase.OnResize(e)
  425.             Me.Region = Region.FromHrgn(CreateRoundRectRgn(1, -5, Me.Width + 5, Me.Height - 1, 12, 12))
  426.         End Sub
  427.  
  428.         Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  429.             Dim g As Graphics = pevent.Graphics
  430.             g.SmoothingMode = SmoothingMode.AntiAlias
  431.             g.Clear(Color.White)
  432.  
  433.             g.FillRectangle(New SolidBrush(Color.FromArgb(56, 143, 133)), Me.ClientRectangle)
  434.             g.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), New Rectangle(0, 0, Me.Width, Me.Height \ 2))
  435.  
  436.             Select Case state
  437.                 Case MouseState.Over
  438.                     g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.White)), Me.ClientRectangle)
  439.                     Exit Select
  440.  
  441.                 Case MouseState.Down
  442.                     g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  443.                     Exit Select
  444.             End Select
  445.  
  446.             TextRenderer.DrawText(g, "0", font, Me.ClientRectangle, Color.WhiteSmoke, TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)
  447.  
  448.             DrawRoundRect(g, New Pen(Color.Teal), 1, -5, Me.Width + 5, Me.Height + 2, _
  449.                 8)
  450.         End Sub
  451.  
  452.     End Class
  453.  
  454.     Class Kaspersky2014GreenButton
  455.         Inherits Button
  456.  
  457.         Private Enum MouseState
  458.             None
  459.             Over
  460.             Down
  461.         End Enum
  462.  
  463.         Private state As MouseState = MouseState.None
  464.  
  465.         Protected Overrides Sub OnMouseEnter(e As EventArgs)
  466.             state = MouseState.Over
  467.             MyBase.OnMouseEnter(e)
  468.         End Sub
  469.  
  470.         Protected Overrides Sub OnMouseLeave(e As EventArgs)
  471.             state = MouseState.None
  472.             MyBase.OnMouseLeave(e)
  473.         End Sub
  474.  
  475.         Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  476.             state = MouseState.Down
  477.             MyBase.OnMouseDown(mevent)
  478.         End Sub
  479.  
  480.         Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  481.             state = MouseState.Over
  482.             MyBase.OnMouseUp(mevent)
  483.         End Sub
  484.  
  485.         Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  486.             Dim g As Graphics = pevent.Graphics
  487.             g.Clear(Color.White)
  488.  
  489.             Dim bg As New LinearGradientBrush(Me.ClientRectangle, Color.FromArgb(0, 161, 137), Color.FromArgb(0, 130, 110), LinearGradientMode.Vertical)
  490.  
  491.             g.FillRectangle(bg, Me.ClientRectangle)
  492.  
  493.             Select Case state
  494.                 Case MouseState.Over
  495.                     g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.White)), Me.ClientRectangle)
  496.                     Exit Select
  497.  
  498.                 Case MouseState.Down
  499.                     g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  500.                     Exit Select
  501.             End Select
  502.  
  503.             g.DrawLine(New Pen(Color.FromArgb(0, 191, 167)), 1, 1, Me.Width, 1)
  504.  
  505.             g.DrawRectangle(New Pen(Color.FromArgb(0, 141, 117)), New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  506.  
  507.             TextRenderer.DrawText(g, Me.Text, Me.Font, Me.ClientRectangle, Me.ForeColor, TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter)
  508.         End Sub
  509.  
  510.     End Class
  511.  
  512.     Class Kaspersky2014CheckBox
  513.         Inherits Button
  514.  
  515.         Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  516.             radius As Single)
  517.             Dim gp As New GraphicsPath()
  518.             gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  519.             gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  520.             gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  521.             gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  522.             gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  523.             gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  524.             gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  525.             gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  526.             gp.CloseFigure()
  527.             g.DrawPath(p, gp)
  528.             gp.Dispose()
  529.         End Sub
  530.  
  531.         Private mChecked As Boolean = False
  532.         Public Property Checked() As Boolean
  533.             Get
  534.                 Return mChecked
  535.             End Get
  536.             Set
  537.                 mChecked = value
  538.                 Me.Invalidate()
  539.             End Set
  540.         End Property
  541.  
  542.         Protected Overrides Sub OnClick(e As EventArgs)
  543.             Me.Checked = Not Me.Checked
  544.             MyBase.OnClick(e)
  545.         End Sub
  546.  
  547.         Private font As New Font("Marlett", 15F)
  548.  
  549.         Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  550.             Dim g As Graphics = pevent.Graphics
  551.             g.Clear(Me.BackColor)
  552.  
  553.             DrawRoundRect(g, New Pen(Color.FromArgb(172, 182, 181)), 0, 0, 17, 17, _
  554.                 3)
  555.  
  556.             Select Case mChecked
  557.                 Case True
  558.                     g.DrawString("b", font, Brushes.DarkSlateGray, New PointF(-2, -1))
  559.                     Exit Select
  560.             End Select
  561.  
  562.             g.DrawString(Me.Text, Me.Font, Brushes.Black, New PointF(20, 2))
  563.         End Sub
  564.  
  565.     End Class
  566.  
  567.     Class Kaspersky2014WhiteButton
  568.         Inherits Button
  569.  
  570.         Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  571.             radius As Single)
  572.             Dim gp As New GraphicsPath()
  573.             gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  574.             gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  575.             gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  576.             gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  577.             gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  578.             gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  579.             gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  580.             gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  581.             gp.CloseFigure()
  582.             g.DrawPath(p, gp)
  583.             gp.Dispose()
  584.         End Sub
  585.  
  586.         Private Enum MouseState
  587.             None
  588.             Over
  589.             Down
  590.         End Enum
  591.  
  592.         Private state As MouseState = MouseState.None
  593.  
  594.         Protected Overrides Sub OnMouseEnter(e As EventArgs)
  595.             state = MouseState.Over
  596.             MyBase.OnMouseEnter(e)
  597.         End Sub
  598.  
  599.         Protected Overrides Sub OnMouseLeave(e As EventArgs)
  600.             state = MouseState.None
  601.             MyBase.OnMouseLeave(e)
  602.         End Sub
  603.  
  604.         Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  605.             state = MouseState.Down
  606.             MyBase.OnMouseDown(mevent)
  607.         End Sub
  608.  
  609.         Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  610.             state = MouseState.Over
  611.             MyBase.OnMouseUp(mevent)
  612.         End Sub
  613.  
  614.         Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  615.             Dim g As Graphics = pevent.Graphics
  616.             g.Clear(Color.White)
  617.  
  618.             Dim bg As New LinearGradientBrush(Me.ClientRectangle, Color.White, Color.FromArgb(220, 220, 220), LinearGradientMode.Vertical)
  619.             g.FillRectangle(bg, Me.ClientRectangle)
  620.  
  621.             Select Case state
  622.                 Case MouseState.Over
  623.                     g.FillRectangle(New SolidBrush(Color.FromArgb(10, Color.Black)), Me.ClientRectangle)
  624.                     Exit Select
  625.  
  626.                 Case MouseState.Down
  627.                     g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  628.                     Exit Select
  629.             End Select
  630.  
  631.             DrawRoundRect(g, Pens.Gray, 0, 0, Me.Width - 1, Me.Height - 1, _
  632.                 3)
  633.  
  634.             TextRenderer.DrawText(g, Me.Text, Me.Font, Me.ClientRectangle, Me.ForeColor, TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)
  635.         End Sub
  636.  
  637.     End Class
  638. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement