netrosly

CupCake Theme GDI

Aug 11th, 2015
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 10.97 KB | None | 0 0
  1. '[By Nettro from HF]
  2. Public Class CC_Form
  3.   Inherits Control
  4.   Property OddColor As Color = Color.FromArgb(251, 161, 161)
  5.   Property EvenColor As Color = Color.FromArgb(252, 174, 174)
  6.   Property Fence_Width As Integer = 32
  7.   Property header_Height As Integer = 80
  8.   Property Ribbon_Side_Color As Color = Color.FromArgb(57, 229, 189)
  9.   Property Ribbon_Color As Color = Color.FromArgb(35, 207, 167)
  10.   Property Bubble_Color As Color = Color.FromArgb(251, 161, 161)
  11.   Property Border_Color1 As Color = Color.FromArgb(160, 236, 217)
  12.   Property Border_Color2 As Color = Color.FromArgb(35, 207, 167)
  13.   Property Border_Color3 As Color = Color.FromArgb(57, 229, 189)
  14.   Property Bottom_B_Color1 As Color = Color.FromArgb(230, 201, 255)
  15.   Property Bottom_B_Color2 As Color = Color.FromArgb(135, 92, 173)
  16.   Property Bottom_B_Color3 As Color = Color.FromArgb(205, 171, 234)
  17.   Property Top_Fence_Color As Color = Color.FromArgb(183, 239, 251)
  18.   Property Rounded_Corners As Boolean = True
  19.   Property Max_Tog As Boolean = False
  20.   Property Min_Tog As Boolean = False
  21.   Property Close_Tog As Boolean = False
  22.   Sub New()
  23.     Me.BackColor = Color.White
  24.     Me.DoubleBuffered = True
  25.     Me.Dock = DockStyle.Fill
  26.   End Sub
  27.   <Runtime.InteropServices.DllImport("Gdi32.dll", EntryPoint:="CreateRoundRectRgn")>
  28.   Private Shared Function CreateRoundRectRgn(nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer, nWidthEllipse As Integer, nHeightEllipse As Integer) As IntPtr
  29.   End Function
  30.   Private Sub CC_Form_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
  31.     If Rounded_Corners = True Then
  32.       Me.Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Me.Width + 1, Me.Height + 1, 11, 11))
  33.     End If
  34.     e.Graphics.Clear(BackColor)
  35.     e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  36.     Dim mx_f_i As Integer = Math.Ceiling(Me.Width / Fence_Width)
  37.     For i As Integer = 0 To mx_f_i
  38.       If i Mod 2 <> 0 Then
  39.         Dim FencePs As Point() = {New Point(Fence_Width * i, header_Height), New Point(((Fence_Width * i) - Fence_Width / 2), header_Height - 20), New Point((Fence_Width * i) - Fence_Width, header_Height), New Point((Fence_Width * i) - Fence_Width, Me.Height), New Point(Fence_Width * i, Me.Height), New Point(Fence_Width * i, header_Height)}
  40.         e.Graphics.FillPolygon(New SolidBrush(OddColor), FencePs)
  41.       Else
  42.         Dim FencePs As Point() = {New Point(Fence_Width * i, header_Height), New Point(((Fence_Width * i) - Fence_Width / 2), header_Height - 20), New Point((Fence_Width * i) - Fence_Width, header_Height), New Point((Fence_Width * i) - Fence_Width, Me.Height), New Point(Fence_Width * i, Me.Height), New Point(Fence_Width * i, header_Height)}
  43.         e.Graphics.FillPolygon(New SolidBrush(EvenColor), FencePs)
  44.       End If
  45.     Next
  46.     'Bubble
  47.     e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(60, Color.Black)), New Rectangle(Me.Width / 2 - 40, 8, 80, 80))
  48.     e.Graphics.FillEllipse(New SolidBrush(Bubble_Color), New Rectangle(Me.Width / 2 - 40, 5, 80, 80))
  49.     e.Graphics.DrawImage(FindForm.Icon.ToBitmap, New Rectangle(Me.Width / 2 - 12, 12, 24, 24))
  50.     Dim fmtxsz As SizeF = e.Graphics.MeasureString(FindForm.Text, FindForm.Font)
  51.     Dim rib_rt As Point() = {New Point(Me.Width / 2 - (fmtxsz.Width + 8) / 2, 40), New Point(Me.Width / 2 - (fmtxsz.Width + 18) / 2, 40), New Point(Me.Width / 2 - (fmtxsz.Width + 13) / 2, 40 + fmtxsz.Height / 2), New Point(Me.Width / 2 - (fmtxsz.Width + 18) / 2, 40 + fmtxsz.Height), New Point(Me.Width / 2 - (fmtxsz.Width + 8) / 2, 40 + fmtxsz.Height), New Point(Me.Width / 2 - (fmtxsz.Width + 8) / 2, 40)}
  52.     Dim rib_lt As Point() = {New Point(Me.Width / 2 + (fmtxsz.Width + 10) / 2, 40), New Point(Me.Width / 2 + (fmtxsz.Width + 20) / 2, 40), New Point(Me.Width / 2 + (fmtxsz.Width + 15) / 2, 40 + fmtxsz.Height / 2), New Point(Me.Width / 2 + (fmtxsz.Width + 20) / 2, 40 + fmtxsz.Height), New Point(Me.Width / 2 + (fmtxsz.Width + 10) / 2, 40 + fmtxsz.Height), New Point(Me.Width / 2 + (fmtxsz.Width + 10) / 2, 40)}
  53.     e.Graphics.FillPolygon(New SolidBrush(Ribbon_Side_Color), rib_rt)
  54.     e.Graphics.FillPolygon(New SolidBrush(Ribbon_Side_Color), rib_lt)
  55.     e.Graphics.FillRectangle(New SolidBrush(Ribbon_Color), New Rectangle(Me.Width / 2 - (fmtxsz.Width + 8) / 2, 40, fmtxsz.Width + 8, fmtxsz.Height + 2))
  56.     e.Graphics.DrawString(FindForm.Text, FindForm.Font, Brushes.White, New Rectangle(Me.Width / 2 - (fmtxsz.Width + 8) / 2, 40, fmtxsz.Width + 8, fmtxsz.Height + 2), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  57.     'Border
  58.     e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(140, Color.White)), New Rectangle(0, header_Height + 54, Me.Width, Me.Height - (header_Height + 104)))
  59.     e.Graphics.FillRectangle(New SolidBrush(Border_Color1), New Rectangle(0, header_Height + 20, Me.Width, 18))
  60.  
  61.     e.Graphics.FillRectangle(New SolidBrush(Border_Color3), New Rectangle(0, header_Height + 54, Me.Width, 6))
  62.     e.Graphics.FillRectangle(New SolidBrush(Border_Color2), New Rectangle(0, header_Height + 26, Me.Width, 30))
  63.     'Bttom
  64.     e.Graphics.FillRectangle(New SolidBrush(Bottom_B_Color1), New Rectangle(0, Me.Height - (header_Height) + 20, Me.Width, 18))
  65.  
  66.     e.Graphics.FillRectangle(New SolidBrush(Bottom_B_Color3), New Rectangle(0, Me.Height - (header_Height) + 54, Me.Width, 6))
  67.     e.Graphics.FillRectangle(New SolidBrush(Bottom_B_Color2), New Rectangle(0, Me.Height - (header_Height) + 26, Me.Width, 30))
  68.     'Fence Top
  69.     Dim FenceTP As Point() = {New Point(Me.Width, 10), New Point(Me.Width - 70, 10), New Point(Me.Width - 76, 22), New Point(Me.Width - 70, 34), New Point(Me.Width, 34), New Point(Me.Width, 10)}
  70.     e.Graphics.FillPolygon(New SolidBrush(Top_Fence_Color), FenceTP)
  71.     'Buttons
  72.     If Close_Tog = False Then
  73.       e.Graphics.FillEllipse(Brushes.LightGray, New Rectangle(Me.Width - 20, 13, 16, 16))
  74.       e.Graphics.FillEllipse(Brushes.White, New Rectangle(Me.Width - 20, 12, 16, 16))
  75.       e.Graphics.DrawString("x", New Font("Arial", 10, FontStyle.Bold), Brushes.DarkGray, New Rectangle(Me.Width - 20, 11, 16, 16), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  76.     Else
  77.       e.Graphics.FillEllipse(Brushes.LightGray, New Rectangle(Me.Width - 20, 13, 16, 16))
  78.       e.Graphics.FillEllipse(Brushes.White, New Rectangle(Me.Width - 20, 12, 16, 16))
  79.       e.Graphics.DrawString("x", New Font("Arial", 10, FontStyle.Bold), Brushes.DarkGray, New Rectangle(Me.Width - 20, 11, 16, 16), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  80.       e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(80, Color.Black)), New Rectangle(Me.Width - 20, 12, 16, 17))
  81.     End If
  82.    
  83.     If Max_Tog = False Then
  84.       e.Graphics.FillEllipse(Brushes.LightGray, New Rectangle(Me.Width - 40, 13, 16, 16))
  85.       e.Graphics.FillEllipse(Brushes.White, New Rectangle(Me.Width - 40, 12, 16, 16))
  86.       e.Graphics.DrawString("+", New Font("Arial", 11, FontStyle.Bold), Brushes.DarkGray, New Rectangle(Me.Width - 40, 13, 16, 16), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  87.     Else
  88.       e.Graphics.FillEllipse(Brushes.LightGray, New Rectangle(Me.Width - 40, 13, 16, 16))
  89.       e.Graphics.FillEllipse(Brushes.White, New Rectangle(Me.Width - 40, 12, 16, 16))
  90.       e.Graphics.DrawString("+", New Font("Arial", 11, FontStyle.Bold), Brushes.DarkGray, New Rectangle(Me.Width - 40, 13, 16, 16), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  91.       e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(80, Color.Black)), New Rectangle(Me.Width - 40, 12, 16, 17))
  92.     End If
  93.    
  94.     If Min_Tog = False Then
  95.       e.Graphics.FillEllipse(Brushes.LightGray, New Rectangle(Me.Width - 60, 13, 16, 16))
  96.       e.Graphics.FillEllipse(Brushes.White, New Rectangle(Me.Width - 60, 12, 16, 16))
  97.       e.Graphics.DrawString("-", New Font("Arial", 11, FontStyle.Bold), Brushes.DarkGray, New Rectangle(Me.Width - 59, 13, 16, 16), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  98.     Else
  99.       e.Graphics.FillEllipse(Brushes.LightGray, New Rectangle(Me.Width - 60, 13, 16, 16))
  100.       e.Graphics.FillEllipse(Brushes.White, New Rectangle(Me.Width - 60, 12, 16, 16))
  101.       e.Graphics.DrawString("-", New Font("Arial", 11, FontStyle.Bold), Brushes.DarkGray, New Rectangle(Me.Width - 59, 13, 16, 16), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  102.       e.Graphics.FillEllipse(New SolidBrush(Color.FromArgb(80, Color.Black)), New Rectangle(Me.Width - 60, 12, 16, 17))
  103.     End If
  104.    
  105.   End Sub
  106. #Region "ThemeDraggable"
  107.   Dim x, y As Integer
  108.   Private savePoint As New Point(0, 0)
  109.   Private isDragging As Boolean = False
  110.  
  111.   Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  112.     Dim dragRect As New Rectangle(0, 0, Me.Width - 70, header_Height)
  113.     If dragRect.Contains(New Point(e.X, e.Y)) Then
  114.       isDragging = True
  115.       savePoint = New Point(e.X, e.Y)
  116.     End If
  117.         '
  118.         If e.Button = System.Windows.Forms.MouseButtons.Left Then
  119.             If New Rectangle(Me.Width - 20, 13, 16, 16).Contains(e.X, e.Y) Then
  120.                 Environment.Exit(0)
  121.             End If
  122.             If New Rectangle(Me.Width - 40, 13, 16, 16).Contains(e.X, e.Y) Then
  123.                 If FindForm.WindowState = FormWindowState.Normal Then
  124.                     FindForm.WindowState = FormWindowState.Maximized
  125.                 Else
  126.                     FindForm.WindowState = FormWindowState.Normal
  127.                 End If
  128.             End If
  129.             If New Rectangle(Me.Width - 60, 13, 16, 16).Contains(e.X, e.Y) Then
  130.                 FindForm.WindowState = FormWindowState.Minimized
  131.             End If
  132.         End If
  133.         MyBase.OnMouseDown(e)
  134.   End Sub
  135.  
  136.   Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  137.     isDragging = False
  138.     MyBase.OnMouseUp(e)
  139.   End Sub
  140.  
  141.   Private mouseX As Integer
  142.   Private mouseY As Integer
  143.   Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  144.  
  145.     mouseX = e.X
  146.     mouseY = e.Y
  147.     If New Rectangle(Me.Width - 20, 13, 16, 16).Contains(e.X, e.Y) Then
  148.       Close_Tog = True
  149.       Cursor = Cursors.Hand
  150.     Else
  151.       Close_Tog = False
  152.       Cursor = Cursors.Arrow
  153.     End If
  154.     If New Rectangle(Me.Width - 40, 13, 16, 16).Contains(e.X, e.Y) Then
  155.       Max_Tog = True
  156.       Cursor = Cursors.Hand
  157.     Else
  158.       Max_Tog = False
  159.       Cursor = Cursors.Arrow
  160.     End If
  161.     If New Rectangle(Me.Width - 60, 13, 16, 16).Contains(e.X, e.Y) Then
  162.       Min_Tog = True
  163.       Cursor = Cursors.Hand
  164.     Else
  165.       Min_Tog = False
  166.       Cursor = Cursors.Arrow
  167.     End If
  168.     If isDragging Then
  169.       Dim screenPoint As Point = PointToScreen(e.Location)
  170.  
  171.       FindForm().Location = New Point(screenPoint.X - Me.savePoint.X, screenPoint.Y - Me.savePoint.Y)
  172.     End If
  173.     MyBase.OnMouseMove(e)
  174.     Invalidate()
  175.   End Sub
  176.  
  177. #End Region
  178. End Class
Advertisement
Add Comment
Please, Sign In to add comment