Guest User

Kaspersky Theme

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