Advertisement
netrosly

LottoLight Button

Jul 6th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.82 KB | None | 0 0
  1. Imports System.Runtime.InteropServices
  2. Imports System.Drawing.Drawing2D
  3.  
  4. Public Class LottoLight
  5.     Class RoundedRectangle
  6.         <DllImport("gdi32.dll")> _
  7.         Shared Function CreateRoundRectRgn(ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal cx As Integer, ByVal cy As Integer) As IntPtr
  8.         End Function
  9.         Shared Function DrawRoundRectangle(rct As Rectangle, r As Integer, MSAA As Integer, FillColor As Color, BorderColor As Color)
  10.             Dim b As New Bitmap(rct.Width * MSAA + MSAA, rct.Height * MSAA + MSAA)
  11.             Dim g As Graphics = Graphics.FromImage(b)
  12.             Dim RegH As IntPtr = CreateRoundRectRgn(rct.Left, rct.Top, (rct.Width) * MSAA, (rct.Height) * MSAA, r * MSAA, r * MSAA)
  13.             Dim RegH1 As IntPtr = CreateRoundRectRgn(rct.Left + MSAA / 1, rct.Top + MSAA / 1, (rct.Width - 1) * MSAA, (rct.Height - 1) * MSAA, (r - 2) * MSAA, (r - 2) * MSAA)
  14.             Dim Reg As Region = Region.FromHrgn(RegH)
  15.             Dim Reg1 As Region = Region.FromHrgn(RegH1)
  16.  
  17.             g.InterpolationMode = InterpolationMode.HighQualityBicubic
  18.  
  19.             g.FillRegion(New SolidBrush(BorderColor), Reg)
  20.             g.SetClip(Reg1, CombineMode.Replace)
  21.             g.Clear(FillColor)
  22.             Return b
  23.         End Function
  24.     End Class
  25. End Class
  26. Public Class LL_Button
  27.     Inherits Control
  28.     Sub New()
  29.         Me.DoubleBuffered = True
  30.     End Sub
  31.     Dim mouseover As Boolean = False
  32.     Dim mouseclick As Boolean = False
  33.     Dim WithEvents tmr As New Timer With {.Interval = 10}
  34.     Dim clickcount As Integer = 0
  35.     Event MouseClicked()
  36.     Private Sub LL_Button_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
  37.         If e.Button = Windows.Forms.MouseButtons.Left Then
  38.             If mouseover Then
  39.                 If mouseclick = False Then
  40.                     mouseclick = True
  41.                     Me.Refresh()
  42.                 End If
  43.             End If
  44.         End If
  45.     End Sub
  46.  
  47.     Private Sub LL_Button_MouseLeave(sender As Object, e As EventArgs) Handles Me.MouseLeave
  48.         mouseover = False
  49.         Me.Refresh()
  50.     End Sub
  51.  
  52.     Private Sub LL_Button_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
  53.         If New Rectangle(1, 4, Me.Width - 2, Me.Height - 2).Contains(e.X, e.Y) Then
  54.             mouseover = True
  55.             Cursor = Cursors.Hand
  56.             Me.Refresh()
  57.         Else
  58.             mouseover = False
  59.             Cursor = Cursors.Arrow
  60.             Me.Refresh()
  61.         End If
  62.     End Sub
  63.  
  64.     Private Sub LL_Button_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
  65.         If e.Button = Windows.Forms.MouseButtons.Left Then
  66.             If mouseover Then
  67.                 RaiseEvent MouseClicked()
  68.                 mouseclick = False
  69.             End If
  70.         End If
  71.     End Sub
  72.     Private Sub LL_Button_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
  73.         Dim g As Graphics = e.Graphics
  74.         g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  75.         If mouseover Then
  76.             g.DrawImage(LottoLight.RoundedRectangle.DrawRoundRectangle(New Rectangle(1, 4, Me.Width - 2, Me.Height - 2), 6, 4, Color.FromArgb(39, 185, 101), Color.FromArgb(39, 185, 101)), 1, 4, Me.Width - 2, Me.Height - 2)
  77.             g.DrawImage(LottoLight.RoundedRectangle.DrawRoundRectangle(New Rectangle(1, 1, Me.Width - 2, Me.Height - 3), 6, 4, Color.FromArgb(39, 185, 101), Color.FromArgb(39, 185, 101)), 1, 1, Me.Width - 2, Me.Height - 3)
  78.             g.DrawString("Smart Play", New Font("Arial", 14, FontStyle.Regular), Brushes.White, New Rectangle(10, Me.Height - 38, Me.Width - 12, Me.Height - 38))
  79.            
  80.         Else
  81.             g.DrawImage(LottoLight.RoundedRectangle.DrawRoundRectangle(New Rectangle(1, 4, Me.Width - 2, Me.Height - 2), 6, 4, Color.FromArgb(39, 185, 101), Color.FromArgb(39, 185, 101)), 1, 4, Me.Width - 2, Me.Height - 2)
  82.             g.DrawImage(LottoLight.RoundedRectangle.DrawRoundRectangle(New Rectangle(1, 1, Me.Width - 2, Me.Height - 3), 6, 4, Color.FromArgb(46, 204, 113), Color.FromArgb(46, 204, 113)), 1, 1, Me.Width - 2, Me.Height - 3)
  83.             g.DrawString("Smart Play", New Font("Arial", 14, FontStyle.Regular), Brushes.White, New Rectangle(10, Me.Height - 38, Me.Width - 12, Me.Height - 38))
  84.         End If
  85.         If mouseclick Then
  86.             g.DrawImage(LottoLight.RoundedRectangle.DrawRoundRectangle(New Rectangle(1, 4, Me.Width - 2, Me.Height - 2), 6, 4, Color.FromArgb(46, 204, 113), Color.FromArgb(46, 204, 113)), 1, 4, Me.Width - 2, Me.Height - 2)
  87.             g.DrawImage(LottoLight.RoundedRectangle.DrawRoundRectangle(New Rectangle(1, 1, Me.Width - 2, Me.Height - 5), 6, 4, Color.FromArgb(39, 185, 101), Color.FromArgb(39, 185, 101)), 1, 1, Me.Width - 2, Me.Height - 5)
  88.             g.DrawString("Smart Play", New Font("Arial", 14, FontStyle.Regular), Brushes.White, New Rectangle(10, Me.Height - 38, Me.Width - 12, Me.Height - 38))
  89.         End If
  90.  
  91.     End Sub
  92.  
  93.  
  94. End Class
  95. Public Class LL_BubProgbar
  96.     Inherits Control
  97.     Sub New()
  98.         Me.DoubleBuffered = False
  99.     End Sub
  100.     Property Percent As Integer = 100
  101.     Property ShowBubble As Boolean = True
  102.     Property ShowLabel As Boolean = False
  103.     Property Label As String
  104.     Property ShowPathLine As Boolean = True
  105.     Property BarColor As Color = Color.FromArgb(252, 165, 51)
  106.  
  107.     Private Sub LL_BubProgbar_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
  108.         Dim g As Graphics = e.Graphics
  109.         g.SmoothingMode = SmoothingMode.HighQuality
  110.         g.DrawImage(LottoLight.RoundedRectangle.DrawRoundRectangle(New Rectangle(1, 1, ((Me.Width - 1) - (Me.Width * Percent) / Percent), Me.Height - 2), 6, 4, BarColor, BarColor), New Rectangle(1, 1, Me.Width - 1 - ((Me.Width - 1) - (Me.Width * Percent) / Percent), Me.Height - 2))
  111.     End Sub
  112. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement