Advertisement
netrosly

PokeGroup

Aug 1st, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.35 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2.  
  3. Public Class PokeGroup
  4.     Inherits Control
  5.     Sub New()
  6.         Me.DoubleBuffered = True
  7.         Me.Size = New Size(160, 40)
  8.     End Sub
  9.     Property Shadow As Boolean = False
  10.     Property Color1 As Color = Color.FromArgb(255, 254, 255)
  11.     Property Color2 As Color = Color.FromArgb(242, 254, 234)
  12.     Property BorderColor As Color = Color.FromArgb(29, 209, 165)
  13.     Property Curve As Integer = 10
  14. #Region "Round Rectangle"
  15.     Public Shared Function NTRound(rectangle As Rectangle, slope As Integer) As GraphicsPath
  16.         Dim path = New GraphicsPath(FillMode.Winding)
  17.         path.AddArc(rectangle.X - slope, rectangle.Y, slope, slope, 180.0F, 90.0F)
  18.         path.AddArc(rectangle.Right, rectangle.Y, slope, slope, 270.0F, 90.0F)
  19.         path.AddArc(rectangle.Right - slope, rectangle.Bottom - slope, slope, slope, 0.0F, 90.0F)
  20.         path.AddArc(rectangle.X, rectangle.Bottom - slope, slope, slope, 90.0F, 90.0F)
  21.         path.CloseFigure()
  22.         Return path
  23.     End Function
  24.  
  25.     Public Shared Function NTRound(x As Integer, y As Integer, height As Integer, width As Integer, slope As Integer) As GraphicsPath
  26.         Return Round(New Rectangle(x, y, height, width), slope)
  27.     End Function
  28.  
  29.     Public Shared Function Round(rectangle As Rectangle, slope As Integer) As GraphicsPath
  30.         Dim path = New GraphicsPath(FillMode.Winding)
  31.         path.AddArc(rectangle.X, rectangle.Y, slope, slope, 180.0F, 90.0F)
  32.         path.AddArc(rectangle.Right - slope, rectangle.Y, slope, slope, 270.0F, 90.0F)
  33.         path.AddArc(rectangle.Right - slope, rectangle.Bottom - slope, slope, slope, 0.0F, 90.0F)
  34.         path.AddArc(rectangle.X, rectangle.Bottom - slope, slope, slope, 90.0F, 90.0F)
  35.         path.CloseFigure()
  36.         Return path
  37.     End Function
  38.  
  39.     Public Shared Function Round(x As Integer, y As Integer, height As Integer, width As Integer, slope As Integer) As GraphicsPath
  40.         Return Round(New Rectangle(x, y, height, width), slope)
  41.     End Function
  42. #End Region
  43.     Public Function gb(e As Graphics, r As Rectangle, c1 As Color, c2 As Color) As LinearGradientBrush
  44.         Dim g As Graphics = e
  45.         Dim p1 As Point = r.Location
  46.         Dim p2 As Point = New Point(r.Right, r.Bottom)
  47.         Dim brsGradient As New System.Drawing.Drawing2D.LinearGradientBrush(p1, p2, c1, c2)
  48.         Return brsGradient
  49.     End Function
  50.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  51.         Dim b As New Bitmap(Width, Height)
  52.         Dim g As Graphics = Graphics.FromImage(b)
  53.         g.Clear(BackColor)
  54.         g.SmoothingMode = SmoothingMode.AntiAlias
  55.         If Shadow Then
  56.             g.FillPath(New SolidBrush(Color.FromArgb(180, Color.Gray)), Round(New Rectangle(3, 3, Me.Width - 4, Me.Height - 4), 10))
  57.             g.FillPath(gb(g, New Rectangle(0, 0, Me.Width - 6, Me.Height - 6), Color1, Color2), Round(New Rectangle(0, 0, Me.Width - 4, Me.Height - 4), Curve))
  58.             Me.Padding = New Padding(2, 2, Me.Width - 8, Me.Height - 8)
  59.         Else
  60.             g.FillPath(gb(g, New Rectangle(0, 0, Me.Width - 1, Me.Height - 1), Color1, Color2), Round(New Rectangle(0, 0, Me.Width - 1, Me.Height - 1), Curve))
  61.             Me.Padding = New Padding(2, 2, Me.Width - 3, Me.Height - 3)
  62.         End If
  63.  
  64.  
  65.         e.Graphics.DrawImage(b.Clone, 0, 0)
  66.         g.Dispose()
  67.         b.Dispose()
  68.     End Sub
  69. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement