Advertisement
netrosly

DarkLog_Container

Mar 22nd, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.89 KB | None | 0 0
  1. Public Class DarkLog_Container
  2.     Inherits ContainerControl
  3.     Property Text_ As String = "User Login"
  4.     Property Text_Color As Color = Color.White
  5.     Sub New()
  6.         Me.DoubleBuffered = True
  7.         Me.Dock = DockStyle.Fill
  8.     End Sub
  9.  
  10.     Private Sub DarkLog_Container_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
  11.         e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
  12.         'Back
  13.         e.Graphics.Clear(Color.Black)
  14.         e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(33, 31, 33)), New Rectangle(2, 2, Me.Width - 4, Me.Height - 5))
  15.         'header
  16.         e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(24, 22, 24)), New Rectangle(2, 2, Me.Width - 4, 50))
  17.         e.Graphics.DrawLine(New Pen(Color.FromArgb(15, 13, 15)), New Point(2, 51), New Point(Me.Width - 4, 51))
  18.         e.Graphics.DrawLine(New Pen(Color.FromArgb(42, 40, 41)), New Point(2, 52), New Point(Me.Width - 4, 52))
  19.         Dim rect = New Rectangle(2, 2, Me.Width - 4, 23)
  20.         Dim LGB = New LinearGradientBrush(rect, Color.FromArgb(40, 165, 165, 165), Color.FromArgb(24, 22, 24), 90.0!)
  21.         e.Graphics.FillRectangle(LGB, rect)
  22.         'Shadow Text
  23.         e.Graphics.DrawString(Text_, New Font("Arial", 10, FontStyle.Regular), New SolidBrush(Color.Black), New Rectangle(2, 3, Me.Width - 4, 50), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  24.         'Text
  25.         e.Graphics.DrawString(Text_, New Font("Arial", 10, FontStyle.Regular), New SolidBrush(Text_Color), New Rectangle(2, 2, Me.Width - 4, 50), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  26.         'Border
  27.         e.Graphics.DrawRectangle(New Pen(Color.FromArgb(60, 200, 200, 200)), New Rectangle(1, 1, Me.Width - 3, Me.Height - 4))
  28.     End Sub
  29. #Region "ThemeDraggable"
  30.     Dim x, y As Integer
  31.     Private savePoint As New Point(0, 0)
  32.     Private isDragging As Boolean = False
  33.  
  34.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  35.         Dim dragRect As New Rectangle(0, 0, Me.Width, 50)
  36.         If dragRect.Contains(New Point(e.X, e.Y)) Then
  37.             isDragging = True
  38.             savePoint = New Point(e.X, e.Y)
  39.         End If
  40.         '
  41.         MyBase.OnMouseDown(e)
  42.     End Sub
  43.  
  44.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  45.         isDragging = False
  46.         MyBase.OnMouseUp(e)
  47.     End Sub
  48.  
  49.     Private mouseX As Integer
  50.     Private mouseY As Integer
  51.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  52.  
  53.         mouseX = e.X
  54.         mouseY = e.Y
  55.         If isDragging Then
  56.             Dim screenPoint As Point = PointToScreen(e.Location)
  57.  
  58.             FindForm().Location = New Point(screenPoint.X - Me.savePoint.X, screenPoint.Y - Me.savePoint.Y)
  59.         End If
  60.         MyBase.OnMouseMove(e)
  61.         Invalidate()
  62.     End Sub
  63.  
  64. #End Region
  65. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement