Advertisement
benito

Untitled

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