netrosly

dot Net Streamer Container

Dec 23rd, 2014
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.44 KB | None | 0 0
  1. Public Class TestForm
  2. Inherits ContainerControl
  3. Function NoiseBrush(colors As Color()) As TextureBrush
  4. Dim B As New Bitmap(128, 128)
  5. Dim R As New Random(128)
  6.  
  7. For X As Integer = 0 To B.Width - 1
  8. For Y As Integer = 0 To B.Height - 1
  9. B.SetPixel(X, Y, colors(R.Next(colors.Length)))
  10. Next
  11. Next
  12.  
  13. Dim T As New TextureBrush(B)
  14. B.Dispose()
  15.  
  16. Return T
  17. End Function
  18. #Region "Properties"
  19. Public ColorBarTop As Color
  20. Public ColorBarBottom As Color
  21. Public Icon As Image
  22. Public IconBorder As Boolean = False
  23. Public HeaderTitle As String = ".NET"
  24. Public Title As String = ".STREAMER"
  25. <PropertyTab("ColorBarTop")> _
  26. <DisplayName("ColorBarTop")> _
  27. Public Property ColorBT() As Color
  28. Get
  29. Return ColorBarTop
  30. End Get
  31. Set(value As Color)
  32. ColorBarTop = value
  33. End Set
  34. End Property
  35. <PropertyTab("ColorBarBottom")> _
  36. <DisplayName("ColorBarBottom")> _
  37. Public Property ColorBB() As Color
  38. Get
  39. Return ColorBarBottom
  40. End Get
  41. Set(value As Color)
  42. ColorBarBottom = value
  43. End Set
  44. End Property
  45. <PropertyTab("Icon")> _
  46. <DisplayName("Icon")> _
  47. Public Property Iconn() As Image
  48. Get
  49. Return Icon
  50. End Get
  51. Set(value As Image)
  52. Icon = value
  53. End Set
  54. End Property
  55. <PropertyTab("IconBorder")> _
  56. <DisplayName("IconBorder")> _
  57. Public Property IconnBorder() As Boolean
  58. Get
  59. Return IconBorder
  60. End Get
  61. Set(value As Boolean)
  62. IconBorder = value
  63. End Set
  64. End Property
  65. <PropertyTab("HeaderTitle")> _
  66. <DisplayName("HeaderTitle")> _
  67. Public Property Header() As String
  68. Get
  69. Return HeaderTitle
  70. End Get
  71. Set(value As String)
  72. HeaderTitle = value
  73. End Set
  74. End Property
  75. <PropertyTab("Title")> _
  76. <DisplayName("Title")> _
  77. Public Property Titlee() As String
  78. Get
  79. Return Title
  80. End Get
  81. Set(value As String)
  82. Title = value
  83. End Set
  84. End Property
  85. #End Region
  86. Sub New()
  87. Me.BackColor = Color.FromArgb(45, 45, 45)
  88. Me.DoubleBuffered = True
  89. End Sub
  90. Dim TopTexture As TextureBrush = NoiseBrush({Color.FromArgb(29, 25, 21), Color.FromArgb(31, 27, 23), Color.FromArgb(27, 23, 29)})
  91. Private Sub TestForm_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
  92. e.Graphics.SmoothingMode = SmoothingMode.HighQuality
  93. 'Border And Background
  94. Dim Rect = New Rectangle(0, 0, Me.Width, Me.Height)
  95. e.Graphics.FillRectangle(TopTexture, Rect)
  96. e.Graphics.DrawRectangle(New Pen(Color.DimGray), New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  97. For i As Integer = 0 To 14
  98. Dim x As Integer = i * 20 - 150
  99. Dim y As Integer = i * 20 - 120
  100. Dim wid As Integer = Me.Width + 20 - x * 2
  101. Dim hei As Integer = Me.Height + 30 - y * 2
  102. e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(1, 255, 255, 255)), New Rectangle(x, y, wid, hei))
  103. Next
  104. 'Bar
  105. Dim rectsquare As New Rectangle(1, 15, 13, 55)
  106. Dim brush As New LinearGradientBrush(rectsquare, ColorBarTop, ColorBarBottom, 90.0!)
  107. e.Graphics.FillRectangle(brush, rectsquare)
  108. 'Icon
  109. If Not Icon Is Nothing Then
  110. e.Graphics.DrawImage(Icon, New Rectangle(18, 20, 25, 25))
  111. End If
  112. 'Icon Border
  113. If IconBorder = True Then
  114. e.Graphics.DrawRectangle(New Pen(Color.DimGray), New Rectangle(18, 20, 25, 25))
  115. End If
  116. 'Header
  117. e.Graphics.DrawString(HeaderTitle, New Font("Arial", 10, FontStyle.Regular), Brushes.White, New Rectangle(45, 32, 1000, 16))
  118. 'Title
  119. e.Graphics.DrawString(Title, New Font("Arial", 10, FontStyle.Regular), Brushes.White, New Rectangle(18, 52, 1000, 16))
  120. 'Buttons
  121. e.Graphics.DrawString("r", New Font("Webdings", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(Me.Width - 25, 10, 16, 16))
  122. e.Graphics.DrawString("0", New Font("Webdings", 12, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(Me.Width - 45, 8, 16, 16))
  123. 'Example
  124. 'Dim point1 As New PointF(5, 5)
  125. 'Dim point2 As New PointF(10, 10)
  126. 'Dim point3 As New PointF(0, 10)
  127. 'Dim curvePoints As PointF() = {point1, point2, point3}
  128.  
  129. '' Define fill mode.
  130. 'Dim newFillMode As FillMode = FillMode.Winding
  131. 'e.Graphics.FillPolygon(New SolidBrush(Color.White), curvePoints, newFillMode)
  132. End Sub
  133. #Region "ThemeDraggable"
  134. Dim x, y As Integer
  135. Private savePoint As New Point(0, 0)
  136. Private isDragging As Boolean = False
  137.  
  138. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  139. Dim dragRect As New Rectangle(0, 0, Me.Width, 15)
  140. If dragRect.Contains(New Point(e.X, e.Y)) Then
  141. isDragging = True
  142. savePoint = New Point(e.X, e.Y)
  143. End If
  144. Dim clickRect As New Rectangle(Me.Width - 25, 10, 16, 16)
  145. If clickRect.Contains(New Point(e.X, e.Y)) Then
  146. Environment.[Exit](0)
  147. End If
  148. Dim clickRect2 As New Rectangle(Me.Width - 45, 8, 16, 16)
  149. If clickRect2.Contains(New Point(e.X, e.Y)) Then
  150. FindForm.WindowState = FormWindowState.Minimized
  151. End If
  152. '
  153. MyBase.OnMouseDown(e)
  154. End Sub
  155.  
  156. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  157. isDragging = False
  158. MyBase.OnMouseUp(e)
  159. End Sub
  160.  
  161. Private mouseX As Integer
  162. Private mouseY As Integer
  163. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  164.  
  165. mouseX = e.X
  166. mouseY = e.Y
  167. If New Rectangle(Width - 40, 10, 24, 24).Contains(New Point(x, y)) Then
  168. FindForm.Close()
  169. End If
  170. If isDragging Then
  171. Dim screenPoint As Point = PointToScreen(e.Location)
  172.  
  173. FindForm().Location = New Point(screenPoint.X - Me.savePoint.X, screenPoint.Y - Me.savePoint.Y)
  174. End If
  175. MyBase.OnMouseMove(e)
  176. Invalidate()
  177. End Sub
  178.  
  179. #End Region
  180. Private Sub TestForm_Resize(sender As Object, e As EventArgs) Handles Me.Resize
  181. Me.Refresh()
  182. End Sub
  183. End Class
Add Comment
Please, Sign In to add comment