LordPankake

[VB.Net] Slice (Remix) Theme - [8 Controls | Dark]

Aug 13th, 2014
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. '|===========================================================|
  3. '|===|  Slice Theme (Re-creation)
  4. '| Creator: LordPankake
  5. '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
  6. '| Created: 8/5/2014, Last edited: 8/13/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(100, 100, 100)
  47.         Pal.ColHigh = Color.FromArgb(65, 65, 65)
  48.         Pal.ColMed = Color.FromArgb(40, 40, 40)
  49.         Pal.ColDim = Color.FromArgb(30, 30, 30)
  50.         Pal.ColDark = Color.FromArgb(15, 15, 15)
  51.         BackColor = Pal.ColDim
  52.     End Sub
  53. End Class
  54. Public Class ThemedTabControl : Inherits TabControl
  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(100, 100, 100)
  92.         Pal.ColHigh = Color.FromArgb(65, 65, 65)
  93.         Pal.ColMed = Color.FromArgb(40, 40, 40)
  94.         Pal.ColDim = Color.FromArgb(30, 30, 30)
  95.         Pal.ColDark = Color.FromArgb(15, 15, 15)
  96.         BackColor = Pal.ColDim
  97.         '  ItemSize = New Size(0, 25)
  98.        '  Padding = New Size(20, 0)
  99.        Alignment = TabAlignment.Top
  100.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  101.     End Sub
  102. End Class
  103. Public Class ThemedContainer : Inherits ContainerControl
  104.     Public D As New DrawUtils
  105.     Protected Drag As Boolean = True
  106.     Public State As MouseState = MouseState.None
  107.     Protected TopCap As Boolean = False
  108.     Protected SizeCap As Boolean = False
  109.     Public Pal As Palette
  110.     Protected MouseP As Point = New Point(0, 0)
  111.     Protected TopGrip As Integer
  112.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  113.     End Sub
  114.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  115.         MyBase.OnMouseEnter(e)
  116.         State = MouseState.Over
  117.         Invalidate()
  118.     End Sub
  119.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  120.         MyBase.OnMouseDown(e)
  121.         State = MouseState.Down
  122.         If e.Button = Windows.Forms.MouseButtons.Left And Drag Then
  123.             If New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
  124.                 TopCap = True : MouseP = e.Location
  125.             ElseIf New Rectangle(Width - 15, Height - 15, 15, 15).Contains(e.Location) Then
  126.                 SizeCap = True : MouseP = e.Location
  127.             End If
  128.         End If
  129.     End Sub
  130.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  131.         MyBase.OnMouseLeave(e)
  132.         State = MouseState.None
  133.         Invalidate()
  134.     End Sub
  135.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  136.         MyBase.OnMouseUp(e)
  137.         State = MouseState.Over
  138.         If Drag Then
  139.             TopCap = False
  140.             SizeCap = False
  141.         End If
  142.  
  143.     End Sub
  144.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  145.         MyBase.OnMouseMove(e)
  146.         If Drag Then
  147.             If TopCap Then
  148.                 Parent.Location = MousePosition - MouseP
  149.             End If
  150.             If SizeCap Then
  151.                 MouseP = e.Location
  152.                 Parent.Size = New Size(MouseP)
  153.                 Invalidate()
  154.             End If
  155.         End If
  156.     End Sub
  157.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  158.         MyBase.OnTextChanged(e)
  159.         Invalidate()
  160.     End Sub
  161.     Sub New()
  162.         MyBase.New()
  163.         MinimumSize = New Size(20, 20)
  164.         ForeColor = Color.FromArgb(146, 149, 152)
  165.         Font = New Font("Trebuchet MS", 10.0F)
  166.         DoubleBuffered = True
  167.         Pal = New Palette
  168.         Pal.ColHighest = Color.FromArgb(100, 100, 100)
  169.         Pal.ColHigh = Color.FromArgb(65, 65, 65)
  170.         Pal.ColMed = Color.FromArgb(40, 40, 40)
  171.         Pal.ColDim = Color.FromArgb(30, 30, 30)
  172.         Pal.ColDark = Color.FromArgb(15, 15, 15)
  173.         BackColor = Pal.ColDim
  174.     End Sub
  175. End Class
  176. #End Region
  177. #Region "Theme Objects"
  178. Public Class SliceForm : Inherits ThemedContainer
  179.     Public Property SolidTop As Boolean
  180.     Sub New()
  181.         MyBase.New()
  182.         MinimumSize = New Size(305, 150)
  183.         Dock = DockStyle.Fill
  184.         TopGrip = 27
  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.TransparencyKey = Color.Fuchsia
  191.             Me.ParentForm.MinimumSize = MinimumSize
  192.             If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
  193.                 Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  194.             End If
  195.         Catch ex As Exception : End Try
  196.         G.Clear(Me.ParentForm.TransparencyKey)
  197.         '| Details behind the main shape
  198.        Dim DrawRect As New Rectangle(140, 3, Width - 281, Height - 7)
  199.         Dim DrawRectHatch As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.Transparent, Pal.ColMed)
  200.         D.FillGradientBeam(G, Color.FromArgb(Pal.ColDim.R + 4, Pal.ColDim.R + 4, Pal.ColDim.R + 4), Pal.ColDark, DrawRect, GradientAlignment.Vertical)
  201.         G.FillRectangle(DrawRectHatch, DrawRect)
  202.         G.FillRectangle(New SolidBrush(Color.FromArgb(80, 1, 1, 1)), DrawRect)
  203.         D.FillGradientBeam(G, Pal.ColDark, Color.Transparent, New Rectangle(50, 3, Width - 101, Height - 7), GradientAlignment.Vertical)
  204.         ' Behind details - glow
  205.        D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(60, 150, 150, 150), New Rectangle(120, 3, Width - 241, TopGrip), GradientAlignment.Vertical)
  206.         D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, 3, Width - 241, 4), GradientAlignment.Vertical)
  207.         D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, 16, Width - 241, 4), GradientAlignment.Vertical)
  208.         D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(60, 150, 150, 150), New Rectangle(120, Height - 4 - TopGrip, Width - 241, TopGrip), GradientAlignment.Vertical)
  209.         D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, Height - 8, Width - 241, 4), GradientAlignment.Vertical)
  210.         D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, Height - 21, Width - 241, 4), GradientAlignment.Vertical)
  211.         G.DrawRectangle(Pens.Black, DrawRect)
  212.         '| Creation of the main shape.
  213.        Dim MainPath As New GraphicsPath
  214.         Dim Curve As Integer = 6
  215.         Dim ArcRectangleWidth As Integer = Curve * 2
  216.         With MainPath
  217.             .AddArc(New Rectangle(0, 0, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  218.             .AddLine(New Point(140, 0), New Point(160, 20))
  219.             .AddLine(New Point(Width - 161, 20), New Point(Width - 141, 0))
  220.             .AddArc(New Rectangle(Width - ArcRectangleWidth - 1, 0, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  221.             .AddArc(New Rectangle(Width - ArcRectangleWidth - 1, Height - ArcRectangleWidth - 1, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  222.             .AddLine(New Point(Width - 141, Height - 1), New Point(Width - 161, Height - 21))
  223.             .AddLine(New Point(160, Height - 21), New Point(140, Height - 1))
  224.             .AddArc(New Rectangle(0, Height - ArcRectangleWidth - 1, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  225.             .AddLine(New Point(0, Height - ArcRectangleWidth - 1), New Point(0, Curve + 0))
  226.         End With
  227.         '| Initial Fill
  228.        G.FillPath(New SolidBrush(Pal.ColDim), MainPath)
  229.         G.SmoothingMode = SmoothingMode.HighQuality
  230.  
  231.         '| Drawing the inner glow
  232.        Dim GlowPath As GraphicsPath = MainPath
  233.         Dim GlowBrush As PathGradientBrush
  234.         GlowBrush = New PathGradientBrush(GlowPath)
  235.         GlowBrush.CenterColor = Color.Transparent
  236.         GlowBrush.SurroundColors = {Color.FromArgb(Pal.ColHigh.R - 15, Pal.ColHigh.R - 15, Pal.ColHigh.R - 15)}
  237.         GlowBrush.FocusScales = New PointF(1.0F, 0.9F)
  238.         GlowBrush.CenterPoint = New Point(Width / 2, Height / 2)
  239.         G.FillPath(GlowBrush, GlowPath)
  240.  
  241.         '| Fixing the sides (from glow)
  242.        G.SmoothingMode = SmoothingMode.None
  243.         G.DrawLine(Pens.Black, New Point(0, 5), New Point(0, Height - 6))
  244.         G.DrawLine(Pens.Black, New Point(Width - 1, 5), New Point(Width - 1, Height - 6))
  245.  
  246.         '| Drawing the text and final shape outline
  247.        D.DrawTextWithShadow(G, New Rectangle(0, 1, 140, TopGrip), Text, Font, HorizontalAlignment.Center, Color.FromArgb(160, 160, 160), Color.Black)
  248.         G.DrawPath(New Pen(Brushes.Black, 1), MainPath)
  249.     End Sub
  250. End Class
  251. Public Class SliceTopButton : Inherits ThemedControl
  252.     Public Property Action As BtnAction = BtnAction.Close
  253.  
  254.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  255.         MyBase.OnMouseDown(e)
  256.         State = MouseState.Down
  257.         Invalidate()
  258.         If e.X > Location.X Then
  259.  
  260.         End If
  261.         If Action = BtnAction.Close Then
  262.             FindForm.Close()
  263.         Else
  264.             FindForm.WindowState = FormWindowState.Minimized
  265.         End If
  266.  
  267.     End Sub
  268.     Enum BtnAction
  269.         Close
  270.         Minimize
  271.     End Enum
  272.     Sub New()
  273.         MyBase.New()
  274.         Font = New Font("Trebuchet MS", 12.0F, FontStyle.Bold)
  275.     End Sub
  276.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  277.         Dim G As Graphics = e.Graphics
  278.         MyBase.OnPaint(e)
  279.         G.Clear(Me.Parent.BackColor)
  280.         G.SmoothingMode = SmoothingMode.HighQuality
  281.         Dim BorderPath As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, Height - 1), 5)
  282.         Dim FillPath As GraphicsPath = D.RoundedTopRect(New Rectangle(1, 1, Width - 3, Height - 3), 5)
  283.  
  284.         '| Setup the rotate/shift
  285.        Dim RotateMatrix As New Matrix
  286.         RotateMatrix.RotateAt(180, New Point(Width / 2, Height / 2))
  287.         RotateMatrix.Translate(1, 1)
  288.  
  289.         '| Transform the paths to rotate (Don't feel like duplicating draw method)
  290.        BorderPath.Transform(RotateMatrix)
  291.         FillPath.Transform(RotateMatrix)
  292.         Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
  293.  
  294.         '| Handling colors/text based on the action
  295.        If Action = BtnAction.Close Then
  296.             Select Case State
  297.                 Case MouseState.None
  298.                     Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(200, 40, 40), Color.FromArgb(150, 40, 40))
  299.                     Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(255, 88, 66), Color.FromArgb(200, 80, 60))
  300.                     G.FillPath(FillGB, FillPath)
  301.                     G.DrawPath(New Pen(DrawGB), FillPath)
  302.                 Case MouseState.Over
  303.                     Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(255, 40, 40), Color.FromArgb(200, 40, 40))
  304.                     Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(255, 133, 100), Color.FromArgb(200, 90, 75))
  305.                     G.FillPath(FillGB, FillPath)
  306.                     G.DrawPath(New Pen(DrawGB), FillPath)
  307.                 Case MouseState.Down
  308.                     Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(188, 20, 20), Color.FromArgb(140, 5, 5))
  309.                     Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(222, 44, 22), Color.FromArgb(180, 22, 5))
  310.                     G.FillPath(FillGB, FillPath)
  311.                     G.DrawPath(New Pen(DrawGB), FillPath)
  312.             End Select
  313.             D.DrawTextWithShadow(G, TextRect, "X", Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
  314.         Else
  315.             Select Case State
  316.                 Case MouseState.None
  317.                     Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(40, 40, 200), Color.FromArgb(40, 40, 150))
  318.                     Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(66, 88, 255), Color.FromArgb(60, 80, 200))
  319.                     G.FillPath(FillGB, FillPath)
  320.                     G.DrawPath(New Pen(DrawGB), FillPath)
  321.                 Case MouseState.Over
  322.                     Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(40, 40, 255), Color.FromArgb(40, 40, 200))
  323.                     Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(100, 133, 200), Color.FromArgb(75, 90, 170))
  324.                     G.FillPath(FillGB, FillPath)
  325.                     G.DrawPath(New Pen(DrawGB), FillPath)
  326.                 Case MouseState.Down
  327.                     Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(20, 40, 188), Color.FromArgb(5, 20, 140))
  328.                     Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(22, 44, 222), Color.FromArgb(5, 22, 180))
  329.                     G.FillPath(FillGB, FillPath)
  330.                     G.DrawPath(New Pen(DrawGB), FillPath)
  331.             End Select
  332.             D.DrawTextWithShadow(G, TextRect, "-", Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
  333.         End If
  334.         G.DrawPath(Pens.Black, BorderPath)
  335.         D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
  336.     End Sub
  337. End Class
  338. Public Class SliceButton : Inherits ThemedControl
  339.     Sub New()
  340.         MyBase.New()
  341.         Font = New Font("Trebuchet MS", 10.0F)
  342.     End Sub
  343.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  344.         Dim G As Graphics = e.Graphics
  345.         MyBase.OnPaint(e)
  346.         G.Clear(Me.Parent.BackColor)
  347.         G.SmoothingMode = SmoothingMode.HighQuality
  348.  
  349.         Dim BorderPath As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2)
  350.         Dim FillPath As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 2)
  351.         Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
  352.  
  353.         '| Handling colors/text based on the action
  354.        Select Case State
  355.             Case MouseState.None
  356.                 Dim BtnBrush As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColMed, Pal.ColDim)
  357.                 G.FillPath(BtnBrush, FillPath)
  358.                 G.DrawPath(New Pen(Pal.ColHigh), FillPath)
  359.                 D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
  360.  
  361.             Case MouseState.Over
  362.                 Dim BtnBrush As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHigh, Pal.ColMed)
  363.                 G.FillPath(BtnBrush, FillPath)
  364.                 G.DrawPath(New Pen(Pal.ColHighest), FillPath)
  365.                 D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.WhiteSmoke, Color.Black)
  366.  
  367.             Case MouseState.Down
  368.                 Dim BtnBrush As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColDim, Pal.ColDark)
  369.                 G.FillPath(BtnBrush, FillPath)
  370.                 G.DrawPath(New Pen(Pal.ColMed), FillPath)
  371.                 D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(144, 144, 144), Color.Black)
  372.  
  373.         End Select
  374.         G.DrawPath(Pens.Black, BorderPath)
  375.     End Sub
  376. End Class
  377. Public Class SliceTextbox : Inherits ThemedControl
  378. #Region "Textbox Data"
  379.     Private WithEvents TxtBox As New TextBox
  380.     Private TempSize As Size
  381.     Public Property TxtReadOnly As Boolean
  382.     Public Property MaxCharacters As Integer
  383.     Public Property Multiline() As Boolean
  384.         Get
  385.             Return TxtBox.Multiline
  386.         End Get
  387.         Set(ByVal v As Boolean)
  388.             TxtBox.Multiline = v
  389.             Invalidate()
  390.         End Set
  391.     End Property
  392.     Public Property TextAlign As HorizontalAlignment
  393.     Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  394.         MyBase.OnSizeChanged(e)
  395.         If Not Size.Height = 21 Then
  396.             TempSize = Size
  397.         End If
  398.         If Not IsNothing(TxtBox) Then
  399.             TxtBox.Size = New Size(Width - 8, Height - 8)
  400.         End If
  401.  
  402.         Invalidate()
  403.     End Sub
  404.     Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  405.         MyBase.OnFontChanged(e)
  406.         If Not IsNothing(TxtBox) Then
  407.             TxtBox.Font = Font
  408.         End If
  409.  
  410.     End Sub
  411.     Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  412.         MyBase.OnGotFocus(e)
  413.         TxtBox.Focus()
  414.     End Sub
  415.     Private Sub TextChngTxtBox() Handles TxtBox.TextChanged
  416.         Text = TxtBox.Text
  417.     End Sub
  418.     Private Sub TextChng() Handles MyBase.TextChanged
  419.         TxtBox.Text = Text
  420.     End Sub
  421.     Private Sub SetupTextbox()
  422.  
  423.         TxtBox.MaxLength = 30000
  424.         TxtBox.Size = New Size(New Point(50, 21))
  425.         TxtBox.Multiline = True
  426.         TxtBox.BackColor = Pal.ColMed
  427.         TxtBox.ForeColor = Color.FromArgb(199, 199, 199)
  428.         TxtBox.Text = String.Empty
  429.         TxtBox.TextAlign = HorizontalAlignment.Left
  430.         TxtBox.BorderStyle = BorderStyle.None
  431.         TxtBox.Location = New Point(4, 4)
  432.         TxtBox.Font = Font
  433.         TxtBox.Size = New Size(Width - 8, Height - 8)
  434.     End Sub
  435. #End Region
  436.     Sub New()
  437.         MyBase.New()
  438.         Font = New Font("Trebuchet MS", 8.5F)
  439.         TxtReadOnly = False
  440.         Multiline = False
  441.         TextAlign = HorizontalAlignment.Left
  442.         SetupTextbox()
  443.         Controls.Add(TxtBox)
  444.     End Sub
  445.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  446.         Dim G As Graphics = e.Graphics
  447.         MyBase.OnPaint(e)
  448.         G.Clear(Me.Parent.BackColor)
  449.         If Not TxtBox.Multiline Then
  450.             TxtBox.Location = New Point(6, TxtBox.Top)
  451.             If (TxtBox.Width + TxtBox.Left) > Width - 3 And TxtBox.Width > 5 Then
  452.                 TxtBox.Width -= 1
  453.             End If
  454.             Size = New Size(New Point(Width, 21))
  455.         Else
  456.             TxtBox.Location = New Point(3, TxtBox.Top)
  457.             Size = TempSize
  458.         End If
  459.         G.SmoothingMode = SmoothingMode.HighQuality
  460.         'Color.FromArgb(Pal.ColMed.R - 10, Pal.ColMed.R - 10, Pal.ColMed.R - 10) instead of ColDark
  461.        G.FillPath(New SolidBrush(Pal.ColMed), D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 2))
  462.         G.DrawPath(New Pen(Pal.ColHigh), D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 2))
  463.         G.DrawPath(New Pen(Pal.ColDark), D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  464.     End Sub
  465. End Class
  466. Public Class SliceCheckbox : Inherits ThemedControl
  467.     Public Property Checked As Boolean
  468.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  469.         MyBase.OnMouseDown(e)
  470.         Checked = Not Checked
  471.     End Sub
  472.     Sub New()
  473.         MyBase.New()
  474.         Font = New Font("Trebuchet MS", 10.0F)
  475.     End Sub
  476.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  477.         Dim G As Graphics = e.Graphics
  478.         MyBase.OnPaint(e)
  479.         G.Clear(Me.Parent.BackColor)
  480.         Height = 21
  481.         G.SmoothingMode = SmoothingMode.HighQuality
  482.         Dim BorderPath As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Height - 1, Height - 1), 3)
  483.         Dim FillPath As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Height - 3, Height - 3), 3)
  484.         If Checked Then
  485.             G.FillPath(New SolidBrush(Pal.ColHigh), FillPath)
  486.             G.DrawPath(New Pen(Pal.ColHighest), FillPath)
  487.         Else
  488.             G.FillPath(New SolidBrush(Pal.ColMed), FillPath)
  489.             G.DrawPath(New Pen(Pal.ColHigh), FillPath)
  490.         End If
  491.         G.DrawPath(Pens.Black, BorderPath)
  492.         D.DrawTextWithShadow(G, New Rectangle(Height + 3, 0, Height - 4, Height - 2), Text, Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
  493.     End Sub
  494. End Class
  495. Public Class SliceRadiobutton : Inherits ThemedControl
  496.     Public Property Checked As Boolean
  497.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  498.         MyBase.OnMouseDown(e)
  499.         For Each Cont As Control In Parent.Controls
  500.             If TypeOf Cont Is SliceRadiobutton Then
  501.                 DirectCast(Cont, SliceRadiobutton).Checked = False
  502.                 Cont.Invalidate()
  503.             End If
  504.         Next
  505.         Checked = True
  506.     End Sub
  507.     Sub New()
  508.         MyBase.New()
  509.         Font = New Font("Trebuchet MS", 10.0F)
  510.     End Sub
  511.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  512.         Dim G As Graphics = e.Graphics
  513.         MyBase.OnPaint(e)
  514.         G.Clear(Me.Parent.BackColor)
  515.         Height = 21
  516.         G.SmoothingMode = SmoothingMode.HighQuality
  517.         If Checked Then
  518.             G.FillEllipse(New SolidBrush(Pal.ColHigh), New Rectangle(1, 1, Height - 3, Height - 3))
  519.             G.DrawEllipse(New Pen(Pal.ColHighest), New Rectangle(1, 1, Height - 3, Height - 3))
  520.         Else
  521.             G.FillEllipse(New SolidBrush(Pal.ColMed), New Rectangle(1, 1, Height - 3, Height - 3))
  522.             G.DrawEllipse(New Pen(Pal.ColHigh), New Rectangle(1, 1, Height - 3, Height - 3))
  523.         End If
  524.         G.DrawEllipse(Pens.Black, New Rectangle(0, 0, Height - 1, Height - 1))
  525.         D.DrawTextWithShadow(G, New Rectangle(Height + 3, 0, Height - 4, Height - 2), Text, Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
  526.     End Sub
  527. End Class
  528. Public Class SliceGroupbox : Inherits ThemedContainer
  529.     Sub New()
  530.         MyBase.New()
  531.         Drag = False
  532.     End Sub
  533.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  534.         Dim G As Graphics = e.Graphics
  535.         MyBase.OnPaint(e)
  536.         G.Clear(Me.Parent.BackColor)
  537.         G.SmoothingMode = SmoothingMode.HighQuality
  538.         Dim BorderPath1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 5)
  539.         Dim BorderPath2 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 5)
  540.         G.DrawPath(New Pen(Pal.ColHigh), BorderPath2)
  541.         G.DrawPath(New Pen(Pal.ColDark), BorderPath1)
  542.     End Sub
  543. End Class
  544. Public Class SliceTabControl : Inherits ThemedTabControl
  545.     Sub New()
  546.         MyBase.New()
  547.         ItemSize = New Size(0, 60)
  548.         Padding = New Size(20, 0)
  549.         Font = New Font("Trebuchet MS", 10.0F)
  550.     End Sub
  551.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  552.         Dim G As Graphics = e.Graphics
  553.         MyBase.OnPaint(e)
  554.         G.Clear(Me.Parent.BackColor)
  555.         G.SmoothingMode = SmoothingMode.HighQuality
  556.  
  557.         'Idea, draw the entire bar (roundRect) and draw the 'down' state if the index is the selected one. All the sparator lines will be drawn regardless
  558.        Dim barheight As Integer = 50
  559.         Dim MainBar As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, barheight), 5)
  560.         Dim MainBarHighlight As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, barheight - 2), 5)
  561.         Dim MainBarSub As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, barheight + 6), 5)
  562.         Dim MainBarFillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, barheight), Pal.ColHighest, Pal.ColHigh)
  563.         Dim MainBarOutlineGB As New LinearGradientBrush(New Point(0, 0), New Point(0, barheight), Pal.ColDark, Color.Black)
  564.         G.FillPath(New SolidBrush(Color.FromArgb(Pal.ColHigh.R - 11, Pal.ColHigh.R - 11, Pal.ColHigh.R - 11)), MainBarSub)
  565.         G.FillPath(MainBarFillGB, MainBar)
  566.         G.DrawPath(New Pen(Pal.ColHighest), MainBarHighlight)
  567.         G.DrawPath(New Pen(MainBarOutlineGB), MainBar)
  568.         G.DrawPath(New Pen(MainBarOutlineGB), MainBarSub)
  569.  
  570.         For i = 0 To TabCount - 1
  571.             Dim TabRect As Rectangle = GetTabRect(i)
  572.             Dim LineX As Integer = TabRect.X + TabRect.Width - 1
  573.             If i = SelectedIndex Then
  574.                 G.FillRectangle(New SolidBrush(Me.Parent.BackColor), New Rectangle(TabRect.X - 1, -5, TabRect.Width + 1, TabRect.Height + 10))
  575.                 G.FillRectangle(New SolidBrush(Pal.ColHighest), New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight))
  576.                 D.FillGradientBeam(G, Color.FromArgb(50, 200, 200, 200), Color.Transparent, New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight), GradientAlignment.Horizontal)
  577.                 G.DrawRectangle(Pens.Black, New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight))
  578.                 G.DrawLine(Pens.Black, New Point(LineX + 1, 0), New Point(LineX + 1, barheight))
  579.                 D.DrawTextWithShadow(G, New Rectangle(TabRect.X - 1, 10, TabRect.Width + 1, barheight + 10), TabPages(i).Text, Font, HorizontalAlignment.Center, Color.WhiteSmoke, Color.Black)
  580.             Else
  581.                 G.DrawLine(Pens.Black, New Point(LineX, 0), New Point(LineX, barheight))
  582.                 D.DrawTextWithShadow(G, New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight), TabPages(i).Text, Font, HorizontalAlignment.Center, Color.FromArgb(155, 155, 155), Color.Black)
  583.             End If
  584.  
  585.  
  586.             Try : TabPages(i).BackColor = Me.Parent.BackColor : Catch : End Try
  587.         Next
  588.    
  589.  
  590.     End Sub
  591. End Class
  592. #End Region
  593. '|===========================================================|
  594. #Region "Theme Utility Stuff"
  595. Public Class Palette
  596.     Public ColHighest As Color
  597.     Public ColHigh As Color
  598.     Public ColMed As Color
  599.     Public ColDim As Color
  600.     Public ColDark As Color
  601. End Class
  602. Public Enum MouseState As Byte
  603.     None = 0
  604.     Over = 1
  605.     Down = 2
  606.     Block = 3
  607. End Enum
  608. Public Enum GradientAlignment As Byte
  609.     Vertical = 0
  610.     Horizontal = 1
  611. End Enum
  612. Public Class DrawUtils
  613.     Public Sub FillGradientBeam(ByVal g As Graphics, ByVal Col1 As Color, ByVal Col2 As Color, ByVal rect As Rectangle, ByVal align As GradientAlignment)
  614.         Dim stored As SmoothingMode = g.SmoothingMode
  615.         Dim Blend As New ColorBlend
  616.         g.SmoothingMode = SmoothingMode.HighQuality
  617.         Select Case align
  618.             Case GradientAlignment.Vertical
  619.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black)
  620.                 Blend.Positions = {0, 1 / 2, 1}
  621.                 Blend.Colors = {Col1, Col2, Col1}
  622.                 PathGradient.InterpolationColors = Blend
  623.                 g.FillRectangle(PathGradient, rect)
  624.             Case GradientAlignment.Horizontal
  625.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black)
  626.                 Blend.Positions = {0, 1 / 2, 1}
  627.                 Blend.Colors = {Col1, Col2, Col1}
  628.                 PathGradient.InterpolationColors = Blend
  629.                 PathGradient.RotateTransform(0)
  630.                 g.FillRectangle(PathGradient, rect)
  631.         End Select
  632.         g.SmoothingMode = stored
  633.     End Sub
  634.     Public Sub DrawTextWithShadow(ByVal G As Graphics, ByVal ContRect As Rectangle, ByVal Text As String, ByVal TFont As Font, ByVal TAlign As HorizontalAlignment, ByVal TColor As Color, ByVal BColor As Color)
  635.         DrawText(G, New Rectangle(ContRect.X, ContRect.Y + 2, ContRect.Width + 1, ContRect.Height + 2), Text, TFont, TAlign, BColor)
  636.         DrawText(G, ContRect, Text, TFont, TAlign, TColor)
  637.     End Sub
  638.     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)
  639.         If String.IsNullOrEmpty(Text) Then Return
  640.         Dim TextSize As Size = G.MeasureString(Text, TFont).ToSize
  641.         Dim CenteredY As Integer = ContRect.Height \ 2 - TextSize.Height \ 2
  642.         Select Case TAlign
  643.             Case HorizontalAlignment.Left
  644.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X, CenteredY)
  645.             Case HorizontalAlignment.Right
  646.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X + ContRect.Width - TextSize.Width - 5, CenteredY)
  647.             Case HorizontalAlignment.Center
  648.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X + ContRect.Width \ 2 - TextSize.Width \ 2, CenteredY)
  649.         End Select
  650.     End Sub
  651.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  652.         Dim Path As New GraphicsPath
  653.         Dim ArcRectangleWidth As Integer = Curve * 2
  654.         With Path
  655.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  656.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  657.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  658.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  659.             .AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  660.         End With
  661.         Return Path
  662.     End Function
  663.     Public Function RoundedTopRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  664.         Dim Path As GraphicsPath = New GraphicsPath()
  665.         Dim ArcRectangleWidth As Integer = Curve * 2
  666.         With Path
  667.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  668.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  669.             .AddLine(New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height))
  670.             .AddLine(New Point(Rectangle.X, Rectangle.Height + Rectangle.Y), New Point(Rectangle.X, Rectangle.Y + Curve))
  671.         End With
  672.         Return Path
  673.     End Function
  674. End Class
  675. #End Region
Advertisement
Add Comment
Please, Sign In to add comment