Advertisement
Guest User

Untitled

a guest
May 21st, 2014
1,237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2.  
  3. '
  4. '
  5. 'Created By Marvinn (HF)
  6. 'Need Any help feel free to mail/pm me (marvinzwolsman@hotmail.com)
  7. 'Please give propper credits!
  8. '11/5/2011 22:30 (Dutch/Netherlands)
  9. '
  10. '
  11. Public Class CypherxButton
  12.     Inherits Control
  13.  
  14.     Sub New()
  15.         Font = New Font("Arial", 8)
  16.         ForeColor = Color.White
  17.     End Sub
  18.  
  19.     Private Enum State
  20.         MouseDown
  21.         MouseEnter
  22.         MouseLeft
  23.     End Enum
  24.  
  25.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  26.         MouseState = State.MouseLeft
  27.         Invalidate()
  28.     End Sub
  29.  
  30.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  31.         MouseState = State.MouseEnter
  32.         Invalidate()
  33.     End Sub
  34.  
  35.     Protected Overrides Sub OnMouseClick(ByVal e As System.Windows.Forms.MouseEventArgs)
  36.         MouseState = State.MouseLeft
  37.         Invalidate()
  38.         MyBase.OnMouseClick(e)
  39.     End Sub
  40.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  41.         Invalidate()
  42.     End Sub
  43.  
  44.     Dim MouseState As State = State.MouseLeft
  45.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  46.         Using b As New Bitmap(Width, Height)
  47.             Using g As Graphics = Graphics.FromImage(b)
  48.                 Dim OuterR As New Rectangle(0, 0, Width - 1, Height - 1)
  49.                 Dim InnerR As New Rectangle(1, 1, Width - 3, Height - 3)
  50.                 Dim UpHalf As New Rectangle(2, 2, Width - 3, (Height - 1) / 2)
  51.                 Dim DownHalf As New Rectangle(2, (Height - 1) / 2, Width - 3, (Height - 1) / 2)
  52.  
  53.                 Select Case MouseState
  54.                     Case State.MouseLeft
  55.                         Draw.Gradient(g, Color.FromArgb(88, 79, 72), Color.FromArgb(76, 69, 61), UpHalf)
  56.                         Draw.Gradient(g, Color.FromArgb(56, 46, 36), Color.FromArgb(66, 56, 46), DownHalf)
  57.                         g.DrawRectangle(Pens.Black, OuterR)
  58.                         g.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(75, 66, 60))), InnerR)
  59.                         ForeColor = Color.White
  60.                     Case State.MouseEnter
  61.                         Draw.Gradient(g, Color.FromArgb(234, 236, 241), Color.FromArgb(215, 219, 225), UpHalf)
  62.                         Draw.Gradient(g, Color.FromArgb(189, 193, 198), Color.FromArgb(195, 198, 201), DownHalf)
  63.                         ForeColor = Color.FromArgb(23, 32, 37)
  64.                 End Select
  65.                 Dim S As SizeF = g.MeasureString(Text, Font)
  66.                 g.DrawString(Text, Font, New SolidBrush(ForeColor), CInt(Width / 2 - S.Width / 2), CInt(Height / 2 - S.Height / 2))
  67.  
  68.                 e.Graphics.DrawImage(b.Clone, 0, 0)
  69.             End Using
  70.         End Using
  71.         MyBase.OnPaint(e)
  72.     End Sub
  73.  
  74.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  75.     End Sub
  76. End Class
  77.  
  78. Public Class CypherxTheme
  79.     Inherits Control
  80.     Dim Bgimagee As Bitmap
  81.     Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  82.         Dock = DockStyle.Fill
  83.         Bgimagee = CreateBg()
  84.         If TypeOf Parent Is Form Then
  85.             With DirectCast(Parent, Form)
  86.                 .FormBorderStyle = 0
  87.                 .BackColor = Color.FromArgb(25, 18, 12)
  88.                 .ForeColor = Color.White
  89.                 .Font = New Font("Arial", 8)
  90.                 _Icon = .Icon
  91.                 .Text = Text
  92.                 DoubleBuffered = True
  93.                 .BackgroundImage = Bgimagee
  94.                 BackgroundImage = Bgimagee
  95.             End With
  96.         End If
  97.         MyBase.OnHandleCreated(e)
  98.     End Sub
  99.  
  100.     Dim Balk As New Rectangle(4, 4, Width - 8, 27)
  101.  
  102.  
  103.     Function CreateBg() As Bitmap
  104.         Using b As New Bitmap(Width, Height)
  105.             Using g As Graphics = Graphics.FromImage(b)
  106.                 Dim P1 As Color = Color.FromArgb(29, 25, 22)
  107.                 Dim P2 As Color = Color.FromArgb(35, 31, 28)
  108.  
  109.                 For y As Integer = 0 To Height Step 4
  110.                     For x As Integer = 3 To Width Step 4
  111.                         g.FillRectangle(New SolidBrush(P1), New Rectangle(x, y, 1, 1))
  112.                         g.FillRectangle(New SolidBrush(P2), New Rectangle(x, y + 1, 1, 1))
  113.                         Try
  114.                             g.FillRectangle(New SolidBrush(P1), New Rectangle(x + 2, y + 2, 1, 1))
  115.                             g.FillRectangle(New SolidBrush(P2), New Rectangle(x + 2, y + 3, 1, 1))
  116.                         Catch
  117.                         End Try
  118.                     Next
  119.                 Next
  120.                 Return b.Clone
  121.             End Using
  122.         End Using
  123.     End Function
  124.  
  125.  
  126.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  127.         Using b As New Bitmap(Width, Height)
  128.             Using g As Graphics = Graphics.FromImage(b)
  129.                 g.FillRectangle(New SolidBrush(Color.FromArgb(25, 18, 12)), New Rectangle(0, 0, Width, Height))
  130.  
  131.                 Dim P1 As Color = Color.FromArgb(29, 25, 22)
  132.                 Dim P2 As Color = Color.FromArgb(35, 31, 28)
  133.                 If Not Bgimagee.Equals(Nothing) Then
  134.                     g.DrawImage(Bgimagee, 0, 0)
  135.                 End If
  136.  
  137.                 g.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(15, 10, 5))), New Rectangle(0, 0, Width - 2, Height - 1))
  138.                 g.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(55, 45, 35))), New Rectangle(1, 1, Width - 3, Height - 3))
  139.                 g.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(75, 70, 65)), 2), New Rectangle(3, 3, Width - 6, Height - 6))
  140.  
  141.  
  142.  
  143.                 Dim BovenHelftBalk As New Rectangle(4, 4, Width - 8, CInt(27 / 2))
  144.                 Dim OnderHelftBalk As New Rectangle(4, CInt(27 / 2) + 2, Width - 8, CInt(27 / 2))
  145.  
  146.                 g.FillRectangle(New SolidBrush(Color.FromArgb(200, Color.FromArgb(75, 70, 65))), BovenHelftBalk)
  147.                 g.FillRectangle(New SolidBrush(Color.FromArgb(230, P2)), OnderHelftBalk)
  148.  
  149.                 g.DrawImage(ResizeIcon, New Rectangle(10, 10, 16, 16))
  150.  
  151.                 Dim S = g.MeasureString(Text, Font)
  152.                 g.DrawString(Text, New Font("Arial", 8, FontStyle.Bold), New SolidBrush(ForeColor), 36, 10)
  153.  
  154.                 Dim MinimizeRec As New Rectangle(Width - 32, 16, 9, 5)
  155.  
  156.                 If Minibox Then
  157.                     Select Case EnteredMinimize
  158.                         Case True
  159.                             g.FillRectangle(Brushes.White, MinimizeRec)
  160.                             g.DrawRectangle(New Pen(Color.FromArgb(255, Color.Black), 1), MinimizeRec)
  161.                         Case False
  162.                             g.FillRectangle(New SolidBrush(Color.FromArgb(100, Color.White)), MinimizeRec)
  163.                             g.DrawRectangle(New Pen(Color.FromArgb(150, Color.Black), 1), MinimizeRec)
  164.                     End Select
  165.                 End If
  166.  
  167.                 Select Case EntredClose
  168.                     Case True
  169.                         g.DrawString("x", New Font("Arial", 13, FontStyle.Bold), Brushes.White, Width - 20, 5)
  170.                     Case False
  171.                         g.DrawString("x", New Font("Arial", 13, FontStyle.Bold), New SolidBrush(Color.FromArgb(100, Color.White)), Width - 20, 5)
  172.                 End Select
  173.  
  174.  
  175.                 e.Graphics.DrawImage(b, 0, 0)
  176.             End Using
  177.         End Using
  178.         MyBase.OnPaint(e)
  179.     End Sub
  180.  
  181.     Dim EnteredMinimize As Boolean = False
  182.     Dim EntredClose As Boolean = False
  183.  
  184.     Function ResizeIcon() As Bitmap
  185.         Dim TempIcon As Icon = Icon
  186.         Dim TempBitmap As Bitmap = New Bitmap(32, 32)
  187.         Dim BitmapGraphic As Graphics = Graphics.FromImage(TempBitmap)
  188.         Dim XPos, YPos As Integer
  189.         XPos = (TempBitmap.Width - TempIcon.Width) \ 2
  190.         YPos = (TempBitmap.Height - TempIcon.Height) \ 2
  191.  
  192.         BitmapGraphic.DrawIcon(TempIcon, New Rectangle(XPos, YPos, TempIcon.Width, TempIcon.Height))
  193.         Return TempBitmap
  194.     End Function
  195.  
  196.     Dim _Icon As Icon
  197.     Public Property Icon As Icon
  198.         Get
  199.             Return _Icon
  200.         End Get
  201.         Set(ByVal value As Icon)
  202.             _Icon = value
  203.             If TypeOf Parent Is Form Then
  204.                 With DirectCast(Parent, Form)
  205.                     .Icon = value
  206.                     _Icon = value
  207.                     Invalidate()
  208.                 End With
  209.             End If
  210.         End Set
  211.     End Property
  212.  
  213.     Dim FadingOut As Boolean = True
  214.     ' <summary>
  215.    ' This boolean indicates the use of the Fade Out Effect on close
  216.    ' </summary>
  217.    Public Property UseFadeOut As Boolean
  218.         Get
  219.             Return FadingOut
  220.         End Get
  221.         Set(ByVal value As Boolean)
  222.             FadingOut = value
  223.         End Set
  224.     End Property
  225.  
  226.     Dim Minibox As Boolean = True
  227.     Public Property MinimizeBox As Boolean
  228.         Get
  229.             Return Minibox
  230.         End Get
  231.         Set(ByVal value As Boolean)
  232.             Minibox = value
  233.             Invalidate()
  234.         End Set
  235.     End Property
  236.  
  237. #Region " Global Variables "
  238.     Dim Point As New Point()
  239.     Dim X, Y As Integer
  240. #End Region
  241.  
  242. #Region " GUI "
  243.  
  244.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  245.         Dim Last As Boolean = EnteredMinimize
  246.  
  247.         Dim MinimizeRec As New Rectangle(Width - 32, 16, 9, 5)
  248.         If MinimizeRec.Contains(e.Location) Then
  249.             EnteredMinimize = True
  250.         Else
  251.             EnteredMinimize = False
  252.         End If
  253.  
  254.         If Not Last = EnteredMinimize Then
  255.             Invalidate()
  256.         End If
  257.  
  258.         Last = EntredClose
  259.  
  260.         Dim CloseRec As New Rectangle(Width - 20, 5, 16, 16)
  261.         If CloseRec.Contains(e.Location) Then
  262.             EntredClose = True
  263.         Else
  264.             EntredClose = False
  265.         End If
  266.  
  267.         If Not Last = EntredClose Then
  268.             Invalidate()
  269.         End If
  270.  
  271.         If TypeOf Parent Is Form Then
  272.             With DirectCast(Parent, Form)
  273.                 If e.Button = MouseButtons.Left And e.Location.X < Width And e.Location.Y < Balk.Height Then
  274.                     Point = Control.MousePosition
  275.                     Point.X = Point.X - (X)
  276.                     Point.Y = Point.Y - (Y)
  277.                     .Location = Point
  278.                 End If
  279.             End With
  280.         End If
  281.  
  282.         MyBase.OnMouseMove(e)
  283.     End Sub
  284.  
  285.  
  286.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  287.         If TypeOf Parent Is Form Then
  288.             With DirectCast(Parent, Form)
  289.                 X = Control.MousePosition.X - .Location.X
  290.                 Y = Control.MousePosition.Y - .Location.Y
  291.             End With
  292.         End If
  293.  
  294.         Dim MinimizeRec As New Rectangle(Width - 32, 16, 9, 5)
  295.         If MinimizeRec.Contains(e.Location) Then
  296.             If TypeOf Parent Is Form Then
  297.                 With DirectCast(Parent, Form)
  298.                     .WindowState = FormWindowState.Minimized
  299.                 End With
  300.             End If
  301.         End If
  302.  
  303.         Dim CloseRec As New Rectangle(Width - 20, 5, 16, 16)
  304.         If CloseRec.Contains(e.Location) Then
  305.             If TypeOf Parent Is Form Then
  306.                 With DirectCast(Parent, Form)
  307.                     If FadingOut Then FadeOut()
  308.                     .Close()
  309.                    
  310.                 End With
  311.             End If
  312.  
  313.         End If
  314.  
  315.         MyBase.OnMouseDown(e)
  316.     End Sub
  317. #End Region
  318.  
  319.     Function FadeOut()
  320.         If TypeOf Parent Is Form Then
  321.             With DirectCast(Parent, Form)
  322.                 For i As Double = 1 To 0.0 Step -0.1
  323.                     .Opacity = i
  324.                     Threading.Thread.Sleep(50)
  325.                 Next
  326.             End With
  327.         End If
  328.         Return True
  329.     End Function
  330.  
  331. End Class
  332.  
  333. Public Class CypherxLabel
  334.     Inherits Label
  335.     Sub New()
  336.         Font = New Font("Arial", 8)
  337.         ForeColor = Color.White
  338.         BackColor = Color.Transparent
  339.     End Sub
  340. End Class
  341.  
  342. Public Class CyperxProgressbar
  343.     Inherits Control
  344.     Sub New()
  345.         Font = New Font("Arial", 8)
  346.         ForeColor = Color.White
  347.     End Sub
  348.  
  349.     Dim _UseColor As Boolean = False
  350.     Public Property Colorize As Boolean
  351.         Get
  352.             Return _UseColor
  353.         End Get
  354.         Set(ByVal value As Boolean)
  355.             _UseColor = value
  356.             Invalidate()
  357.         End Set
  358.     End Property
  359.     Dim Perc As Double = 0
  360.     Public ReadOnly Property Percentage As Double
  361.         Get
  362.             Return Perc
  363.         End Get
  364.     End Property
  365.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  366.         Using b As New Bitmap(Width, Height)
  367.             Using g As Graphics = Graphics.FromImage(b)
  368.                 Dim WholeR As New Rectangle(0, 0, Width - 1, Height - 1)
  369.                 Draw.Gradient(g, _Lightcolor, _DarkColor, WholeR)
  370.                 g.DrawRectangle(Pens.Black, WholeR)
  371.                 Dim OneProcent As Double = Maximum / 100
  372.                 Dim ProgressProcent As Integer = _Progress / OneProcent
  373.                 Console.WriteLine(ProgressProcent)
  374.  
  375.                 Dim ProgressRec As New Rectangle(2, 2, CInt((Width - 4) * (ProgressProcent * 0.01)), Height - 4)
  376.                 Perc = _Progress / (Maximum / 100)
  377.                 Select Case _UseColor
  378.                     Case False
  379.                         g.FillRectangle(New SolidBrush(Color.FromArgb(100, Color.Black)), ProgressRec)
  380.                     Case True
  381.                         Dim Drawcolor As Color = Color.FromArgb(150, 255 - 2 * ProgressProcent, (1.7 * ProgressProcent), 0)
  382.                         g.FillRectangle(New SolidBrush(Color.FromArgb(50, Drawcolor)), ProgressRec)
  383.                 End Select
  384.  
  385.                 If Showt Then g.DrawString(Text, Font, New SolidBrush(ForeColor), New Point(3, 4))
  386.                 e.Graphics.DrawImage(b, 0, 0)
  387.             End Using
  388.         End Using
  389.     End Sub
  390.  
  391.  
  392.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  393.     End Sub
  394.  
  395. #Region " Properties "
  396.  
  397.     Dim Showt As Boolean = True
  398.     Public Property ShowText As Boolean
  399.         Get
  400.             Return Showt
  401.         End Get
  402.         Set(ByVal value As Boolean)
  403.             Showt = value
  404.             Invalidate()
  405.         End Set
  406.     End Property
  407.     Private _Maximum As Double = 100
  408.     Public Property Maximum() As Double
  409.         Get
  410.             Return _Maximum
  411.         End Get
  412.         Set(ByVal value As Double)
  413.             _Maximum = value
  414.             value = _Current / value * 100
  415.             Invalidate()
  416.         End Set
  417.     End Property
  418.  
  419.     Private _Current As Double
  420.     Public Property Current() As Double
  421.         Get
  422.             Return _Current
  423.         End Get
  424.         Set(ByVal value As Double)
  425.             _Current = value
  426.             value = value / _Maximum * 100
  427.             Invalidate()
  428.         End Set
  429.     End Property
  430.  
  431.     Private _Progress As Integer
  432.     Public Property Value() As Double
  433.         Get
  434.             Return _Progress
  435.         End Get
  436.         Set(ByVal value As Double)
  437.             If value < 0 Then value = 0 Else If value > Maximum Then value = Maximum
  438.             _Progress = CInt(value)
  439.             _Current = value * 0.01 * _Maximum
  440.             Invalidate()
  441.         End Set
  442.     End Property
  443.  
  444.     Public Property DarkColor As Color
  445.  
  446.         Get
  447.             Return _DarkColor
  448.  
  449.         End Get
  450.         Set(ByVal value As Color)
  451.             _DarkColor = value
  452.             Invalidate()
  453.         End Set
  454.     End Property
  455.  
  456.     Public Property Lightcolor() As Color
  457.         Get
  458.             Return _Lightcolor
  459.         End Get
  460.         Set(ByVal value As Color)
  461.             _Lightcolor = value
  462.             Invalidate()
  463.         End Set
  464.     End Property
  465.  
  466. #End Region
  467.  
  468. #Region " Colors "
  469.     Dim _Lightcolor As Color = Color.FromArgb(65, 55, 45)
  470.     Dim _DarkColor = Color.FromArgb(75, 70, 65)
  471. #End Region
  472.  
  473.  
  474. End Class
  475.  
  476. Public Class CyperxTextbox
  477.  
  478.     Inherits Control
  479.  
  480.     Dim Stroke As Color = Color.FromArgb(80, 71, 62)
  481.     Dim Bg As Color = Color.FromArgb(67, 60, 53)
  482.     Dim tbox As TextBox
  483.     Sub New()
  484.         Me.Text = ""
  485.         tbox = Nothing
  486.         tbox = New TextBox
  487.         tbox.Text = Text
  488.         tbox.BorderStyle = BorderStyle.None
  489.         tbox.BackColor = Color.FromArgb(25, 18, 12)
  490.         tbox.Location = New Point(3, 4)
  491.         tbox.Width = Width - 7
  492.         tbox.Font = Font
  493.         tbox.UseSystemPasswordChar = Pwbox
  494.         tbox.ForeColor = Color.White
  495.         Me.Controls.Add(tbox)
  496.         AddHandler tbox.TextChanged, Sub() TextChange()
  497.     End Sub
  498.     Dim Pwbox As Boolean = False
  499.  
  500.     Dim DrawRounded As Boolean = True
  501.     Public Property Rounded As Boolean
  502.         Get
  503.             Return DrawRounded
  504.         End Get
  505.         Set(ByVal value As Boolean)
  506.             DrawRounded = value
  507.         End Set
  508.     End Property
  509.  
  510.     Public Property UseSystemPasswordChar As Boolean
  511.         Get
  512.             Return Pwbox
  513.         End Get
  514.         Set(ByVal value As Boolean)
  515.             Pwbox = value
  516.             tbox = Nothing
  517.             tbox = New TextBox
  518.             tbox.Text = Text
  519.             tbox.BorderStyle = BorderStyle.None
  520.             tbox.BackColor = Color.FromArgb(25, 18, 12)
  521.             tbox.Location = New Point(3, 4)
  522.             tbox.Width = Width - 7
  523.             tbox.Font = Font
  524.             tbox.UseSystemPasswordChar = Pwbox
  525.             tbox.ForeColor = Color.White
  526.             Me.Controls.Add(tbox)
  527.             AddHandler tbox.TextChanged, Sub() TextChange()
  528.         End Set
  529.     End Property
  530.  
  531.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  532.         tbox = New TextBox
  533.         tbox.Text = Text
  534.         tbox.BorderStyle = BorderStyle.None
  535.         tbox.BackColor = Color.FromArgb(25, 18, 12)
  536.         tbox.Location = New Point(3, 4)
  537.         tbox.Width = Width - 7
  538.         tbox.Font = Font
  539.         tbox.UseSystemPasswordChar = Pwbox
  540.         tbox.ForeColor = Color.White
  541.         Me.Controls.Add(tbox)
  542.         AddHandler tbox.TextChanged, Sub() TextChange()
  543.         MyBase.OnHandleCreated(e)
  544.     End Sub
  545.  
  546.     Private Sub TextChange()
  547.         Me.Text = tbox.Text
  548.     End Sub
  549.  
  550.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  551.         Using b As New Bitmap(Width, Height)
  552.             Using g As Graphics = Graphics.FromImage(b)
  553.                 g.DrawRectangle(New Pen(Color.FromArgb(25, 18, 12)), New Rectangle(0, 0, Width, Height))
  554.                 If DrawRounded Then
  555.                     Dim Outline As GraphicsPath = Draw.RoundedRectangle(0, 0, Width - 1, Height - 1, 10, 1)
  556.                     g.DrawPath(New Pen(Stroke), Outline)
  557.                 Else
  558.                     Dim rec As New Rectangle(0, 0, Width - 1, Height - 1)
  559.                     g.FillRectangle(New SolidBrush(Color.FromArgb(25, 18, 12)), rec)
  560.                     g.DrawRectangle(New Pen(Stroke), rec)
  561.                 End If
  562.                 e.Graphics.DrawImage(b, 0, 0)
  563.             End Using
  564.         End Using
  565.         MyBase.OnPaint(e)
  566.     End Sub
  567. End Class
  568.  
  569. Public Class CypherxGroupBox
  570.     Inherits Panel
  571.     Dim Stroke As Color = Color.FromArgb(80, 71, 62)
  572.     Sub New()
  573.         BackColor = Color.Transparent
  574.     End Sub
  575.     Dim _t As String = ""
  576.     Public Property Header As String
  577.         Get
  578.             Return _t
  579.         End Get
  580.         Set(ByVal value As String)
  581.             _t = value
  582.             Invalidate()
  583.         End Set
  584.     End Property
  585.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  586.         Using b As New Bitmap(Width, Height)
  587.             Using g As Graphics = Graphics.FromImage(b)
  588.                 Dim M As SizeF = g.MeasureString(_t, font)
  589.                 Dim Outline As GraphicsPath = Draw.RoundedRectangle(0, M.Height / 2, Width - 1, Height - 1, 10, 1)
  590.                 g.Clear(BackColor)
  591.                 g.FillRectangle(New SolidBrush(Color.FromArgb(25, 18, 12)), New Rectangle(0, M.Height / 2, Width - 1, Height - 1))
  592.                 g.DrawPath(New Pen(Stroke), Outline)
  593.  
  594.                 g.FillRectangle(New SolidBrush(Color.FromArgb(25, 18, 12)), New Rectangle(10, (M.Height / 2) - 2, M.Width + 10, M.Height))
  595.                 g.DrawString(_t, Font, New SolidBrush(Stroke), 12, 2)
  596.                 e.Graphics.DrawImage(b, 0, 0)
  597.             End Using
  598.         End Using
  599.         MyBase.OnPaint(e)
  600.     End Sub
  601. End Class
  602.  
  603. Public Class CyperxSeperator
  604.     Inherits Control
  605.     Sub New()
  606.         If TypeOf Parent Is CypherxTheme Then
  607.             With DirectCast(Parent, CypherxTheme)
  608.                 BackgroundImage = .BackgroundImage
  609.             End With
  610.         End If
  611.     End Sub
  612.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  613.     End Sub
  614.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  615.         Using b As New Bitmap(Width, Height)
  616.             Using g As Graphics = Graphics.FromImage(b)
  617.                 g.Clear(BackColor)
  618.  
  619.                 Dim P1 As Color = Color.FromArgb(29, 25, 22)
  620.                 Dim P2 As Color = Color.FromArgb(80, 71, 62)
  621.                 g.FillRectangle(New SolidBrush(Color.FromArgb(25, 18, 12)), New Rectangle(0, 0, Width, Height))
  622.                 If D Then Draw.BackGround(Width, Height, g)
  623.  
  624.                 Dim GRec As New Rectangle(0, Height / 2, Width / 5, 2)
  625.                 Using GBrush As LinearGradientBrush = New LinearGradientBrush(grec, Color.Transparent, P2, LinearGradientMode.Horizontal)
  626.                     g.FillRectangle(GBrush, GRec)
  627.                 End Using
  628.                 g.DrawLine(New Pen(P2, 2), New Point(GRec.Width, GRec.Y + 1), New Point(Width - GRec.Width + 1, GRec.Y + 1))
  629.  
  630.                 GRec = New Rectangle(Width - (Width / 5), Height / 2, Width / 5, 2)
  631.                 Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, P2, Color.Transparent, LinearGradientMode.Horizontal)
  632.                     g.FillRectangle(GBrush, GRec)
  633.                 End Using
  634.                 e.Graphics.DrawImage(b, 0, 0)
  635.             End Using
  636.         End Using
  637.         MyBase.OnPaint(e)
  638.     End Sub
  639.  
  640.     Dim D As Boolean = True
  641.     Public Property DrawPatern As Boolean
  642.         Get
  643.             Return D
  644.         End Get
  645.         Set(ByVal value As Boolean)
  646.             D = value
  647.             Invalidate()
  648.         End Set
  649.     End Property
  650. End Class
  651.  
  652. Public Class CyperxComboBox
  653.     Inherits Control
  654.  
  655.     Sub New()
  656.         Font = New Font("Arial", 8)
  657.         ForeColor = Color.White
  658.         MinimumSize = New Size(130, 23)
  659.  
  660.     End Sub
  661.  
  662.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  663.         If _Items.Length < 0 Then _Items = New String() {Text}
  664.         MyBase.OnHandleCreated(e)
  665.     End Sub
  666.     Private Enum State
  667.         MouseDown = 0
  668.         MouseEnter = 1
  669.         MouseLeft = 2
  670.         Wait = 3
  671.     End Enum
  672.  
  673.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  674.         If Not MouseState = State.Wait Then
  675.             MouseState = State.MouseLeft
  676.             Invalidate()
  677.         End If
  678.     End Sub
  679.  
  680.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  681.         If Not MouseState = State.Wait Then
  682.             MouseState = State.MouseEnter
  683.             Invalidate()
  684.         End If
  685.     End Sub
  686.  
  687.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  688.         If Not MouseState = State.Wait Then
  689.             MouseState = State.MouseEnter
  690.             Invalidate()
  691.         End If
  692.     End Sub
  693.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  694.  
  695.  
  696.         MouseState = State.Wait
  697.         Dim ShowPopup As New Threading.Thread(AddressOf ShowAndWait)
  698.         ShowPopup.Start()
  699.  
  700.         Invalidate()
  701.  
  702.         MyBase.OnMouseDown(e)
  703.     End Sub
  704.  
  705.     Sub ShowAndWait()
  706.         Dim pop As New Popup(_Items)
  707.         pop.Location = New Point(Location.X, Location.Y + Height + 2)
  708.  
  709.         Invoke(New AddX(AddressOf AddControl), pop)
  710.  
  711.  
  712.         pop.WaitForInput()
  713.  
  714.         MouseState = State.MouseLeft
  715.         If Not pop.SelectedItem = "" Then
  716.             Invoke(New UpdateTextD(AddressOf UpdateText), pop.SelectedItem)
  717.         Else
  718.             Invoke(New UpdateTextD(AddressOf UpdateText), Text)
  719.         End If
  720.  
  721.  
  722.     End Sub
  723.  
  724.     Delegate Sub UpdateTextD(ByVal text As String)
  725.     Sub UpdateText(ByVal text As String)
  726.         Me.Text = text
  727.         Invalidate()
  728.     End Sub
  729.  
  730.     Delegate Sub AddX(ByVal control As Control)
  731.     Sub AddControl(ByVal control As Control)
  732.         Parent.Controls.Add(control)
  733.     End Sub
  734.     Dim _Items() As String
  735.     Public Property Items As String()
  736.         Get
  737.             Return _Items
  738.         End Get
  739.         Set(ByVal value As String())
  740.             _Items = value
  741.             Text = value(0)
  742.             Invalidate()
  743.         End Set
  744.     End Property
  745.     Dim MouseState As State = State.MouseLeft
  746.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  747.         Using b As New Bitmap(Width, Height)
  748.             Using g As Graphics = Graphics.FromImage(b)
  749.                 Dim OuterR As New Rectangle(0, 0, Width - 1, Height - 1)
  750.                 Dim InnerR As New Rectangle(1, 1, Width - 3, Height - 3)
  751.                 Dim UpHalf As New Rectangle(2, 2, Width - 3, (Height - 1) / 2)
  752.                 Dim DownHalf As New Rectangle(2, (Height - 1) / 2, Width - 3, (Height - 1) / 2)
  753.  
  754.                 Select Case MouseState
  755.                     Case State.MouseLeft
  756.                         Draw.Gradient(g, Color.FromArgb(88, 79, 72), Color.FromArgb(76, 69, 61), UpHalf)
  757.                         Draw.Gradient(g, Color.FromArgb(56, 46, 36), Color.FromArgb(66, 56, 46), DownHalf)
  758.                         g.DrawRectangle(Pens.Black, OuterR)
  759.                         g.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(75, 66, 60))), InnerR)
  760.                         ForeColor = Color.White
  761.                     Case State.MouseEnter
  762.                         ForeColor = Color.FromArgb(23, 32, 37)
  763.                         Draw.Gradient(g, Color.FromArgb(234, 236, 241), Color.FromArgb(215, 219, 225), UpHalf)
  764.                         Draw.Gradient(g, Color.FromArgb(189, 193, 198), Color.FromArgb(195, 198, 201), DownHalf)
  765.                     Case State.Wait
  766.                         ForeColor = Color.FromArgb(23, 32, 37)
  767.                         Draw.Gradient(g, Color.FromArgb(234, 236, 241), Color.FromArgb(215, 219, 225), UpHalf)
  768.                         Draw.Gradient(g, Color.FromArgb(189, 193, 198), Color.FromArgb(195, 198, 201), DownHalf)
  769.                 End Select
  770.  
  771.  
  772.                 Dim UpRec As New Rectangle(Width - 18, 2, 1, 5)
  773.                 Draw.Gradient(g, Color.Transparent, Color.FromArgb(25, 18, 12), UpRec)
  774.                 g.DrawLine(New Pen(Color.FromArgb(28, 18, 12), 1), New Point(Width - 18, 7), New Point(Width - 18, Height - 7))
  775.                 Draw.Gradient(g, Color.FromArgb(28, 18, 12), Color.Transparent, New Rectangle(Width - 18, Height - 7, 1, 5))
  776.  
  777.                 g.DrawLine(New Pen(Brushes.White, 2), New Point(Width - 15, 9), New Point(Width - 10, 14))
  778.                 g.DrawLine(New Pen(Brushes.White, 2), New Point(Width - 5, 9), New Point(Width - 10, 14))
  779.  
  780.                 Dim S As SizeF = g.MeasureString(Text, Font)
  781.                 g.DrawString(Text, Font, New SolidBrush(ForeColor), 5, CInt(Height / 2 - S.Height / 2))
  782.  
  783.                 e.Graphics.DrawImage(b.Clone, 0, 0)
  784.             End Using
  785.         End Using
  786.         MyBase.OnPaint(e)
  787.     End Sub
  788.  
  789.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  790.     End Sub
  791. End Class
  792.  
  793. Public Class Popup
  794.     Inherits Control
  795.     Dim _items() As String
  796.     Dim ListOfRec As New List(Of Rectangle)
  797.  
  798.     Sub New(ByVal items As String())
  799.         DoubleBuffered = True
  800.         _items = items
  801.         FixWidth()
  802.         FixList()
  803.  
  804.     End Sub
  805.     Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  806.         Console.WriteLine(TopLevelControl.TopLevelControl)
  807.         BringToFront()
  808.         MyBase.OnHandleCreated(e)
  809.     End Sub
  810.     Dim MyMousedown As Boolean = False
  811.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  812.         MyMousedown = True
  813.         Invalidate()
  814.         _item = Temp_item
  815.         Console.WriteLine("Item: " & SelectedItem)
  816.         Input = True
  817.         Me.Hide()
  818.         MyBase.OnMouseDown(e)
  819.     End Sub
  820.  
  821.     Sub FixWidth()
  822.         Dim G As Graphics = Graphics.FromImage(New Bitmap(1, 1))
  823.         Dim LongestWidth As Integer = 0
  824.         For Each Str As String In _items
  825.             If G.MeasureString(Str, Font).Width > LongestWidth Then
  826.                 LongestWidth = G.MeasureString(Str, Font).Width
  827.             End If
  828.         Next
  829.  
  830.         If LongestWidth < 85 Then
  831.             Width = 95
  832.         Else
  833.             Me.Width = LongestWidth + 9
  834.         End If
  835.  
  836.     End Sub
  837.     Sub FixList()
  838.         Dim MyHeight = 23 * _items.Length - 1
  839.         Dim AantalRecs As Integer = MyHeight / 23
  840.         ListOfRec.Add(New Rectangle(2, 3, Width - 5, 23))
  841.         For i As Integer = 1 To AantalRecs
  842.             Dim rec As New Rectangle(2, 23 * i, Width - 5, 23)
  843.             ListOfRec.Add(rec)
  844.         Next
  845.  
  846.         Me.Height = MyHeight + 5
  847.         Invalidate()
  848.     End Sub
  849.     Dim SelectedReg As New Rectangle(0, 0, 0, 0)
  850.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  851.         Dim Oldrec As Rectangle = SelectedReg
  852.         For Each rec As Rectangle In ListOfRec
  853.             If rec.Contains(e.Location) Then
  854.                 SelectedReg = rec
  855.             End If
  856.         Next
  857.         If Not Oldrec = SelectedReg Then
  858.             Invalidate()
  859.         End If
  860.         MyBase.OnMouseMove(e)
  861.     End Sub
  862.  
  863.     Dim Input As Boolean = False
  864.     Public Sub WaitForInput()
  865.         Do While Input = False
  866.             Threading.Thread.Sleep(1)
  867.         Loop
  868.     End Sub
  869.  
  870.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  871.         SelectedReg = New Rectangle(0, 0, 0, 0)
  872.         Me.Visible = False
  873.         Input = True
  874.         MyBase.OnMouseLeave(e)
  875.     End Sub
  876.  
  877.     Dim _item As String = ""
  878.     Public Property SelectedItem As String
  879.         Get
  880.             Return _item
  881.         End Get
  882.         Set(ByVal value As String)
  883.             _item = value
  884.         End Set
  885.     End Property
  886.  
  887.     Dim Temp_item As String = ""
  888.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  889.         Using b As New Bitmap(Width, Height)
  890.             Using g As Graphics = Graphics.FromImage(b)
  891.  
  892.                 Dim Fullrec As New Rectangle(0, 0, Width - 1, Height - 1)
  893.                 g.FillRectangle(New SolidBrush(Color.FromArgb(20, 13, 6)), Fullrec)
  894.                 g.DrawRectangle(New Pen(Color.FromArgb(16, 11, 5)), Fullrec)
  895.                 g.FillRectangle(New SolidBrush(Color.FromArgb(177, 177, 179)), SelectedReg)
  896.                 g.DrawRectangle(New Pen(Color.FromArgb(51, 51, 50)), SelectedReg)
  897.  
  898.                 If SelectedReg.Contains(New Point(5, 5)) Then
  899.                     g.DrawString(_items(0), Font, New SolidBrush(Color.FromArgb(20, 13, 6)), 5, 6)
  900.                     Console.WriteLine("Selected item " & _items(0))
  901.                     Temp_item = _items(0)
  902.                 Else
  903.                     g.DrawString(_items(0), Font, Brushes.White, 5, 6)
  904.                 End If
  905.  
  906.  
  907.                 For I As Integer = 1 To _items.Length - 1
  908.                     If SelectedReg.Contains(New Point(5, I * 23 + 5)) Then
  909.                         g.DrawString(_items(I), Font, New SolidBrush(Color.FromArgb(20, 13, 6)), 5, I * 23 + 5)
  910.                         Console.WriteLine("Selected item: " & _items(I))
  911.                         Temp_item = _items(I)
  912.                     Else
  913.                         g.DrawString(_items(I), Font, Brushes.White, 5, I * 23 + 5)
  914.                     End If
  915.                 Next
  916.                 e.Graphics.DrawImage(b, 0, 0)
  917.             End Using
  918.         End Using
  919.         MyBase.OnPaint(e)
  920.     End Sub
  921.  
  922. End Class
  923.  
  924.  
  925. '
  926. '
  927. 'Created By Aeonhack
  928. '
  929. '
  930. Public Class Draw
  931.     Shared Sub Gradient(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  932.         Dim R As New Rectangle(x, y, width, height)
  933.         Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
  934.             g.FillRectangle(T, R)
  935.         End Using
  936.     End Sub
  937.     Shared Sub Gradient(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  938.         Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
  939.             g.FillRectangle(T, R)
  940.         End Using
  941.     End Sub
  942.     Shared Sub Blend(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal c3 As Color, ByVal c As Single, ByVal d As Integer, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  943.         Dim v As New ColorBlend(3)
  944.         V.Colors = New Color() {c1, c2, c3}
  945.         V.Positions = New Single() {0, c, 1}
  946.         Dim R As New Rectangle(x, y, width, height)
  947.         Using T As New LinearGradientBrush(R, c1, c1, CType(d, LinearGradientMode))
  948.             T.InterpolationColors = v : g.FillRectangle(T, R)
  949.         End Using
  950.     End Sub
  951.     Shared Function RoundedRectangle(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cornerwidth As Integer, ByVal PenWidth As Integer) As GraphicsPath
  952.         Dim p As New GraphicsPath
  953.         p.StartFigure()
  954.         p.AddArc(New Rectangle(x, y, cornerwidth, cornerwidth), 180, 90)
  955.         p.AddLine(cornerwidth, y, width - cornerwidth - PenWidth, y)
  956.  
  957.         p.AddArc(New Rectangle(width - cornerwidth - PenWidth, y, cornerwidth, cornerwidth), -90, 90)
  958.         p.AddLine(width - PenWidth, cornerwidth, width - PenWidth, height - cornerwidth - PenWidth)
  959.  
  960.         p.AddArc(New Rectangle(width - cornerwidth - PenWidth, height - cornerwidth - PenWidth, cornerwidth, cornerwidth), 0, 90)
  961.         p.AddLine(width - cornerwidth - PenWidth, height - PenWidth, cornerwidth, height - PenWidth)
  962.  
  963.         p.AddArc(New Rectangle(x, height - cornerwidth - PenWidth, cornerwidth, cornerwidth), 90, 90)
  964.         p.CloseFigure()
  965.  
  966.         Return p
  967.     End Function
  968.  
  969.     Shared Sub BackGround(ByVal width As Integer, ByVal height As Integer, ByVal G As Graphics)
  970.  
  971.         Dim P1 As Color = Color.FromArgb(29, 25, 22)
  972.         Dim P2 As Color = Color.FromArgb(35, 31, 28)
  973.  
  974.         For y As Integer = 0 To height Step 4
  975.             For x As Integer = 0 To width Step 4
  976.                 G.FillRectangle(New SolidBrush(P1), New Rectangle(x, y, 1, 1))
  977.                 G.FillRectangle(New SolidBrush(P2), New Rectangle(x, y + 1, 1, 1))
  978.                 Try
  979.                     G.FillRectangle(New SolidBrush(P1), New Rectangle(x + 2, y + 2, 1, 1))
  980.                     G.FillRectangle(New SolidBrush(P2), New Rectangle(x + 2, y + 3, 1, 1))
  981.                 Catch
  982.                 End Try
  983.             Next
  984.         Next
  985.     End Sub
  986. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement