netrosly

YouStreamForm

Aug 1st, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 13.33 KB | None | 0 0
  1. Imports System, System.IO, System.Collections.Generic
  2. Imports System.Drawing, System.Drawing.Drawing2D
  3. Imports System.ComponentModel, System.Windows.Forms
  4. Imports System.Runtime.InteropServices
  5. Imports System.Drawing.Imaging
  6. Public Class FormContainer
  7.     Inherits Panel
  8.     Property Logo As Image
  9.     Sub New()
  10.         Me.Dock = DockStyle.Fill
  11.         Me.DoubleBuffered = True
  12.         Me.Padding = New Padding(2, 30, 2, 2)
  13.         SetStyle(139270, True)
  14.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  15.  
  16.         Font = New Font("Verdana", 8S)
  17.  
  18.     End Sub
  19. #Region "Round Rectangle"
  20.     Public Shared Function NTRound(rectangle As Rectangle, slope As Integer) As GraphicsPath
  21.         Dim path = New GraphicsPath(FillMode.Winding)
  22.         path.AddArc(rectangle.X - slope, rectangle.Y, slope, slope, 180.0F, 90.0F)
  23.         path.AddArc(rectangle.Right, rectangle.Y, slope, slope, 270.0F, 90.0F)
  24.         path.AddArc(rectangle.Right - slope, rectangle.Bottom - slope, slope, slope, 0.0F, 90.0F)
  25.         path.AddArc(rectangle.X, rectangle.Bottom - slope, slope, slope, 90.0F, 90.0F)
  26.         path.CloseFigure()
  27.         Return path
  28.     End Function
  29.  
  30.     Public Shared Function NTRound(x As Integer, y As Integer, height As Integer, width As Integer, slope As Integer) As GraphicsPath
  31.         Return Round(New Rectangle(x, y, height, width), slope)
  32.     End Function
  33.  
  34.     Public Shared Function Round(rectangle As Rectangle, slope As Integer) As GraphicsPath
  35.         Dim path = New GraphicsPath(FillMode.Winding)
  36.         path.AddArc(rectangle.X, rectangle.Y, slope, slope, 180.0F, 90.0F)
  37.         path.AddArc(rectangle.Right - slope, rectangle.Y, slope, slope, 270.0F, 90.0F)
  38.         path.AddArc(rectangle.Right - slope, rectangle.Bottom - slope, slope, slope, 0.0F, 90.0F)
  39.         path.AddArc(rectangle.X, rectangle.Bottom - slope, slope, slope, 90.0F, 90.0F)
  40.         path.CloseFigure()
  41.         Return path
  42.     End Function
  43.  
  44.     Public Shared Function Round(x As Integer, y As Integer, height As Integer, width As Integer, slope As Integer) As GraphicsPath
  45.         Return Round(New Rectangle(x, y, height, width), slope)
  46.     End Function
  47. #End Region
  48.  
  49.     Private Sub FormContainer_Leave(sender As Object, e As EventArgs) Handles Me.Leave
  50.         resizeleft = False
  51.         resizeright = False
  52.         resizebot = False
  53.     End Sub
  54.  
  55.     Private Sub FormContainer_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
  56.         If e.Button = Windows.Forms.MouseButtons.Left Then
  57.             If New Rectangle(Me.Width - 45, -20, 40, 38).Contains(e.X, e.Y) Then
  58.                 Close = True
  59.                 Max = False
  60.                 Min = False
  61.                 Main.Close()
  62.  
  63.                 Me.Cursor = Cursors.Arrow
  64.                 Me.Refresh()
  65.             ElseIf New Rectangle(Me.Width - 75, -20, 30, 38).Contains(e.X, e.Y) Then
  66.                 'If Max = True Then
  67.                 '    Main.WindowState = FormWindowState.Normal
  68.                 '    Max = False
  69.                 'Else
  70.                 '    Main.WindowState = FormWindowState.Maximized
  71.                 '    Max = True
  72.                 'End If
  73.                 Main.WindowState = FormWindowState.Minimized
  74.                 Close = False
  75.                 MinHover = False
  76.                 Min = False
  77.                 Me.Cursor = Cursors.Arrow
  78.                 Me.Refresh()
  79.             ElseIf New Rectangle(Me.Width - 105, -20, 30, 38).Contains(e.X, e.Y) Then
  80.                 Max = False
  81.                 Close = False
  82.                 Min = True
  83.                 'Main.WindowState = FormWindowState.Minimized
  84.                 Me.Cursor = Cursors.Arrow
  85.                 Me.Refresh()
  86.             ElseIf Not New Rectangle(Me.Width - 45, -20, 40, 38).Contains(e.X, e.Y) And Not New Rectangle(Me.Width - 105, -20, 30, 38).Contains(e.X, e.Y) And Not New Rectangle(Me.Width - 75, -20, 30, 38).Contains(e.X, e.Y) And New Rectangle(2, 1, Me.Width - 4, 49).Contains(e.X, e.Y) Then
  87.                 moving = True
  88.                 movelocclick = e.Location
  89.                 Me.Cursor = Cursors.Arrow
  90.                 Me.Refresh()
  91.                 'ElseIf New Rectangle(Me.Width - 8, 1, 6, Me.Height - 1).Contains(e.X, e.Y) Then
  92.                 '    resizeright = True
  93.                 '    Cursor = Cursors.PanEast
  94.                 'ElseIf New Rectangle(0, 1, 3, Me.Height - 1).Contains(e.X, e.Y) Then
  95.                 '    resizeleft = True
  96.                 '    resizeright = False
  97.                 '    Cursor = Cursors.PanWest
  98.             End If
  99.      
  100.         End If
  101.     End Sub
  102.     Dim moving As Boolean = False
  103.     Dim movelocclick As Point
  104.     Dim resizeleft As Boolean = False
  105.     Dim resizetop As Boolean = False
  106.     Dim resizeright As Boolean = False
  107.     Dim resizebot As Boolean = False
  108.     Dim CloseHover As Boolean = False
  109.     Dim Close As Boolean = False
  110.     Dim MaxHover As Boolean = False
  111.     Dim Max As Boolean = False
  112.     Dim MinHover As Boolean = False
  113.     Dim Min As Boolean = False
  114.     Dim Shadow As Boolean = False
  115.     Private Sub FormContainer_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
  116.         If New Rectangle(Me.Width - 45, -20, 40, 38).Contains(e.X, e.Y) Then
  117.             CloseHover = True
  118.             MaxHover = False
  119.             MinHover = False
  120.             Me.Cursor = Cursors.Hand
  121.             Me.Refresh()
  122.         ElseIf New Rectangle(Me.Width - 75, -20, 30, 38).Contains(e.X, e.Y) Then
  123.             MaxHover = False
  124.             CloseHover = False
  125.             MinHover = True
  126.             Me.Cursor = Cursors.Hand
  127.             Me.Refresh()
  128.         ElseIf New Rectangle(Me.Width - 105, -20, 30, 38).Contains(e.X, e.Y) Then
  129.             MaxHover = False
  130.             CloseHover = False
  131.             MinHover = False
  132.             Me.Cursor = Cursors.Hand
  133.             Me.Refresh()
  134.         ElseIf Not New Rectangle(Me.Width - 45, -20, 40, 38).Contains(e.X, e.Y) Or Not New Rectangle(Me.Width - 105, -20, 30, 38).Contains(e.X, e.Y) Or Not New Rectangle(Me.Width - 75, -20, 30, 38).Contains(e.X, e.Y) And New Rectangle(2, 1, Me.Width - 4, 49).Contains(e.X, e.Y) Then
  135.             CloseHover = False
  136.             MaxHover = False
  137.             MinHover = False
  138.             Me.Cursor = Cursors.Arrow
  139.             Me.Refresh()
  140.         End If
  141.         If moving = True Then
  142.             Parent.Location = MousePosition - CType(movelocclick, Size)
  143.         End If
  144.  
  145.         If resizeright Then
  146.             Cursor = Cursors.PanEast
  147.             If Parent.Width > 140 Or Parent.Width = 139 Then
  148.                 Parent.Width = (MousePosition.X - Parent.Location.X)
  149.                 'Parent.Location = MousePosition - CType(New Point(Parent.Location.X - 1, Parent.Location.Y), Size)
  150.  
  151.             End If
  152.         End If
  153.         If resizeleft Then
  154.             Cursor = Cursors.PanWest
  155.             Parent.Location = New Point(MousePosition.X, Parent.Location.Y)
  156.             Parent.Width = (MousePosition.X + Parent.Location.X)
  157.         End If
  158.     End Sub
  159.     Private Declare Function GetCursorPos Lib "user32" (lpPoint As Point) As Point
  160.  
  161.  
  162.     Private Sub FormContainer_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
  163.         moving = False
  164.         resizeleft = False
  165.     End Sub
  166.  
  167.  
  168.     Private Sub FormContainer_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
  169.         Dim g As Graphics = e.Graphics
  170.         g.SmoothingMode = SmoothingMode.AntiAlias
  171.         g.Clear(Color.FromArgb(255, 84, 84, 84))
  172.         'g.DrawRectangle(New Pen(Color.FromArgb(255, 50, 50, 50)), New Rectangle(1, 1, Me.Width - 3, Me.Height - 3))
  173.         'g.DrawRectangle(New Pen(Color.FromArgb(255, 81, 81, 81)), New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  174.         g.FillRectangle(New SolidBrush(Color.FromArgb(255, 51, 51, 51)), New Rectangle(0, 0, Me.Width - 1, 29)) 'New Rectangle(2, 1, Me.Width - 4, 29)
  175.         g.DrawLine(New Pen(Color.FromArgb(255, 70, 70, 70)), New Point(1, 29), New Point(Me.Width - 3, 29))
  176.         g.DrawLine(New Pen(Color.FromArgb(255, 34, 34, 34)), New Point(1, 30), New Point(Me.Width - 3, 30))
  177.         Dim lgbShadow = New LinearGradientBrush(New Rectangle(1, 31, Me.Width - 3, 10), Color.FromArgb(120, Color.Black), Color.Transparent, 90.0!)
  178.         g.FillRectangle(lgbShadow, New Rectangle(1, 30, Me.Width - 3, 10))
  179.         'Try : g.DrawImage(Logo, New Rectangle(5, 2, 24, 24)) : Catch ex As Exception : End Try
  180.         g.FillPath(New SolidBrush(Color.FromArgb(146, 50, 42)), Round(New Rectangle(30, 3, 53, 21), 10))
  181.         g.DrawString("You  Stream", New Font("Arial", 9, FontStyle.Bold), New SolidBrush(Color.FromArgb(248, 248, 248)), New Rectangle(5, 6, Me.Width / 3, 35), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near})
  182.  
  183.         'No Hover/Click Min
  184.         If MinHover = True Then
  185.             lgbShadow = New LinearGradientBrush(New Rectangle(Me.Width - 75, -20, 40, 38), Color.FromArgb(255, 51, 51, 51), Color.FromArgb(151, 151, 71), 270.0!) '205, 151, 71, 71
  186.         Else
  187.             lgbShadow = New LinearGradientBrush(New Rectangle(Me.Width - 75, -20, 40, 38), Color.FromArgb(255, 51, 51, 51), Color.FromArgb(205, 71, 71, 71), 270.0!) '205, 151, 71, 71
  188.         End If
  189.         g.FillPath(lgbShadow, Round(New Rectangle(Me.Width - 75, -20, 40, 38), 10))
  190.         g.DrawPath(New Pen(Color.FromArgb(255, 81, 81, 81)), Round(New Rectangle(Me.Width - 75, -19, 40, 38), 10))
  191.         g.DrawPath(New Pen(Color.FromArgb(255, 31, 31, 31)), Round(New Rectangle(Me.Width - 75, -20, 40, 38), 10))
  192.         'g.FillRectangle(New SolidBrush(Color.FromArgb(34, 34, 34)), New Rectangle(Me.Width - 65, 10, 12, 3))
  193.         g.SmoothingMode = SmoothingMode.HighSpeed
  194.         g.FillRectangle(New SolidBrush(Color.FromArgb(79, 79, 79)), New Rectangle(Me.Width - 65, 10, 12, 2))
  195.         g.SmoothingMode = SmoothingMode.AntiAlias
  196.         ''No Hover/Click Max
  197.         'If MaxHover = True Then
  198.         '    lgbShadow = New LinearGradientBrush(New Rectangle(Me.Width - 75, -20, 40, 38), Color.FromArgb(255, 51, 51, 51), Color.FromArgb(155, 71, 151, 71), 270.0!) '155, 71, 151, 71
  199.         'Else
  200.         '    lgbShadow = New LinearGradientBrush(New Rectangle(Me.Width - 75, -20, 40, 38), Color.FromArgb(255, 51, 51, 51), Color.FromArgb(205, 71, 71, 71), 270.0!) '155, 71, 151, 71
  201.         'End If
  202.         'g.FillPath(lgbShadow, Round(New Rectangle(Me.Width - 75, -20, 40, 38), 10))
  203.         'g.DrawPath(New Pen(Color.FromArgb(255, 81, 81, 81)), Round(New Rectangle(Me.Width - 75, -19, 40, 38), 10))
  204.         'g.DrawPath(New Pen(Color.FromArgb(255, 31, 31, 31)), Round(New Rectangle(Me.Width - 75, -20, 40, 38), 10))
  205.         'If Max = True Then
  206.         '    'icon\/Shadow(34)
  207.         '    g.DrawRectangle(New Pen(Color.FromArgb(34, 34, 34)), New Rectangle(Me.Width - 64, 6, 14, 10))
  208.         '    g.DrawRectangle(New Pen(Color.FromArgb(78, 78, 78)), New Rectangle(Me.Width - 63, 7, 12, 8))
  209.         '    g.FillRectangle(New SolidBrush(Color.FromArgb(34, 34, 34)), New Rectangle(Me.Width - 63, 7, 12, 3))
  210.         '    g.FillRectangle(New SolidBrush(Color.FromArgb(78, 78, 78)), New Rectangle(Me.Width - 63, 7, 12, 2))
  211.         '    'icon\/Shadow(34)
  212.         '    g.DrawRectangle(New Pen(Color.FromArgb(34, 34, 34)), New Rectangle(Me.Width - 67, 4, 14, 10))
  213.         '    g.DrawRectangle(New Pen(Color.FromArgb(78, 78, 78)), New Rectangle(Me.Width - 66, 5, 12, 8))
  214.         '    g.FillRectangle(New SolidBrush(Color.FromArgb(34, 34, 34)), New Rectangle(Me.Width - 66, 5, 12, 3))
  215.         '    g.FillRectangle(New SolidBrush(Color.FromArgb(78, 78, 78)), New Rectangle(Me.Width - 66, 5, 12, 2))
  216.         'Else
  217.         '    'icon\/Shadow(34)
  218.         '    g.DrawRectangle(New Pen(Color.FromArgb(34, 34, 34)), New Rectangle(Me.Width - 67, 4, 14, 10))
  219.         '    g.DrawRectangle(New Pen(Color.FromArgb(78, 78, 78)), New Rectangle(Me.Width - 66, 5, 12, 8))
  220.         '    g.FillRectangle(New SolidBrush(Color.FromArgb(34, 34, 34)), New Rectangle(Me.Width - 66, 5, 12, 3))
  221.         '    g.FillRectangle(New SolidBrush(Color.FromArgb(78, 78, 78)), New Rectangle(Me.Width - 66, 5, 12, 2))
  222.         'End If
  223.      
  224.  
  225.         'No Hover/Click (Close Button
  226.         If CloseHover = True Then
  227.             lgbShadow = New LinearGradientBrush(New Rectangle(Me.Width - 45, -20, 40, 38), Color.FromArgb(255, 51, 51, 51), Color.FromArgb(205, 151, 71, 71), 270.0!) '205, 151, 71, 71
  228.         Else
  229.             lgbShadow = New LinearGradientBrush(New Rectangle(Me.Width - 45, -20, 40, 38), Color.FromArgb(255, 51, 51, 51), Color.FromArgb(205, 71, 71, 71), 270.0!) '205, 151, 71, 71
  230.         End If
  231.         g.FillPath(lgbShadow, Round(New Rectangle(Me.Width - 45, -20, 40, 38), 10))
  232.         g.DrawPath(New Pen(Color.FromArgb(255, 81, 81, 81)), Round(New Rectangle(Me.Width - 45, -19, 40, 38), 10))
  233.         g.DrawPath(New Pen(Color.FromArgb(255, 31, 31, 31)), Round(New Rectangle(Me.Width - 45, -20, 40, 38), 10))
  234.         'icon \/Shadow(34)
  235.         'g.DrawLine(New Pen(Color.FromArgb(34, 34, 34)), New Point(Me.Width - 21, 5), New Point(Me.Width - 27, 12))
  236.         'g.DrawLine(New Pen(Color.FromArgb(34, 34, 34)), New Point(Me.Width - 29, 5), New Point(Me.Width - 19, 12))
  237.  
  238.         g.DrawLine(New Pen(Color.FromArgb(89, 89, 89)), New Point(Me.Width - 20, 5), New Point(Me.Width - 28, 12))
  239.         g.DrawLine(New Pen(Color.FromArgb(89, 89, 89)), New Point(Me.Width - 28, 5), New Point(Me.Width - 20, 12))
  240.  
  241.     End Sub
  242.  
  243. End Class
Add Comment
Please, Sign In to add comment