Advertisement
iJorgePc

VBColdTheme

Jun 29th, 2020
1,691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 36.84 KB | None | 0 0
  1. '<------------------>
  2. 'Author: Seukaiwokeo & JordanBelford
  3. 'Created: 12.12.2017
  4. 'Updated: 15.09.2018
  5. 'Description: Cold Hack D3D9 Menu UI
  6. 'Version: v3
  7. '<------------------>
  8.  
  9. Imports System.Drawing
  10. Imports System.Drawing.Drawing2D
  11. Imports System.Runtime.InteropServices
  12. Imports System.IO
  13. Imports System.Reflection
  14. Imports System.ComponentModel
  15. Imports System.Drawing.Text
  16.  
  17. Public Enum MouseState As Byte
  18.     None = 0
  19.     Hover = 1
  20.     Down = 2
  21.     Block = 3
  22. End Enum
  23. Module Functions
  24.     Function CenterText(Text As String, Font As Font, Width As Integer, Height As Integer) As Point
  25.         Dim W As Integer = (Width / 2) - (TextRenderer.MeasureText(Text, Font).Width / 2)
  26.         Dim H As Integer = (Height / 2) - (TextRenderer.MeasureText(Text, Font).Height / 2)
  27.         Dim P As New Point(W, H)
  28.         Return P
  29.     End Function
  30.     Function LeftText(Text As String, Font As Font, Width As Integer, Height As Integer) As Point
  31.         Dim W As Integer = 3
  32.         Dim H As Integer = (Height / 2) - (TextRenderer.MeasureText(Text, Font).Height / 2)
  33.         Dim P As New Point(W, H - 2)
  34.         Return P
  35.     End Function
  36.     Function DrawGradient(Width As Integer, Height As Integer, Optional State As MouseState = MouseState.None) As LinearGradientBrush
  37.         Dim myBrush As LinearGradientBrush
  38.         If State = MouseState.None Then
  39.             myBrush = New LinearGradientBrush(New Point(0, Height), New Point(Width, Height), Color.FromArgb(255, 202, 18), Color.FromArgb(210, 160, 39))
  40.         ElseIf State = MouseState.Hover Then
  41.             myBrush = New LinearGradientBrush(New Point(0, Height), New Point(Width, Height), Color.FromArgb(220, 255, 202, 18), Color.FromArgb(220, 210, 160, 39))
  42.         ElseIf State = MouseState.Down Then
  43.             myBrush = New LinearGradientBrush(New Point(0, Height), New Point(Width, Height), Color.FromArgb(210, 160, 39), Color.FromArgb(255, 202, 18))
  44.         Else
  45.             myBrush = New LinearGradientBrush(New Point(0, Height), New Point(Width, Height), Color.FromArgb(255, 202, 18), Color.FromArgb(210, 160, 39))
  46.         End If
  47.         myBrush.RotateTransform(90)
  48.         Return myBrush
  49.     End Function
  50. End Module
  51. Class ColdForm
  52.     Inherits ContainerControl
  53.     Dim Down As Boolean = False
  54.     Dim MoveHeight As Integer = 30
  55.     Dim MousePoint As New Point(0, 0)
  56.  
  57.     Protected Overrides Sub OnCreateControl()
  58.         ParentForm.FormBorderStyle = FormBorderStyle.None
  59.         ParentForm.AllowTransparency = True
  60.         ParentForm.TransparencyKey = Color.Fuchsia
  61.         Dock = DockStyle.Fill
  62.         Invalidate()
  63.     End Sub
  64. #Region "MouseStates"
  65.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  66.         MyBase.OnMouseDown(e)
  67.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  68.             Down = True
  69.             MousePoint = e.Location
  70.         End If
  71.     End Sub
  72.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  73.         MyBase.OnMouseUp(e)
  74.         Down = False
  75.     End Sub
  76.     Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs)
  77.         MyBase.OnMouseMove(e)
  78.         If Down Then
  79.             Parent.Location = MousePosition - MousePoint
  80.         End If
  81.     End Sub
  82. #End Region
  83.     Public mFont As New Font("Segoe UI", 10)
  84.     Sub New()
  85.         Me.Font = mFont
  86.     End Sub
  87.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  88.         MyBase.OnPaint(e)
  89.         Using g = e.Graphics
  90.             'Form Background and Topbar
  91.             g.Clear(Color.White)
  92.             g.FillRectangle(DrawGradient(50, Height), New Rectangle(New Point(0, 0), New Size(Width, 25)))
  93.             g.FillRectangle(New SolidBrush(Color.FromArgb(218, 218, 218)), New Rectangle(0, 25, Width, Height - 25))
  94.             g.DrawString(Me.Text, mFont, New SolidBrush(Color.FromArgb(0, 0, 0)), LeftText(Me.Text, mFont, Width, MoveHeight))
  95.             'Border
  96.             g.DrawLine(Pens.Black, New Point(Width, 25), New Point(0, 25)) 'Topbar bottom
  97.             g.DrawLine(Pens.Black, New Point(Width, 0), New Point(0, 0)) 'Form Top
  98.             g.DrawLine(Pens.Black, New Point(0, Height), New Point(0, 0)) 'Form Left
  99.             g.DrawLine(Pens.Black, New Point(Width - 1, 0), New Point(Width - 1, Height)) 'Form Right
  100.             g.DrawLine(Pens.Black, New Point(Width, Height - 1), New Point(0, Height - 1)) 'Form Bottom
  101.         End Using
  102.     End Sub
  103.     Protected Overrides Sub OnSizeChanged(e As System.EventArgs)
  104.         MyBase.OnSizeChanged(e)
  105.         MyBase.Refresh()
  106.     End Sub
  107.     Protected Overrides Sub OnEnter(e As System.EventArgs)
  108.         MyBase.OnLocationChanged(e)
  109.     End Sub
  110. End Class
  111. #Region " RoundRectangle "
  112.  
  113. Module RoundRectangle
  114.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  115.         Dim P As GraphicsPath = New GraphicsPath()
  116.         Dim ArcRectangleWidth As Integer = Curve * 2
  117.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  118.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  119.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  120.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  121.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  122.         Return P
  123.     End Function
  124.     Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
  125.         Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  126.         Dim P As GraphicsPath = New GraphicsPath()
  127.         Dim ArcRectangleWidth As Integer = Curve * 2
  128.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  129.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  130.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  131.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  132.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  133.         Return P
  134.     End Function
  135.     Public Function RoundedTopRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  136.         Dim P As GraphicsPath = New GraphicsPath()
  137.         Dim ArcRectangleWidth As Integer = Curve * 2
  138.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  139.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  140.         P.AddLine(New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 1))
  141.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - 1 + Rectangle.Y), New Point(Rectangle.X, Rectangle.Y + Curve))
  142.         Return P
  143.     End Function
  144. End Module
  145.  
  146. #End Region
  147. #Region " TrackBar "
  148.  
  149. <DefaultEvent("ValueChanged")> Class ColdTrackBar
  150.     Inherits Control
  151.  
  152. #Region " Enums "
  153.  
  154.     Enum ValueDivisor
  155.         By1 = 1
  156.         By10 = 10
  157.         By100 = 100
  158.         By1000 = 1000
  159.     End Enum
  160.  
  161. #End Region
  162. #Region " Variables "
  163.  
  164.     Private PipeBorder, FillValue As GraphicsPath
  165.     Private TrackBarHandleRect As Rectangle
  166.     Private Cap As Boolean
  167.     Private ValueDrawer As Integer
  168.  
  169.     Private ThumbSize As Size = New Size(15, 15)
  170.     Private TrackThumb As Rectangle
  171.  
  172.     Private _Minimum As Integer = 0
  173.     Private _Maximum As Integer = 10
  174.     Private _Value As Integer = 0
  175.  
  176.     Private _DrawValueString As Boolean = False
  177.     Private _JumpToMouse As Boolean = False
  178.     Private DividedValue As ValueDivisor = ValueDivisor.By1
  179.  
  180. #End Region
  181. #Region " Properties "
  182.  
  183.     Public Property Minimum() As Integer
  184.         Get
  185.             Return _Minimum
  186.         End Get
  187.         Set(ByVal value As Integer)
  188.  
  189.             If value >= _Maximum Then value = _Maximum - 10
  190.             If _Value < value Then _Value = value
  191.  
  192.             _Minimum = value
  193.             Invalidate()
  194.         End Set
  195.     End Property
  196.  
  197.     Public Property Maximum() As Integer
  198.         Get
  199.             Return _Maximum
  200.         End Get
  201.         Set(ByVal value As Integer)
  202.  
  203.             If value <= _Minimum Then value = _Minimum + 10
  204.             If _Value > value Then _Value = value
  205.  
  206.             _Maximum = value
  207.             Invalidate()
  208.         End Set
  209.     End Property
  210.  
  211.     Event ValueChanged()
  212.     Public Property Value() As Integer
  213.         Get
  214.             Return _Value
  215.         End Get
  216.         Set(ByVal value As Integer)
  217.             If _Value <> value Then
  218.                 If value < _Minimum Then
  219.                     _Value = _Minimum
  220.                 Else
  221.                     If value > _Maximum Then
  222.                         _Value = _Maximum
  223.                     Else
  224.                         _Value = value
  225.                     End If
  226.                 End If
  227.                 Invalidate()
  228.                 RaiseEvent ValueChanged()
  229.             End If
  230.         End Set
  231.     End Property
  232.  
  233.     Public Property ValueDivison() As ValueDivisor
  234.         Get
  235.             Return DividedValue
  236.         End Get
  237.         Set(ByVal Value As ValueDivisor)
  238.             DividedValue = Value
  239.             Invalidate()
  240.         End Set
  241.     End Property
  242.  
  243.     <Browsable(False)> Public Property ValueToSet() As Single
  244.         Get
  245.             Return CSng(_Value / DividedValue)
  246.         End Get
  247.         Set(ByVal Val As Single)
  248.             Value = CInt(Val * DividedValue)
  249.         End Set
  250.     End Property
  251.  
  252.     Public Property JumpToMouse() As Boolean
  253.         Get
  254.             Return _JumpToMouse
  255.         End Get
  256.         Set(ByVal value As Boolean)
  257.             _JumpToMouse = value
  258.             Invalidate()
  259.         End Set
  260.     End Property
  261.  
  262.     Property DrawValueString() As Boolean
  263.         Get
  264.             Return _DrawValueString
  265.         End Get
  266.         Set(ByVal value As Boolean)
  267.             _DrawValueString = value
  268.             If _DrawValueString = True Then
  269.                 Height = 35
  270.             Else
  271.                 Height = 22
  272.             End If
  273.             Invalidate()
  274.         End Set
  275.     End Property
  276.  
  277. #End Region
  278. #Region " EventArgs "
  279.  
  280.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  281.         MyBase.OnMouseMove(e)
  282.         If Cap = True AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
  283.             Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  284.         End If
  285.     End Sub
  286.  
  287.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  288.         MyBase.OnMouseDown(e)
  289.         If e.Button = Windows.Forms.MouseButtons.Left Then
  290.             ValueDrawer = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  291.             TrackBarHandleRect = New Rectangle(ValueDrawer, 0, 25, 25)
  292.             Cap = TrackBarHandleRect.Contains(e.Location)
  293.             Focus()
  294.             If _JumpToMouse Then
  295.                 Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  296.             End If
  297.         End If
  298.     End Sub
  299.  
  300.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  301.         MyBase.OnMouseUp(e)
  302.         Cap = False
  303.     End Sub
  304.  
  305. #End Region
  306.  
  307.     Sub New()
  308.         SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  309.          ControlStyles.UserPaint Or _
  310.          ControlStyles.ResizeRedraw Or _
  311.          ControlStyles.DoubleBuffer, True)
  312.         Size = New Size(80, 22)
  313.         MinimumSize = New Size(47, 22)
  314.     End Sub
  315.  
  316.     Protected Overrides Sub OnResize(e As EventArgs)
  317.         MyBase.OnResize(e)
  318.         If _DrawValueString = True Then
  319.             Height = 35
  320.         Else
  321.             Height = 22
  322.         End If
  323.     End Sub
  324.  
  325.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  326.         MyBase.OnPaint(e)
  327.         Dim G As Graphics = e.Graphics
  328.  
  329.         G.Clear(Color.FromArgb(218, 218, 218))
  330.         G.SmoothingMode = SmoothingMode.AntiAlias
  331.         TrackThumb = New Rectangle(8, 8, Width - 11, 2)
  332.         PipeBorder = RoundRectangle.RoundRect(1, 8, Width - 3, 1, 1)
  333.  
  334.         Try
  335.             ValueDrawer = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  336.         Catch ex As Exception
  337.         End Try
  338.  
  339.         TrackBarHandleRect = New Rectangle(ValueDrawer, 0, 10, 20)
  340.  
  341.         G.SetClip(PipeBorder)
  342.         G.FillPath(New SolidBrush(Color.FromArgb(221, 221, 221)), PipeBorder)
  343.         FillValue = RoundRectangle.RoundRect(0, 8, TrackBarHandleRect.X + TrackBarHandleRect.Width - 3, 2, 1)
  344.  
  345.         G.ResetClip()
  346.  
  347.         G.SmoothingMode = SmoothingMode.HighQuality
  348.         G.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), PipeBorder)
  349.         ' G.FillPath(Brushes.DarkGray, FillValue)
  350.  
  351.         G.DrawRectangle(Pens.Black, TrackThumb.X + CInt(TrackThumb.Width * (Value / Maximum)) - CInt(ThumbSize.Width / 2), TrackThumb.Y + CInt((TrackThumb.Height / 2)) - CInt(ThumbSize.Height / 2), ThumbSize.Width - 6, ThumbSize.Height)
  352.         G.FillRectangle(DrawGradient(ThumbSize.Width, ThumbSize.Height), TrackThumb.X + CInt(TrackThumb.Width * (Value / Maximum)) - CInt(ThumbSize.Width / 2), TrackThumb.Y + CInt((TrackThumb.Height / 2)) - CInt(ThumbSize.Height / 2), ThumbSize.Width - 6, ThumbSize.Height)
  353.  
  354.         If _DrawValueString = True Then
  355.             G.DrawString(ValueToSet, Font, Brushes.DimGray, 1, 20)
  356.         End If
  357.     End Sub
  358. End Class
  359.  
  360. #End Region
  361. Class ColdListBox
  362.     Inherits ListBox
  363.     Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
  364.         Dim p As GraphicsPath = New GraphicsPath()
  365.         Dim arcRectangleWidth As Integer = curve * 1
  366.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  367.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  368.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  369.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  370.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  371.         Return p
  372.     End Function
  373.     Public Function RoundRect(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal curve As Integer) As GraphicsPath
  374.         Dim rectangle As Rectangle = New Rectangle(x, y, width, height)
  375.         Dim p As GraphicsPath = New GraphicsPath()
  376.         Dim arcRectangleWidth As Integer = curve * 1
  377.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  378.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  379.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  380.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  381.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  382.         Return p
  383.     End Function
  384.     Private mFont As New Font("Segoe UI", 8)
  385.     Protected Overrides Sub OnCreateControl()
  386.         Dock = DockStyle.None
  387.         Invalidate()
  388.     End Sub
  389.     Sub New()
  390.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  391.                  ControlStyles.SupportsTransparentBackColor, True)
  392.         DoubleBuffered = True
  393.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  394.         BackColor = Color.FromArgb(246, 246, 246)
  395.         Width = 200
  396.         Height = 200
  397.         Me.Font = mFont
  398.         Me.ForeColor = Color.Black
  399.         Me.ItemHeight = 20
  400.         Me.BorderStyle = Windows.Forms.BorderStyle.FixedSingle
  401.         Me.ScrollAlwaysVisible = False
  402.         Me.HorizontalScrollbar = False
  403.         Me.IntegralHeight = False
  404.     End Sub
  405.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  406.         Using g = e.Graphics
  407.             g.SmoothingMode = SmoothingMode.HighQuality
  408.             g.PixelOffsetMode = PixelOffsetMode.HighQuality
  409.             g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  410.             g.Clear(Color.FromArgb(246, 246, 246))
  411.             g.DrawLine(Pens.Black, New Point(0, 0), New Point(Me.Width, 0))
  412.             g.DrawLine(Pens.Black, New Point(0, Me.Height), New Point(0, 0))
  413.             g.DrawLine(Pens.Black, New Point(Width + 1, 0), New Point(Width + 1, Me.Height))
  414.             g.DrawLine(Pens.Black, New Point(0, Me.Height + 1), New Point(Me.Width, Me.Height + 1))
  415.             g.Dispose()
  416.         End Using
  417.         MyBase.OnPaint(e)
  418.         e.Dispose()
  419.         e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
  420.     End Sub
  421.     Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  422.         Using g = e.Graphics
  423.             e.DrawBackground()
  424.             e.DrawFocusRectangle()
  425.             g.SmoothingMode = SmoothingMode.HighQuality
  426.             g.PixelOffsetMode = PixelOffsetMode.HighQuality
  427.             g.InterpolationMode = InterpolationMode.HighQualityBicubic
  428.             g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  429.             g.FillRectangle(New SolidBrush(BackColor), New Rectangle(e.Bounds.X, e.Bounds.Y - 1, e.Bounds.Width, e.Bounds.Height + 3))
  430.             If e.State.ToString().Contains("Selected,") Then
  431.                 Dim selectgb As New SolidBrush(Color.FromArgb(217, 219, 218))
  432.                 g.FillRectangle(selectgb, New Rectangle(e.Bounds.X, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height))
  433.                 g.DrawRectangle(New Pen(Color.FromArgb(212, 212, 212)), New Rectangle(e.Bounds.X, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height))
  434.             Else
  435.                 Dim nonselectgb As New SolidBrush(Color.FromArgb(246, 246, 246))
  436.                 g.FillRectangle(nonselectgb, e.Bounds)
  437.             End If
  438.             Try
  439.                 g.DrawString(Items(e.Index).ToString(), mFont, New SolidBrush(Color.FromArgb(0, 0, 0)), New Rectangle(e.Bounds.X + 3, e.Bounds.Y + 5, e.Bounds.Width, e.Bounds.Height), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near, .FormatFlags = StringFormatFlags.FitBlackBox})
  440.             Catch : End Try
  441.  
  442.             g.Dispose()
  443.         End Using
  444.     End Sub
  445. End Class
  446. Class ColdButton
  447.     Inherits Control
  448.     Dim Down As Boolean = False
  449.     Dim MoveHeight As Integer = 30
  450.     Dim MousePoint As New Point(0, 0)
  451. #Region "MouseStates"
  452.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  453.         isMousePress = True
  454.         Me.Refresh()
  455.     End Sub
  456.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  457.         isMousePress = False
  458.         Me.Refresh()
  459.     End Sub
  460. #End Region
  461.     Protected Overrides Sub OnCreateControl()
  462.         Dock = DockStyle.None
  463.         Invalidate()
  464.     End Sub
  465.     Private mFont As New Font("Segoe UI", 10)
  466.     Sub New()
  467.         BackColor = Color.FromArgb(51, 51, 51)
  468.         Width = 100
  469.         Height = 30
  470.         Me.Font = mFont
  471.     End Sub
  472.     Dim isMouseEnter As Boolean = False
  473.     Dim isMousePress As Boolean = False
  474.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  475.         Using g = e.Graphics
  476.             g.Clear(Color.White)
  477.             If Not isMouseEnter And Not isMousePress Then
  478.                 g.FillRectangle(DrawGradient(Me.Height, Me.Width), New Rectangle(New Point(0, 0), New Size(Me.Width, Me.Height)))
  479.             ElseIf isMousePress Then
  480.                 g.FillRectangle(DrawGradient(Me.Height, Me.Width, MouseState.Down), New Rectangle(New Point(0, 0), New Size(Me.Width, Me.Height)))
  481.             Else
  482.                 g.FillRectangle(DrawGradient(Me.Height, Me.Width, MouseState.Hover), New Rectangle(New Point(0, 0), New Size(Me.Width, Me.Height)))
  483.             End If
  484.             g.DrawLine(Pens.Black, New Point(0, 0), New Point(Me.Width, 0)) 'Top
  485.             g.DrawLine(Pens.Black, New Point(0, Me.Height), New Point(0, 0)) 'Left
  486.             g.DrawLine(Pens.Black, New Point(Width - 1, 0), New Point(Width - 1, Me.Height)) 'Right
  487.             g.DrawLine(Pens.Black, New Point(0, Me.Height - 1), New Point(Me.Width, Me.Height - 1)) 'Bottom
  488.             g.DrawString(Me.Text, Me.Font, Brushes.Black, New Point(CenterText(Me.Text, Me.Font, Me.Width, Me.Height)))
  489.         End Using
  490.     End Sub
  491.     Protected Overrides Sub OnMouseEnter(e As System.EventArgs)
  492.         isMouseEnter = True
  493.         MyBase.OnMouseEnter(e)
  494.         Me.Refresh()
  495.     End Sub
  496.     Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
  497.         isMouseEnter = False
  498.         isMousePress = False
  499.         MyBase.OnMouseEnter(e)
  500.         Me.Refresh()
  501.     End Sub
  502.     Protected Overrides Sub OnSizeChanged(e As System.EventArgs)
  503.         MyBase.OnSizeChanged(e)
  504.         MyBase.Refresh()
  505.     End Sub
  506. End Class
  507. Class ColdTabControl
  508.     Inherits TabControl
  509.     Sub New()
  510.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or _
  511.                  ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  512.         ItemSize = New Size(0, 30)
  513.         Font = New Font("Segoe UI", 8)
  514.     End Sub
  515.     Protected Overrides Sub CreateHandle()
  516.         MyBase.CreateHandle()
  517.         Alignment = TabAlignment.Top
  518.     End Sub
  519.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  520.         Dim G As Graphics = e.Graphics
  521.         Dim borderPen As New Pen(Color.FromArgb(0, 0, 0))
  522.         G.SmoothingMode = SmoothingMode.HighQuality
  523.         G.Clear(Color.FromArgb(218, 218, 218))
  524.         Dim fillRect As New Rectangle(2, ItemSize.Height + 2, Width - 6, Height - ItemSize.Height - 3)
  525.         G.FillRectangle(New SolidBrush(Color.FromArgb(218, 218, 218)), fillRect)
  526.         G.DrawRectangle(borderPen, fillRect)
  527.         Dim FontColor As New Color
  528.         For i = 0 To TabCount - 1
  529.             Dim mainRect As Rectangle = GetTabRect(i)
  530.             mainRect.Height = mainRect.Height - 6
  531.             mainRect.Width = mainRect.Width - 5
  532.             If i = SelectedIndex Then
  533.                 G.FillRectangle(DrawGradient(mainRect.Height + 5, 0), mainRect)
  534.                 G.DrawRectangle(borderPen, mainRect)
  535.                 FontColor = Color.FromArgb(0, 0, 0)
  536.             Else
  537.                 G.FillRectangle(New SolidBrush(Color.FromArgb(218, 218, 218)), mainRect)
  538.                 G.DrawRectangle(borderPen, mainRect)
  539.                 FontColor = Color.FromArgb(0, 0, 0)
  540.             End If
  541.             Dim titleX As Integer = (mainRect.Location.X + mainRect.Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2)
  542.             Dim titleY As Integer = (mainRect.Location.Y + mainRect.Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2)
  543.             G.DrawString(TabPages(i).Text, Font, New SolidBrush(FontColor), New Point(titleX, titleY))
  544.             Try : TabPages(i).BackColor = Color.FromArgb(218, 218, 218) : Catch : End Try
  545.         Next
  546.     End Sub
  547. End Class
  548. <DefaultEvent("CheckedChanged")> Class ColdCheckBox
  549.     Inherits Control
  550.     Event CheckedChanged(ByVal sender As Object)
  551.     Private _checked As Boolean
  552.     Public Property Checked() As Boolean
  553.         Get
  554.             Return _checked
  555.         End Get
  556.         Set(ByVal value As Boolean)
  557.             _checked = value
  558.             Invalidate()
  559.         End Set
  560.     End Property
  561.     Sub New()
  562.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  563.                  ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  564.         Size = New Size(140, 20)
  565.         Font = New Font("Segoe UI", 8)
  566.     End Sub
  567.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  568.         'Variable
  569.         Dim G As Graphics = e.Graphics
  570.         G.SmoothingMode = SmoothingMode.HighQuality
  571.         G.Clear(Parent.BackColor)
  572.         'Shape and Colors
  573.         Dim box As New Rectangle(0, 0, Height, Height - 1)
  574.         G.FillRectangle(DrawGradient(box.Height + 5, 0), box)
  575.         G.DrawRectangle(New Pen(Color.FromArgb(218, 218, 218)), box)
  576.         box.Width = 15
  577.         box.Height = 15
  578.         'Border
  579.         G.DrawLine(Pens.Black, New Point(0, 0), New Point(box.Width, 0)) 'Top
  580.         G.DrawLine(Pens.Black, New Point(0, 0), New Point(0, box.Height)) 'Left
  581.         G.DrawLine(Pens.Black, New Point(box.Width, 0), New Point(box.Width, box.Height)) 'Right
  582.         G.DrawLine(Pens.Black, New Point(0, box.Height), New Point(box.Width, box.Height)) 'Bottom
  583.         'Inside
  584.         Dim markPen As New Pen(Color.FromArgb(218, 218, 218))
  585.         Dim lightMarkPen As New Pen(Color.FromArgb(0, 0, 0))
  586.         If _checked Then G.DrawString("a", New Font("Marlett", 13), Brushes.Black, New Point(-3, -1.2))
  587.         'Text
  588.         Dim textY As Integer = (Height / 2) - (G.MeasureString(Text, Font).Height / 2)
  589.         G.DrawString(Text, Font, Brushes.Black, New Point(24, textY + 1))
  590.         Me.Size = New Size(28 + G.MeasureString(Text, Font).Width, 16)
  591.     End Sub
  592.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  593.         MyBase.OnMouseDown(e)
  594.         If e.Button = Windows.Forms.MouseButtons.Left Then
  595.             If _checked Then
  596.                 _checked = False
  597.             Else
  598.                 _checked = True
  599.             End If
  600.             RaiseEvent CheckedChanged(Me)
  601.             Invalidate()
  602.         End If
  603.     End Sub
  604. End Class
  605. Class ColdComboBox
  606.     Inherits ComboBox
  607.  
  608.     Sub New()
  609.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  610.                  ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or _
  611.                  ControlStyles.SupportsTransparentBackColor, True)
  612.         Font = New Font("Segoe UI", 7)
  613.  
  614.     End Sub
  615.     Protected Overrides Sub CreateHandle()
  616.         MyBase.CreateHandle()
  617.  
  618.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  619.         DropDownStyle = ComboBoxStyle.DropDownList
  620.         DoubleBuffered = True
  621.         ItemHeight = 20
  622.  
  623.     End Sub
  624.  
  625.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  626.         MyBase.OnPaint(e)
  627.  
  628.         Dim G As Graphics = e.Graphics
  629.         G.SmoothingMode = SmoothingMode.HighQuality
  630.         G.Clear(Parent.BackColor)
  631.  
  632.         Dim mainRect As New Rectangle(0, 0, Width - 1, Height - 1)
  633.         G.FillRectangle(New SolidBrush(Color.FromArgb(246, 246, 246)), mainRect)
  634.         G.DrawRectangle(New Pen(Color.FromArgb(246, 246, 246)), mainRect)
  635.  
  636.         Dim triangle As Point() = New Point() {New Point(Width - 14, 16), New Point(Width - 18, 10), New Point(Width - 10, 10)}
  637.         G.FillPolygon(Brushes.Black, triangle)
  638.         'Border
  639.         G.DrawLine(Pens.Black, New Point(0, 0), New Point(Width, 0)) 'Top
  640.         G.DrawLine(Pens.Black, New Point(0, 0), New Point(0, Height)) 'Left
  641.         G.DrawLine(Pens.Black, New Point(Width - 25, 0), New Point(Width - 25, Height)) 'Left
  642.         G.DrawLine(Pens.Black, New Point(Width - 1, 0), New Point(Width - 1, Height)) 'Right
  643.         G.DrawLine(Pens.Black, New Point(0, Height - 1), New Point(Width, Height - 1)) 'Top
  644.         Try
  645.             If Items.Count > 0 Then
  646.                 If Not SelectedIndex = -1 Then
  647.                     Dim textX As Integer = 6
  648.                     Dim textY As Integer = ((Me.Height - 1) / 2) - (G.MeasureString(Items(SelectedIndex), Font).Height / 2) + 1
  649.                     G.DrawString(Items(SelectedIndex), Font, Brushes.Black, New Point(textX, textY))
  650.                 Else
  651.                     Dim textX As Integer = 6
  652.                     Dim textY As Integer = ((Me.Height - 1) / 2) - (G.MeasureString(Items(0), Font).Height / 2) + 1
  653.                     G.DrawString(Items(0), Font, Brushes.Black, New Point(textX, textY))
  654.                 End If
  655.             End If
  656.         Catch : End Try
  657.  
  658.     End Sub
  659.  
  660.     Sub replaceItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  661.         e.DrawBackground()
  662.  
  663.         Dim G As Graphics = e.Graphics
  664.         G.SmoothingMode = SmoothingMode.HighQuality
  665.  
  666.         Dim rect As New Rectangle(e.Bounds.X - 1, e.Bounds.Y - 1, e.Bounds.Width + 1, e.Bounds.Height + 1)
  667.  
  668.         Try
  669.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  670.                 G.FillRectangle(New SolidBrush(Color.FromArgb(245, 246, 246, 246)), rect)
  671.                 G.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), Font, Brushes.Black, New Rectangle(e.Bounds.X + 6, e.Bounds.Y + 3, e.Bounds.Width, e.Bounds.Height))
  672.                 G.DrawRectangle(New Pen(Color.FromArgb(20, 160, 230)), rect)
  673.             Else
  674.                 G.FillRectangle(New SolidBrush(Color.FromArgb(246, 246, 246)), rect)
  675.                 G.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), Font, Brushes.Black, New Rectangle(e.Bounds.X + 6, e.Bounds.Y + 3, e.Bounds.Width, e.Bounds.Height))
  676.                 G.DrawRectangle(New Pen(Color.FromArgb(246, 246, 246)), rect)
  677.             End If
  678.  
  679.         Catch : End Try
  680.  
  681.     End Sub
  682.  
  683.     Protected Overrides Sub OnSelectedItemChanged(ByVal e As System.EventArgs)
  684.         MyBase.OnSelectedItemChanged(e)
  685.         Invalidate()
  686.     End Sub
  687. End Class
  688. <DefaultEvent("CheckedChanged")> Class ColdRadioButton
  689.     Inherits Control
  690.     Event CheckedChanged(ByVal sender As Object)
  691.     Private _checked As Boolean
  692.     Public Property Checked() As Boolean
  693.         Get
  694.             Return _checked
  695.         End Get
  696.         Set(ByVal value As Boolean)
  697.             _checked = value
  698.             Invalidate()
  699.         End Set
  700.     End Property
  701.     Sub New()
  702.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  703.                  ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  704.         Size = New Size(140, 20)
  705.         Font = New Font("Segoe UI", 8)
  706.     End Sub
  707.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  708.         Dim G As Graphics = e.Graphics
  709.         G.SmoothingMode = SmoothingMode.HighQuality
  710.         G.Clear(Parent.BackColor)
  711.         Dim box As New Rectangle(0, 0, Height - 5, Height - 5)
  712.         G.FillEllipse(New SolidBrush(Color.FromArgb(235, 235, 235)), box)
  713.         G.DrawEllipse(New Pen(Color.FromArgb(0, 0, 0)), box)
  714.         If _checked Then
  715.             Dim innerMark As New Rectangle(1, 1, Height - 7, Height - 7)
  716.             G.FillEllipse(DrawGradient(20, 5, MouseState.None), innerMark)
  717.         End If
  718.         Dim textY As Integer = (Height / 2) - (G.MeasureString(Text, Font).Height / 2)
  719.         G.DrawString(Text, Font, Brushes.Black, New Point(20, textY - 1))
  720.         Me.Size = New Size(26 + G.MeasureString(Text, Font).Width, 18)
  721.     End Sub
  722.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  723.         MyBase.OnMouseDown(e)
  724.         If e.Button = Windows.Forms.MouseButtons.Left Then
  725.             For Each C As Control In Parent.Controls
  726.                 If C IsNot Me AndAlso TypeOf C Is ColdRadioButton Then
  727.                     DirectCast(C, ColdRadioButton).Checked = False
  728.                 End If
  729.             Next
  730.             If Not _checked Then
  731.                 _checked = True
  732.             End If
  733.             RaiseEvent CheckedChanged(Me)
  734.             Invalidate()
  735.         End If
  736.     End Sub
  737. End Class
  738. Class ColdGroupBox
  739.     Inherits GroupBox
  740.     Sub New()
  741.         BackColor = Color.FromArgb(218, 218, 218)
  742.     End Sub
  743.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  744.         MyBase.OnPaint(e)
  745.         Using g = e.Graphics
  746.             g.Clear(Color.FromArgb(218, 218, 218))
  747.             g.DrawLine(Pens.Black, New Point(0, 0), New Point(0, 0))
  748.             Dim border As New Rectangle(New Point(0, 0), New Size(Width - 1, Height - 1))
  749.             Dim topBar As New Rectangle(New Point(0, 0), New Size(Width, 25))
  750.             g.FillRectangle(DrawGradient(40, 25), topBar)
  751.             g.DrawRectangle(Pens.Black, border)
  752.             g.DrawString(Text, Font, Brushes.Black, CenterText(Text, Font, Width, 25))
  753.             g.DrawLine(Pens.Black, New Point(0, 25), New Point(Width, 25))
  754.         End Using
  755.     End Sub
  756. End Class
  757. Class ColdLabel
  758.     Inherits Control
  759.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  760.         MyBase.OnPaint(e)
  761.         Using g = e.Graphics
  762.             g.Clear(Color.FromArgb(216, 216, 216))
  763.             g.DrawString(Text, Font, Brushes.Black, New Point(0, 0))
  764.             Me.Height = g.MeasureString(Text, Font, Width).Height
  765.             Me.Width = g.MeasureString(Text, Font, Width).Width
  766.         End Using
  767.     End Sub
  768. End Class
  769. <DefaultEvent("TextChanged")> Class ColdTextBox
  770.     Inherits TextBox
  771.     Protected Overrides Sub OnCreateControl()
  772.         MyBase.OnCreateControl()
  773.     End Sub
  774.     Sub New()
  775.         BorderStyle = BorderStyle.FixedSingle
  776.         BackColor = Color.FromArgb(216, 216, 216)
  777.         Margin = New Padding(5, 0, 0, 0)
  778.         Font = New Font("Segoe UI", 8)
  779.     End Sub
  780.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  781.         Using g = e.Graphics
  782.             g.DrawLine(Pens.Black, New Point(0, 0), New Point(Me.Width, 0)) 'Top
  783.             g.DrawLine(Pens.Black, New Point(0, Me.Height), New Point(0, 0)) 'Left
  784.             g.DrawLine(Pens.Black, New Point(Width - 1, 0), New Point(Width - 1, Me.Height)) 'Right
  785.             g.DrawLine(Pens.Black, New Point(0, Me.Height - 1), New Point(Me.Width, Me.Height - 1)) 'Bottom
  786.         End Using
  787.         MyBase.OnPaint(e)
  788.     End Sub
  789. End Class
  790. Class ColdProgressBar
  791.     Inherits Control
  792.     Private _Maximum As Integer = 100
  793.     Private _ShowPercant As Boolean = True
  794.     Private _Minimum As Integer = 0
  795.     Public Property ShowPercant As Boolean
  796.         Get
  797.             Return _ShowPercant
  798.         End Get
  799.         Set(value As Boolean)
  800.             _ShowPercant = value
  801.             Invalidate()
  802.         End Set
  803.     End Property
  804.     Public Property Maximum As Integer
  805.         Get
  806.             Return _Maximum
  807.         End Get
  808.         Set(ByVal v As Integer)
  809.             If v < 1 Then v = 1
  810.             If v < _Value Then _Value = v
  811.             _Maximum = v
  812.             Invalidate()
  813.         End Set
  814.     End Property
  815.     Public Property Minimum As Integer
  816.         Get
  817.             Return _Minimum
  818.         End Get
  819.         Set(ByVal v As Integer)
  820.             If Not v > -1 Then v = 0
  821.             If v > _Maximum Then v = _Maximum - 1
  822.             _Minimum = v
  823.             Invalidate()
  824.         End Set
  825.     End Property
  826.     Private _Value As Integer
  827.     Public Property Value As Integer
  828.         Get
  829.             Return _Value
  830.         End Get
  831.         Set(ByVal v As Integer)
  832.             If v > _Maximum Then v = Maximum
  833.             _Value = v
  834.             Invalidate()
  835.         End Set
  836.     End Property
  837.     Sub New()
  838.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  839.                  ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  840.         Size = New Size(100, 24)
  841.         Maximum = 100
  842.         Minimum = 0
  843.         Text = ""
  844.         Font = New Font("Segoe UI", 8)
  845.     End Sub
  846.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  847.         MyBase.OnPaint(e)
  848.         Dim _text As String = Text
  849.         Text = ""
  850.         Dim G As Graphics = e.Graphics
  851.         G.SmoothingMode = SmoothingMode.HighQuality
  852.         G.Clear(Parent.BackColor)
  853.         Dim mainRect As New Rectangle(0, 0, Width - 1, Height - 1)
  854.         G.FillRectangle(New SolidBrush(Color.FromArgb(235, 235, 235)), mainRect)
  855.         G.DrawRectangle(Pens.Black, mainRect)
  856.         Dim barRect As New Rectangle(0, 0, CInt(((Width / _Maximum) * _Value) - 1), Height - 1)
  857.         G.FillRectangle(DrawGradient(Height, CInt(((Width / _Maximum) * _Value) - 1)), barRect)
  858.         Dim percent As Single = (_Value / _Maximum) * 100
  859.         Dim txt As String = Text & " " & CStr(percent) & "%"
  860.         If ShowPercant Then
  861.             G.DrawString(txt, Font, Brushes.Black, LeftText(Text, Font, Width, Height / 2 - 1))
  862.         Else
  863.             G.DrawString(_text, Font, Brushes.Black, CenterText(Text, Font, Width, Height / 2 - 3))
  864.         End If
  865.         Text = _text
  866.     End Sub
  867. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement