LordPankake

[VB.Net] Cry Engine Theme - [7 Controls | Bright]

Aug 19th, 2014
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. '|===========================================================|
  3. '|===|  Cry Engine Theme
  4. '| Creator: LordPankake
  5. '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
  6. '| Created: 8/19/2014, Last edited: 8/19/2014
  7. '|===========================================================|
  8. #Region "Base Classes"
  9. Public Class ThemedControl : Inherits Control
  10.     Public D As New DrawUtils
  11.     Public State As MouseState = MouseState.None
  12.     Public Pal As Palette
  13.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  14.     End Sub
  15.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  16.         MyBase.OnMouseEnter(e)
  17.         State = MouseState.Over
  18.         Invalidate()
  19.     End Sub
  20.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  21.         MyBase.OnMouseDown(e)
  22.         State = MouseState.Down
  23.         Invalidate()
  24.     End Sub
  25.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  26.         MyBase.OnMouseLeave(e)
  27.         State = MouseState.None
  28.         Invalidate()
  29.     End Sub
  30.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  31.         MyBase.OnMouseUp(e)
  32.         State = MouseState.Over
  33.         Invalidate()
  34.     End Sub
  35.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  36.         MyBase.OnTextChanged(e)
  37.         Invalidate()
  38.     End Sub
  39.     Sub New()
  40.         MyBase.New()
  41.         MinimumSize = New Size(20, 20)
  42.         ForeColor = Color.FromArgb(146, 149, 152)
  43.         Font = New Font("Segoe UI", 10.0F)
  44.         DoubleBuffered = True
  45.         Pal = New Palette
  46.         Pal.ColHighest = Color.FromArgb(105, 105, 105)
  47.         Pal.ColHigh = Color.FromArgb(65, 67, 69)
  48.         Pal.ColMed = Color.FromArgb(71, 71, 71)
  49.         Pal.ColDim = Color.FromArgb(52, 52, 52)
  50.         Pal.ColDark = Color.FromArgb(39, 39, 39)
  51.         BackColor = Pal.ColDim
  52.     End Sub
  53. End Class
  54. Public Class ThemedListControl : Inherits listbox
  55.     Public D As New DrawUtils
  56.     Public State As MouseState = MouseState.None
  57.     Public Pal As Palette
  58.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  59.     End Sub
  60.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  61.         MyBase.OnMouseEnter(e)
  62.         State = MouseState.Over
  63.         Invalidate()
  64.     End Sub
  65.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  66.         MyBase.OnMouseDown(e)
  67.         State = MouseState.Down
  68.         Invalidate()
  69.     End Sub
  70.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  71.         MyBase.OnMouseLeave(e)
  72.         State = MouseState.None
  73.         Invalidate()
  74.     End Sub
  75.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  76.         MyBase.OnMouseUp(e)
  77.         State = MouseState.Over
  78.         Invalidate()
  79.     End Sub
  80.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  81.         MyBase.OnTextChanged(e)
  82.         Invalidate()
  83.     End Sub
  84.     Sub New()
  85.         MyBase.New()
  86.         MinimumSize = New Size(20, 20)
  87.         ForeColor = Color.FromArgb(146, 149, 152)
  88.         Font = New Font("Segoe UI", 10.0F)
  89.         DoubleBuffered = True
  90.         Pal = New Palette
  91.         Pal.ColHighest = Color.FromArgb(105, 105, 105)
  92.         Pal.ColHigh = Color.FromArgb(65, 67, 69)
  93.         Pal.ColMed = Color.FromArgb(71, 71, 71)
  94.         Pal.ColDim = Color.FromArgb(52, 52, 52)
  95.         Pal.ColDark = Color.FromArgb(39, 39, 39)
  96.         BackColor = Pal.ColDim
  97.     End Sub
  98. End Class
  99. Public Class ThemedContainer : Inherits ContainerControl
  100.     Public D As New DrawUtils
  101.     Protected DoSize As Boolean = True
  102.     Protected DoDrag As Boolean = True
  103.     Public State As MouseState = MouseState.None
  104.     Protected TopCap As Boolean = False
  105.     Protected SizeCap As Boolean = False
  106.     Public Pal As Palette
  107.     Protected MouseP As Point = New Point(0, 0)
  108.     Protected TopGrip As Integer
  109.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  110.     End Sub
  111.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  112.         MyBase.OnMouseEnter(e)
  113.         State = MouseState.Over
  114.         Invalidate()
  115.     End Sub
  116.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  117.         MyBase.OnMouseDown(e)
  118.         State = MouseState.Down
  119.         If e.Button = Windows.Forms.MouseButtons.Left Then
  120.             If DoDrag And New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
  121.                 TopCap = True : MouseP = e.Location
  122.             ElseIf DoSize And New Rectangle(Width - 15, Height - 15, 15, 15).Contains(e.Location) Then
  123.                 SizeCap = True : MouseP = e.Location
  124.             End If
  125.         End If
  126.     End Sub
  127.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  128.         MyBase.OnMouseLeave(e)
  129.         State = MouseState.None
  130.         Invalidate()
  131.     End Sub
  132.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  133.         MyBase.OnMouseUp(e)
  134.         State = MouseState.Over
  135.         TopCap = False
  136.         If DoSize Then
  137.             SizeCap = False
  138.         End If
  139.  
  140.     End Sub
  141.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  142.         MyBase.OnMouseMove(e)
  143.  
  144.         If DoDrag And TopCap Then
  145.             Parent.Location = MousePosition - MouseP
  146.         End If
  147.         If DoSize And SizeCap Then
  148.             MouseP = e.Location
  149.             Parent.Size = New Size(MouseP)
  150.             Invalidate()
  151.         End If
  152.  
  153.     End Sub
  154.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  155.         MyBase.OnTextChanged(e)
  156.         Invalidate()
  157.     End Sub
  158.     Sub New()
  159.         MyBase.New()
  160.         MinimumSize = New Size(20, 20)
  161.         ForeColor = Color.FromArgb(146, 149, 152)
  162.         Font = New Font("Trebuchet MS", 10.0F)
  163.         DoubleBuffered = True
  164.         Pal = New Palette
  165.         Pal.ColHighest = Color.FromArgb(105, 105, 105)
  166.         Pal.ColHigh = Color.FromArgb(65, 67, 69)
  167.         Pal.ColMed = Color.FromArgb(71, 71, 71)
  168.         Pal.ColDim = Color.FromArgb(49, 49, 49)
  169.         Pal.ColDark = Color.FromArgb(39, 39, 39)
  170.         BackColor = Pal.ColDim
  171.     End Sub
  172. End Class
  173. #End Region
  174. #Region "Theme"
  175. Public Class CryForm : Inherits ThemedContainer
  176.     Sub New()
  177.         MyBase.New()
  178.         MinimumSize = New Size(305, 150)
  179.         BackColor = Pal.ColMed
  180.         Dock = DockStyle.Fill
  181.         TopGrip = 75
  182.         DoDrag = False
  183.         DoSize = False
  184.         Font = New Font("Segoe UI Light", 20.0F)
  185.     End Sub
  186.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  187.         Dim G As Graphics = e.Graphics
  188.         MyBase.OnPaint(e)
  189.         Try
  190.             Me.ParentForm.MinimumSize = MinimumSize
  191.             If Me.ParentForm.FormBorderStyle <> FormBorderStyle.FixedToolWindow Then
  192.                 Me.ParentForm.FormBorderStyle = FormBorderStyle.FixedToolWindow
  193.             End If
  194.         Catch ex As Exception : End Try
  195.         G.Clear(BackColor)
  196.         Dim TopLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip), Pal.ColDim, Pal.ColDark)
  197.         G.FillRectangle(TopLGB, New Rectangle(0, 0, Width, TopGrip))
  198.         G.SmoothingMode = SmoothingMode.AntiAlias
  199.         D.DrawText(G, New Rectangle(12, 0, Width, TopGrip), Text, Font, HorizontalAlignment.Left, Color.WhiteSmoke)
  200.     End Sub
  201. End Class
  202. Public Class CryDialogButton : Inherits ThemedControl
  203.     Sub New()
  204.         MyBase.New()
  205.         Font = New Font("Segoe UI Semilight", 13.0F)
  206.         ForeColor = Pal.ColHighest
  207.     End Sub
  208.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  209.         Dim G As Graphics = e.Graphics
  210.         MyBase.OnPaint(e)
  211.         G.Clear(Me.Parent.BackColor)
  212.         G.SmoothingMode = SmoothingMode.HighQuality
  213.         Dim BorderCol As New Color
  214.         Select Case State
  215.             Case MouseState.None
  216.                 BorderCol = Color.FromArgb(25, 100, 130)
  217.             Case MouseState.Over
  218.                 BorderCol = Color.FromArgb(30, 120, 160)
  219.             Case MouseState.Down
  220.                 BorderCol = Color.FromArgb(10, 75, 100)
  221.         End Select
  222.         G.DrawPath(New Pen(BorderCol), D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 5))
  223.         D.DrawText(G, New Rectangle(6, 0, Width - 13, Height - 2), Text, Font, HorizontalAlignment.Left, ForeColor)
  224.     End Sub
  225. End Class
  226. Public Class CryButton : Inherits ThemedControl
  227.     Sub New()
  228.         MyBase.New()
  229.         Font = New Font("Segoe UI Semilight", 13.0F)
  230.         ForeColor = Pal.ColHighest
  231.     End Sub
  232.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  233.         Dim G As Graphics = e.Graphics
  234.         MyBase.OnPaint(e)
  235.         G.Clear(Me.Parent.BackColor)
  236.         G.SmoothingMode = SmoothingMode.HighQuality
  237.         Dim TopCol, Botcol As New Color
  238.         Select Case State
  239.             Case MouseState.None
  240.                 TopCol = Color.FromArgb(Pal.ColDark.R + 30, Pal.ColDark.R + 30, Pal.ColDark.R + 30)
  241.                 Botcol = Pal.ColDark
  242.             Case MouseState.Over
  243.                 TopCol = Color.FromArgb(Pal.ColDim.R + 30, Pal.ColDim.R + 30, Pal.ColDim.R + 30)
  244.                 Botcol = Pal.ColDim
  245.             Case MouseState.Down
  246.                 TopCol = Pal.ColDark
  247.                 Botcol = Color.FromArgb(Pal.ColDark.R - 30, Pal.ColDark.R - 30, Pal.ColDark.R - 30)
  248.         End Select
  249.         Dim InnerLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), TopCol, Botcol)
  250.         G.DrawRectangle(New Pen(Pal.ColHighest), New Rectangle(0, 0, Width - 2, Height - 2))
  251.         G.DrawRectangle(New Pen(Color.FromArgb(11, 11, 11)), New Rectangle(1, 1, Width - 2, Height - 2))
  252.         G.FillRectangle(InnerLGB, New Rectangle(0, 0, Width - 1, Height - 1))
  253.         D.DrawText(G, New Rectangle(0, 0, Width - 8, Height - 1), Text, Font, HorizontalAlignment.Center, ForeColor)
  254.     End Sub
  255. End Class
  256. Public Class CryCheckbox : Inherits ThemedControl
  257.     Public Property Checked As Boolean
  258.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  259.         MyBase.OnMouseDown(e)
  260.         Checked = Not Checked
  261.         ForeColor = Color.WhiteSmoke
  262.     End Sub
  263.     Sub New()
  264.         MyBase.New()
  265.         Font = New Font("Segoe UI Semilight", 11.0F)
  266.     End Sub
  267.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  268.         Dim G As Graphics = e.Graphics
  269.         MyBase.OnPaint(e)
  270.         G.Clear(Me.Parent.BackColor)
  271.         Height = 21
  272.         G.SmoothingMode = SmoothingMode.HighQuality
  273.  
  274.         If Checked Then
  275.             G.FillPath(New SolidBrush(Color.FromArgb(21, 21, 21)), D.RoundRect(New Rectangle(0, 0, Height - 1, Height - 1), 1))
  276.             ForeColor = Color.WhiteSmoke
  277.             Dim ColBlend As New ColorBlend
  278.             Dim ChkLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.Black, Color.Black)
  279.             ColBlend.Colors = New Color() {Pal.ColHighest, Pal.ColDark, Pal.ColMed}
  280.             ColBlend.Positions = New Single() {0.0, 0.4, 1.0}
  281.             ChkLGB.InterpolationColors = ColBlend
  282.             G.FillPath(ChkLGB, D.RoundRect(New Rectangle(1, 1, Height - 3, Height - 3), 1))
  283.         Else
  284.             G.FillPath(New SolidBrush(Pal.ColDark), D.RoundRect(New Rectangle(0, 0, Height - 1, Height - 1), 1))
  285.             ForeColor = Pal.ColHighest
  286.         End If
  287.         D.DrawText(G, New Rectangle(Height + 1, 0, Width, Height), Text, Font, HorizontalAlignment.Left, ForeColor)
  288.     End Sub
  289. End Class
  290. Public Class CryRadiobutton : Inherits ThemedControl
  291.     Public Property Checked As Boolean
  292.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  293.         MyBase.OnMouseDown(e)
  294.         For Each Cont As Control In Parent.Controls
  295.             If TypeOf Cont Is CryRadiobutton Then
  296.                 DirectCast(Cont, CryRadiobutton).Checked = False
  297.                 Cont.Invalidate()
  298.             End If
  299.         Next
  300.         Checked = True
  301.     End Sub
  302.     Sub New()
  303.         MyBase.New()
  304.  
  305.         Font = New Font("Segoe UI Semilight", 11.0F)
  306.     End Sub
  307.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  308.         Dim G As Graphics = e.Graphics
  309.         MyBase.OnPaint(e)
  310.         G.Clear(Me.Parent.BackColor)
  311.         Height = 21
  312.         G.SmoothingMode = SmoothingMode.HighQuality
  313.  
  314.         If Checked Then
  315.             G.FillEllipse(New SolidBrush(Color.FromArgb(21, 21, 21)), New Rectangle(0, 0, Height - 1, Height - 1))
  316.             ForeColor = Color.WhiteSmoke
  317.             Dim ColBlend As New ColorBlend
  318.             Dim ChkLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.Black, Color.Black)
  319.             ColBlend.Colors = New Color() {Pal.ColHighest, Pal.ColDark, Pal.ColMed}
  320.             ColBlend.Positions = New Single() {0.0, 0.4, 1.0}
  321.             ChkLGB.InterpolationColors = ColBlend
  322.             G.FillEllipse(ChkLGB, New Rectangle(1, 1, Height - 3, Height - 3))
  323.         Else
  324.             G.FillEllipse(New SolidBrush(Pal.ColDark), New Rectangle(0, 0, Height - 1, Height - 1))
  325.             ForeColor = Pal.ColHighest
  326.         End If
  327.         D.DrawText(G, New Rectangle(Height + 1, 0, Width, Height), Text, Font, HorizontalAlignment.Left, ForeColor)
  328.     End Sub
  329. End Class
  330. Public Class CryListbox : Inherits ThemedListControl
  331.     Sub New()
  332.         MyBase.New()
  333.         Font = New Font("Segoe UI Semilight", 12.0F)
  334.         ForeColor = Pal.ColHighest
  335.         DrawMode = DrawMode.OwnerDrawVariable
  336.         BorderStyle = BorderStyle.None
  337.         SetStyle(ControlStyles.UserPaint, True)
  338.     End Sub
  339.  
  340.     Protected Sub OnItemPaint(ByVal G As Graphics, ByVal i As Integer)
  341.         Dim gr As New Rectangle(0, i * 21, Width - 1, 21)
  342.  
  343.         If i = SelectedIndex Then
  344.             G.FillRectangle(New SolidBrush(Color.FromArgb(50, Pal.ColHighest)), gr)
  345.         End If
  346.  
  347.         G.DrawString(Items(i).ToString(), Font, New SolidBrush(ForeColor), gr)
  348.         G.DrawRectangle(New Pen(Color.FromArgb(50, Pal.ColHighest)), gr)
  349.     End Sub
  350.  
  351.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  352.         Dim G As Graphics = e.Graphics
  353.         MyBase.OnPaint(e)
  354.         G.Clear(Me.Parent.BackColor)
  355.         G.SmoothingMode = SmoothingMode.HighQuality
  356.         BorderStyle = BorderStyle.None
  357.         G.FillPath(New SolidBrush(Pal.ColDim), D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  358.  
  359.         Dim x As Integer = 0
  360.         For Each i As Object In Items
  361.             OnItemPaint(G, x)
  362.             x += 1
  363.         Next
  364.  
  365.         G.DrawPath(New Pen(ForeColor), D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  366.     End Sub
  367. End Class
  368. #End Region
  369. #Region "Theme Utility Stuff"
  370. Public Class Palette
  371.     Public ColHighest As Color
  372.     Public ColHigh As Color
  373.     Public ColMed As Color
  374.     Public ColDim As Color
  375.     Public ColDark As Color
  376. End Class
  377. Public Enum MouseState As Byte
  378.     None = 0
  379.     Over = 1
  380.     Down = 2
  381.     Block = 3
  382. End Enum
  383. Public Class DrawUtils
  384.     Public Sub DrawText(ByVal G As Graphics, ByVal ContRect As Rectangle, ByVal Text As String, ByVal TFont As Font, ByVal TAlign As HorizontalAlignment, ByVal TColor As Color)
  385.         If String.IsNullOrEmpty(Text) Then Return
  386.         Dim TextSize As Size = G.MeasureString(Text, TFont).ToSize
  387.         Dim CenteredY As Integer = ContRect.Height \ 2 - TextSize.Height \ 2
  388.         Select Case TAlign
  389.             Case HorizontalAlignment.Left
  390.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X, CenteredY)
  391.             Case HorizontalAlignment.Right
  392.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X + ContRect.Width - TextSize.Width - 5, CenteredY)
  393.             Case HorizontalAlignment.Center
  394.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X + 4 + ContRect.Width \ 2 - TextSize.Width \ 2, CenteredY)
  395.         End Select
  396.     End Sub
  397.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  398.         Dim Path As New GraphicsPath
  399.         Dim ArcRectangleWidth As Integer = Curve * 2
  400.         With Path
  401.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  402.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  403.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  404.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  405.             .AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  406.         End With
  407.         Return Path
  408.     End Function
  409. End Class
  410. #End Region
Advertisement
Add Comment
Please, Sign In to add comment