Advertisement
netrosly

Flat Container

Dec 23rd, 2014
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.06 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2. Imports System.IO
  3. Imports System.ComponentModel
  4.  
  5. Partial Public Class Wow
  6. Inherits Panel
  7. Public Sub New()
  8. Me.SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
  9. DoubleBuffered = True
  10. Me.Padding = New Padding(1, 55, 1, 1)
  11. End Sub
  12. Dim x, y As Integer
  13. Public Enum Type
  14. Teacher = 0
  15. Student = 1
  16. Application = 2
  17. End Enum
  18. Public _Type As Type = Type.Student
  19. Public Property Tyype As Type
  20. Get
  21. Return _Type
  22. End Get
  23. Set(ByVal value As Type)
  24. _Type = value
  25. Invalidate()
  26. End Set
  27. End Property
  28. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  29. Dim bm As New Bitmap(Me.Width, Me.Height)
  30. Dim g As Graphics = Graphics.FromImage(bm)
  31. ' Dim rect As New Rectangle(0, 0, Me.Width, (Me.Height - 35))
  32. ' Dim brush As New LinearGradientBrush(rect, Color.FromArgb(250, 250, 250), Color.FromArgb(206, 206, 206), 90.0!)
  33. 'Begin
  34. 'Form
  35. g.DrawRectangle(New Pen(Color.FromArgb(242, 242, 242)), 0, 0, Me.Width, Me.Height)
  36. g.FillRectangle(New SolidBrush(Color.FromArgb(242, 242, 242)), 0, 0, Me.Width, Me.Height)
  37. 'Splitter
  38. g.DrawRectangle(New Pen(Color.FromArgb(229, 229, 229)), 0, 0, Me.Width, 51)
  39. g.FillRectangle(New SolidBrush(Color.FromArgb(229, 229, 229)), 0, 0, Me.Width, 51)
  40. 'Top
  41. Dim rect = New Rectangle(0, 0, Me.Width, 50)
  42. g.DrawRectangle(New Pen(Color.FromArgb(255, 255, 255)), 0, 0, Me.Width, 50)
  43. g.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), 0, 0, Me.Width, 50)
  44. 'String
  45. g.DrawString(FindForm.Text, New Font("Arial", 12.5, FontStyle.Regular), New SolidBrush(Color.FromArgb(130, 130, 130)), 14, 17)
  46. g.DrawString(_Type.ToString, New Font("Arial", 12.5, FontStyle.Bold), New SolidBrush(Color.FromArgb(45, 114, 160)), 93, 17)
  47. 'Buttons
  48. '//Close button
  49. If New Rectangle(Width - 40, 10, 24, 24).Contains(New Point(mouseX, mouseY)) Then
  50. g.SmoothingMode = SmoothingMode.HighQuality
  51. g.FillRectangle(New SolidBrush(Color.FromArgb(237, 237, 237)), New Rectangle(Width - 40, 10, 24, 24))
  52. g.DrawString("r", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 40, 10))
  53. Else
  54. g.SmoothingMode = SmoothingMode.HighQuality
  55. ' g.FillRectangle(New SolidBrush(Color.FromArgb(237, 237, 237)), New Rectangle(Width - 40, 10, 24, 24))
  56. g.DrawString("r", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 40, 10))
  57. End If
  58. '//Minimize Button
  59. If New Rectangle(Width - 100, 10, 24, 24).Contains(New Point(mouseX, mouseY)) Then
  60. g.SmoothingMode = SmoothingMode.HighQuality
  61. g.FillRectangle(New SolidBrush(Color.FromArgb(237, 237, 237)), New Rectangle(Width - 100, 10, 24, 24))
  62. g.DrawString("0", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 100, 10))
  63. Else
  64. g.SmoothingMode = SmoothingMode.HighQuality
  65. ' g.FillRectangle(New SolidBrush(Color.FromArgb(237, 237, 237)), New Rectangle(Width - 40, 10, 24, 24))
  66. g.DrawString("0", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 100, 10))
  67. End If
  68. '//Fullscreen
  69. If New Rectangle(Width - 70, 10, 24, 24).Contains(New Point(mouseX, mouseY)) Then
  70. g.SmoothingMode = SmoothingMode.HighQuality
  71. g.FillRectangle(New SolidBrush(Color.FromArgb(237, 237, 237)), New Rectangle(Width - 70, 10, 24, 24))
  72. If FindForm.WindowState = FormWindowState.Maximized Then
  73. g.DrawString("2", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 70, 10))
  74. Else
  75. g.DrawString("1", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 70, 10))
  76. End If
  77. Else
  78. g.SmoothingMode = SmoothingMode.HighQuality
  79. ' g.FillRectangle(New SolidBrush(Color.FromArgb(237, 237, 237)), New Rectangle(Width - 40, 10, 24, 24))
  80. If FindForm.WindowState = FormWindowState.Maximized Then
  81. g.DrawString("2", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 70, 10))
  82. Else
  83. g.DrawString("1", New Font("Webdings", 14), New SolidBrush(Color.FromArgb(130, 130, 130)), New Point(Width - 70, 10))
  84. End If
  85. End If
  86. 'End
  87. e.Graphics.DrawImage(DirectCast(bm.Clone(), Bitmap), 0, 0)
  88. g.Dispose()
  89. bm.Dispose()
  90. MyBase.OnPaint(e)
  91.  
  92. End Sub
  93. #Region "ThemeDraggable"
  94.  
  95. Private savePoint As New Point(0, 0)
  96. Private isDragging As Boolean = False
  97.  
  98. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  99. Dim dragRect As New Rectangle(0, 0, Me.Width - 103, 50)
  100. If dragRect.Contains(New Point(e.X, e.Y)) Then
  101. isDragging = True
  102. savePoint = New Point(e.X, e.Y)
  103. End If
  104. Dim clickRect As New Rectangle(Width - 40, 10, 24, 24)
  105. If clickRect.Contains(New Point(e.X, e.Y)) Then
  106. Environment.[Exit](0)
  107. End If
  108. If New Rectangle(Width - 70, 10, 24, 24).Contains(New Point(mouseX, mouseY)) Then
  109. If FindForm.WindowState = FormWindowState.Maximized Then
  110. FindForm.WindowState = FormWindowState.Normal
  111. Else
  112. FindForm.WindowState = FormWindowState.Maximized
  113. End If
  114. End If
  115. If New Rectangle(Width - 100, 10, 24, 24).Contains(New Point(mouseX, mouseY)) Then
  116. FindForm.WindowState = FormWindowState.Minimized
  117. End If
  118. '
  119. MyBase.OnMouseDown(e)
  120. End Sub
  121.  
  122. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  123. isDragging = False
  124. MyBase.OnMouseUp(e)
  125. End Sub
  126.  
  127. Private mouseX As Integer
  128. Private mouseY As Integer
  129. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  130.  
  131. mouseX = e.X
  132. mouseY = e.Y
  133. If isDragging Then
  134. Dim screenPoint As Point = PointToScreen(e.Location)
  135.  
  136. FindForm().Location = New Point(screenPoint.X - Me.savePoint.X, screenPoint.Y - Me.savePoint.Y)
  137. End If
  138. MyBase.OnMouseMove(e)
  139. Invalidate()
  140. End Sub
  141.  
  142. #End Region
  143. Public Function Base64ToImage(base64String As String) As Image
  144. 'I did not write this Function
  145. ' Convert Base64 String to byte[]
  146. Dim imageBytes As Byte() = Convert.FromBase64String(base64String)
  147. Dim ms As New MemoryStream(imageBytes, 0, imageBytes.Length)
  148.  
  149. ' Convert byte[] to Image
  150. ms.Write(imageBytes, 0, imageBytes.Length)
  151. Dim image__1 As Image = Image.FromStream(ms, True)
  152. Return image__1
  153. End Function
  154. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement