Advertisement
Guest User

Kingwood theme

a guest
Dec 18th, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 15.57 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2.  
  3. 'Made by AeroRev9.
  4. 'HackForums.
  5.  
  6. Module Base
  7.  
  8.     Public UI As Color = Color.FromArgb(251, 98, 100)
  9.     Public UIFont As New Font("Segoe UI", 10)
  10.  
  11.     Public Enum MouseState As Byte
  12.         None
  13.         Hover
  14.         Down
  15.     End Enum
  16.  
  17.     Public Sub RoundRect(ByVal G As Graphics, _
  18.                               ByVal X As Integer, _
  19.                               ByVal Y As Integer, _
  20.                               ByVal Width As Integer, _
  21.                               ByVal Height As Integer, _
  22.                               ByVal Curve As Integer, _
  23.                               ByVal Draw As Color)
  24.  
  25.  
  26.         Dim BaseRect As New RectangleF(X, Y, Width,
  27.                                       Height)
  28.         Dim ArcRect As New RectangleF(BaseRect.Location,
  29.                                   New SizeF(Curve, Curve))
  30.  
  31.         G.DrawArc(New Pen(Draw), ArcRect, 180, 90)
  32.         G.DrawLine(New Pen(Draw), X + CInt(Curve / 2),
  33.                              Y,
  34.                              Y + Width - CInt(Curve / 2),
  35.                              Y)
  36.  
  37.         ArcRect.X = BaseRect.Right - Curve
  38.         G.DrawArc(New Pen(Draw), ArcRect, 270, 90)
  39.         G.DrawLine(New Pen(Draw), X + Width,
  40.                              Y + CInt(Curve / 2),
  41.                              X + Width,
  42.                              Y + Height - CInt(Curve / 2))
  43.  
  44.         ArcRect.Y = BaseRect.Bottom - Curve
  45.         G.DrawArc(New Pen(Draw), ArcRect, 0, 90)
  46.         G.DrawLine(New Pen(Draw), X + CInt(Curve / 2),
  47.                              Y + Height,
  48.                              X + Width - CInt(Curve / 2),
  49.                              Y + Height)
  50.  
  51.         ArcRect.X = BaseRect.Left
  52.         G.DrawArc(New Pen(Draw), ArcRect, 90, 90)
  53.         G.DrawLine(New Pen(Draw),
  54.                              X, Y + CInt(Curve / 2),
  55.                              X,
  56.                              Y + Height - CInt(Curve / 2))
  57.  
  58.     End Sub
  59.  
  60.     Public Sub CenterString(G As Graphics, text As String, font As Font, brush As Brush, rect As Rectangle, Optional shadow As Boolean = False, Optional yOffset As Integer = 0)
  61.  
  62.         Dim textSize As SizeF = G.MeasureString(text, font)
  63.         Dim textX As Integer = rect.X + (rect.Width / 2) - (textSize.Width / 2)
  64.         Dim textY As Integer = rect.Y + (rect.Height / 2) - (textSize.Height / 2) + yOffset
  65.  
  66.         If shadow Then G.DrawString(text, font, Brushes.Black, textX + 1, textY + 1)
  67.         G.DrawString(text, font, brush, textX, textY + 1)
  68.  
  69.     End Sub
  70.  
  71.     Public Sub DrawTriangle(G As Graphics, Rect As Rectangle, Draw As Color)
  72.         Dim halfWidth As Integer = Rect.Width / 2
  73.         Dim halfHeight As Integer = Rect.Height / 2
  74.         Dim p0 As Point = Point.Empty
  75.         Dim p1 As Point = Point.Empty
  76.         Dim p2 As Point = Point.Empty
  77.  
  78.  
  79.         p0 = New Point(Rect.Left + halfWidth, Rect.Bottom)
  80.         p1 = New Point(Rect.Left, Rect.Top)
  81.         p2 = New Point(Rect.Right, Rect.Top)
  82.  
  83.         G.FillPolygon(New SolidBrush(Draw), New Point() {p0, p1, p2})
  84.     End Sub
  85.  
  86. End Module
  87.  
  88. Class KingwoodForm
  89.     Inherits ContainerControl
  90.  
  91.     Sub New()
  92.         BackColor = Color.FromArgb(227, 227, 227)
  93.         Dock = DockStyle.Fill
  94.         Font = New Font("Segoe UI", 10)
  95.     End Sub
  96.  
  97. End Class
  98.  
  99. Class KingwoodButton
  100.     Inherits Button
  101.  
  102.     Private State As MouseState
  103.  
  104.     Protected Overrides Sub OnCreateControl()
  105.         MyBase.OnCreateControl()
  106.         SetStyle(ControlStyles.UserPaint, True)
  107.     End Sub
  108.  
  109.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  110.  
  111.         Dim G As Graphics = e.Graphics
  112.         G.SmoothingMode = SmoothingMode.HighQuality
  113.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
  114.  
  115.         MyBase.OnPaint(e)
  116.  
  117.         G.Clear(Color.FromArgb(227, 227, 227))
  118.  
  119.         Select Case State
  120.  
  121.             Case MouseState.Down
  122.                 G.FillRectangle(New SolidBrush(Color.FromArgb(240, 87, 89)), New Rectangle(1, 1, Width - 2, Height - 2))
  123.                 RoundRect(G, 0, 0, Width - 1, Height - 1, 2, Color.FromArgb(240, 87, 89))
  124.             Case MouseState.Hover
  125.                 G.FillRectangle(New SolidBrush(Color.FromArgb(255, 102, 104)), New Rectangle(1, 1, Width - 2, Height - 2))
  126.                 RoundRect(G, 0, 0, Width - 1, Height - 1, 2, Color.FromArgb(255, 102, 104))
  127.             Case Else
  128.                 G.FillRectangle(New SolidBrush(UI), New Rectangle(1, 1, Width - 2, Height - 2))
  129.                 RoundRect(G, 0, 0, Width - 1, Height - 1, 2, UI)
  130.         End Select
  131.  
  132.         CenterString(G, Text, UIFont, Brushes.White, New Rectangle(0, 0, Width, Height))
  133.  
  134.     End Sub
  135.  
  136.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  137.         MyBase.OnMouseEnter(e)
  138.         State = MouseState.Hover : Invalidate()
  139.     End Sub
  140.  
  141.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  142.         MyBase.OnMouseLeave(e)
  143.         State = MouseState.None : Invalidate()
  144.     End Sub
  145.  
  146.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  147.         MyBase.OnMouseDown(e)
  148.         State = MouseState.Down : Invalidate()
  149.     End Sub
  150.  
  151.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  152.         MyBase.OnMouseUp(e)
  153.         State = MouseState.Hover : Invalidate()
  154.     End Sub
  155.  
  156. End Class
  157.  
  158. Class KingwoodCheckBox
  159.     Inherits Control
  160.  
  161.     Event CheckedChanged(sender As Object)
  162.  
  163.     Private _Checked As Boolean
  164.     Public Property Checked As Boolean
  165.         Get
  166.             Return _Checked
  167.         End Get
  168.         Set(value As Boolean)
  169.             _Checked = value
  170.             Invalidate()
  171.         End Set
  172.     End Property
  173.  
  174.     Protected Overrides Sub OnResize(e As EventArgs)
  175.         MyBase.OnResize(e)
  176.         Size = New Point(Width, 17)
  177.     End Sub
  178.  
  179.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  180.  
  181.         Dim G As Graphics = e.Graphics
  182.         G.SmoothingMode = SmoothingMode.HighQuality
  183.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  184.  
  185.         MyBase.OnPaint(e)
  186.  
  187.         G.DrawString(Text, UIFont, New SolidBrush(Color.FromArgb(110, 110, 110)), New Point(22, -1))
  188.         G.DrawRectangle(New Pen(Color.FromArgb(170, 170, 170)), New Rectangle(0, 0, 15, 15))
  189.  
  190.         If Checked Then
  191.             G.FillRectangle(New SolidBrush(UI), New Rectangle(3, 3, 10, 10))
  192.             RoundRect(G, 2, 2, 11, 11, 3, UI)
  193.         End If
  194.  
  195.     End Sub
  196.  
  197.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  198.         MyBase.OnMouseUp(e)
  199.  
  200.         If Checked Then
  201.             Checked = False
  202.         Else
  203.             Checked = True
  204.         End If
  205.  
  206.     End Sub
  207.  
  208. End Class
  209.  
  210. Class KingwoodRadioButton
  211.     Inherits Control
  212.  
  213.     Event CheckedChanged(sender As Object)
  214.  
  215.     Private _Checked As Boolean
  216.     Public Property Checked As Boolean
  217.         Get
  218.             Return _Checked
  219.         End Get
  220.         Set(value As Boolean)
  221.             _Checked = value
  222.             Invalidate()
  223.         End Set
  224.     End Property
  225.  
  226.     Protected Overrides Sub OnResize(e As EventArgs)
  227.         MyBase.OnResize(e)
  228.         Size = New Point(Width, 17)
  229.     End Sub
  230.  
  231.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  232.  
  233.         Dim G As Graphics = e.Graphics
  234.         G.SmoothingMode = SmoothingMode.HighQuality
  235.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  236.  
  237.         MyBase.OnPaint(e)
  238.  
  239.         G.DrawString(Text, UIFont, New SolidBrush(Color.FromArgb(110, 110, 110)), New Point(22, -1))
  240.         G.DrawEllipse(New Pen(Color.FromArgb(170, 170, 170)), New Rectangle(0, 0, 15, 15))
  241.  
  242.         If Checked Then
  243.             G.FillEllipse(New SolidBrush(UI), New Rectangle(2, 2, 11, 11))
  244.         End If
  245.  
  246.     End Sub
  247.  
  248.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  249.         MyBase.OnMouseUp(e)
  250.  
  251.         If Checked Then
  252.             Checked = False
  253.         Else
  254.             Checked = True
  255.         End If
  256.  
  257.     End Sub
  258.  
  259. End Class
  260.  
  261. Class KingwoodGroupBox
  262.     Inherits GroupBox
  263.  
  264.     Protected Overrides Sub OnCreateControl()
  265.         MyBase.OnCreateControl()
  266.         SetStyle(ControlStyles.UserPaint, True)
  267.     End Sub
  268.  
  269.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  270.  
  271.         Dim G As Graphics = e.Graphics
  272.         G.SmoothingMode = SmoothingMode.HighQuality
  273.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
  274.  
  275.         MyBase.OnPaint(e)
  276.  
  277.         G.Clear(Color.FromArgb(227, 227, 227))
  278.  
  279.         G.DrawRectangle(New Pen(Color.FromArgb(210, 210, 210)), New Rectangle(0, 0, Width - 1, Height - 1))
  280.  
  281.         G.FillRectangle(New SolidBrush(Color.FromArgb(62, 71, 86)), New Rectangle(0, 0, Width, 30))
  282.         CenterString(G, Text, UIFont, Brushes.White, New Rectangle(0, 0, Width, 30))
  283.  
  284.     End Sub
  285.  
  286. End Class
  287.  
  288. Class KingwoodProgressBar
  289.     Inherits Control
  290.  
  291.     Private _Maximum As Integer
  292.     Public Property Maximum As Integer
  293.         Get
  294.             Return _Maximum
  295.         End Get
  296.         Set(value As Integer)
  297.             _Maximum = value
  298.             Invalidate()
  299.         End Set
  300.     End Property
  301.  
  302.     Private _Minimum As Integer
  303.     Public Property Minimum As Integer
  304.         Get
  305.             Return _Minimum
  306.         End Get
  307.         Set(value As Integer)
  308.             _Minimum = value
  309.             Invalidate()
  310.         End Set
  311.     End Property
  312.  
  313.     Private _Value As Integer
  314.     Public Property Value As Integer
  315.         Get
  316.             Return _Value
  317.         End Get
  318.         Set(value As Integer)
  319.             _Value = value
  320.             Invalidate()
  321.         End Set
  322.     End Property
  323.  
  324.     Sub New()
  325.         Maximum = 100
  326.         Minimum = 0
  327.         Value = 0
  328.     End Sub
  329.  
  330.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  331.  
  332.         Dim G As Graphics = e.Graphics
  333.         G.SmoothingMode = SmoothingMode.HighQuality
  334.  
  335.         MyBase.OnPaint(e)
  336.  
  337.         G.DrawRectangle(New Pen(Color.FromArgb(210, 210, 210)), New Rectangle(0, 0, Width - 1, Height - 1))
  338.  
  339.         Select Case _Value
  340.             Case Is > 2
  341.                 G.FillRectangle(New SolidBrush(UI), New Rectangle(0, 0, CInt(Value / Maximum * Width), Height))
  342.             Case Is > 0
  343.                 G.FillRectangle(New SolidBrush(UI), New Rectangle(0, 0, CInt(Value / Maximum * Width), Height))
  344.         End Select
  345.  
  346.     End Sub
  347.  
  348. End Class
  349.  
  350. Class KingwoodMessage
  351.     Inherits TextBox
  352.  
  353.     Protected Overrides Sub OnCreateControl()
  354.         MyBase.OnCreateControl()
  355.         SetStyle(ControlStyles.UserPaint, True)
  356.         Enabled = False
  357.         Multiline = True
  358.         BorderStyle = Windows.Forms.BorderStyle.None
  359.     End Sub
  360.  
  361.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  362.  
  363.         Dim G As Graphics = e.Graphics
  364.         G.SmoothingMode = SmoothingMode.HighQuality
  365.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  366.  
  367.         MyBase.OnPaint(e)
  368.  
  369.         G.Clear(Color.FromArgb(227, 227, 227))
  370.  
  371.         G.FillRectangle(New SolidBrush(Color.FromArgb(250, 245, 216)), New Rectangle(1, 1, Width - 2, Height - 2))
  372.         RoundRect(G, 0, 0, Width - 1, Height - 1, 3, Color.FromArgb(225, 220, 191))
  373.  
  374.         G.DrawString(Text, UIFont, New SolidBrush(Color.FromArgb(110, 110, 110)), New Point(12, 8))
  375.  
  376.     End Sub
  377.  
  378.  
  379. End Class
  380.  
  381. Class KingwoodTextBox
  382.     Inherits Control
  383.  
  384.     Dim WithEvents _tb As New TextBox
  385.     Private State As MouseState
  386.  
  387. #Region "Properties"
  388.  
  389.     Private _allowpassword As Boolean = False
  390.     Public Shadows Property UseSystemPasswordChar() As Boolean
  391.         Get
  392.             Return _allowpassword
  393.         End Get
  394.         Set(ByVal value As Boolean)
  395.             _tb.UseSystemPasswordChar = UseSystemPasswordChar
  396.             _allowpassword = value
  397.             Invalidate()
  398.         End Set
  399.     End Property
  400.  
  401.     Private _maxChars As Integer = 32767
  402.     Public Shadows Property MaxLength() As Integer
  403.         Get
  404.             Return _maxChars
  405.         End Get
  406.         Set(ByVal value As Integer)
  407.             _maxChars = value
  408.             _tb.MaxLength = MaxLength
  409.             Invalidate()
  410.         End Set
  411.     End Property
  412.  
  413.     Private _textAlignment As HorizontalAlignment
  414.     Public Shadows Property TextAlign() As HorizontalAlignment
  415.         Get
  416.             Return _textAlignment
  417.         End Get
  418.         Set(ByVal value As HorizontalAlignment)
  419.             _textAlignment = value
  420.             Invalidate()
  421.         End Set
  422.     End Property
  423.  
  424.     Private _multiLine As Boolean = False
  425.     Public Shadows Property MultiLine() As Boolean
  426.         Get
  427.             Return _multiLine
  428.         End Get
  429.         Set(ByVal value As Boolean)
  430.             _multiLine = value
  431.             _tb.Multiline = value
  432.             OnResize(EventArgs.Empty)
  433.             Invalidate()
  434.         End Set
  435.     End Property
  436.  
  437.     Private _readOnly As Boolean = False
  438.     Public Shadows Property [ReadOnly]() As Boolean
  439.         Get
  440.             Return _readOnly
  441.         End Get
  442.         Set(ByVal value As Boolean)
  443.             _readOnly = value
  444.             If _tb IsNot Nothing Then
  445.                 _tb.ReadOnly = value
  446.             End If
  447.         End Set
  448.     End Property
  449.  
  450.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  451.         MyBase.OnTextChanged(e)
  452.  
  453.         Invalidate()
  454.  
  455.     End Sub
  456.  
  457.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  458.         MyBase.OnGotFocus(e)
  459.         _tb.Focus()
  460.     End Sub
  461.  
  462.     Private Sub TextChangeTb() Handles _tb.TextChanged
  463.         Text = _tb.Text
  464.     End Sub
  465.  
  466.     Private Sub TextChng() Handles MyBase.TextChanged
  467.         _tb.Text = Text
  468.     End Sub
  469.  
  470. #End Region
  471.  
  472.     Public Sub NewTextBox()
  473.         With _tb
  474.             .Text = String.Empty
  475.             .BackColor = Color.FromArgb(227, 227, 227)
  476.             .ForeColor = Color.FromArgb(130, 130, 130)
  477.             .TextAlign = HorizontalAlignment.Left
  478.             .BorderStyle = BorderStyle.None
  479.             .Font = UIFont
  480.             .Size = New Size(Width - 3, Height - 3)
  481.             .UseSystemPasswordChar = UseSystemPasswordChar
  482.         End With
  483.     End Sub
  484.  
  485.     Sub New()
  486.         MyBase.New()
  487.         NewTextBox()
  488.         Controls.Add(_tb)
  489.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  490.         DoubleBuffered = True
  491.         TextAlign = HorizontalAlignment.Left
  492.         ForeColor = Color.FromArgb(170, 170, 170)
  493.         Font = UIFont
  494.         Size = New Size(130, 29)
  495.     End Sub
  496.  
  497.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  498.  
  499.         Dim G As Graphics = e.Graphics
  500.         G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  501.  
  502.         MyBase.OnPaint(e)
  503.  
  504.         G.Clear(Color.FromArgb(227, 227, 227))
  505.  
  506.         If State = MouseState.Down Then
  507.             RoundRect(G, 0, 0, Width - 1, Height - 1, 3, Color.FromArgb(62, 71, 86))
  508.         Else
  509.             RoundRect(G, 0, 0, Width - 1, Height - 1, 3, Color.FromArgb(210, 210, 210))
  510.         End If
  511.  
  512.         _tb.TextAlign = TextAlign
  513.         _tb.UseSystemPasswordChar = UseSystemPasswordChar
  514.  
  515.     End Sub
  516.  
  517.     Protected Overrides Sub OnResize(e As EventArgs)
  518.         MyBase.OnResize(e)
  519.         If Not MultiLine Then
  520.             Dim tbheight As Integer = _tb.Height
  521.             _tb.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer))
  522.             _tb.Size = New Size(Width - 20, tbheight)
  523.         Else
  524.             _tb.Location = New Point(10, 10)
  525.             _tb.Size = New Size(Width - 20, Height - 20)
  526.         End If
  527.     End Sub
  528.  
  529.     Protected Overrides Sub OnEnter(e As EventArgs)
  530.         MyBase.OnEnter(e)
  531.         State = MouseState.Down : Invalidate()
  532.     End Sub
  533.  
  534.     Protected Overrides Sub OnLeave(e As EventArgs)
  535.         MyBase.OnLeave(e)
  536.         State = MouseState.None : Invalidate()
  537.     End Sub
  538.  
  539. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement