LordPankake

[VB.Net] Azenis Theme - [6 Controls | Dark]

Aug 17th, 2014
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. '|===========================================================|
  3. '|===|  Azenis
  4. '| Creator: LordPankake
  5. '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
  6. '| Created: 8/13/2014, Last edited: 8/17/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, 105, 110)
  47.         Pal.ColHigh = Color.FromArgb(65, 67, 69)
  48.         Pal.ColMed = Color.FromArgb(40, 42, 44)
  49.         Pal.ColDim = Color.FromArgb(30, 32, 34)
  50.         Pal.ColDark = Color.FromArgb(15, 16, 17)
  51.         BackColor = Pal.ColDim
  52.     End Sub
  53. End Class
  54. Public Class ThemedComboBox : Inherits ComboBox
  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, 105, 110)
  92.         Pal.ColHigh = Color.FromArgb(65, 67, 69)
  93.         Pal.ColMed = Color.FromArgb(40, 42, 44)
  94.         Pal.ColDim = Color.FromArgb(30, 32, 34)
  95.         Pal.ColDark = Color.FromArgb(15, 16, 17)
  96.         BackColor = Pal.ColDim
  97.     End Sub
  98. End Class
  99. Public Class ThemedContainer : Inherits ContainerControl
  100.     Public D As New DrawUtils
  101.     Protected Drag As Boolean = True
  102.     Public State As MouseState = MouseState.None
  103.     Protected TopCap As Boolean = False
  104.     Protected SizeCap As Boolean = False
  105.     Public Pal As Palette
  106.     Protected MouseP As Point = New Point(0, 0)
  107.     Protected TopGrip As Integer
  108.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  109.     End Sub
  110.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  111.         MyBase.OnMouseEnter(e)
  112.         State = MouseState.Over
  113.         Invalidate()
  114.     End Sub
  115.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  116.         MyBase.OnMouseDown(e)
  117.         State = MouseState.Down
  118.         If e.Button = Windows.Forms.MouseButtons.Left Then
  119.             If New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
  120.                 TopCap = True : MouseP = e.Location
  121.             ElseIf Drag And New Rectangle(Width - 15, Height - 15, 15, 15).Contains(e.Location) Then
  122.                 SizeCap = True : MouseP = e.Location
  123.             End If
  124.         End If
  125.     End Sub
  126.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  127.         MyBase.OnMouseLeave(e)
  128.         State = MouseState.None
  129.         Invalidate()
  130.     End Sub
  131.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  132.         MyBase.OnMouseUp(e)
  133.         State = MouseState.Over
  134.         TopCap = False
  135.         If Drag Then
  136.             SizeCap = False
  137.         End If
  138.  
  139.     End Sub
  140.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  141.         MyBase.OnMouseMove(e)
  142.  
  143.         If TopCap Then
  144.             Parent.Location = MousePosition - MouseP
  145.         End If
  146.         If Drag And SizeCap Then
  147.             MouseP = e.Location
  148.             Parent.Size = New Size(MouseP)
  149.             Invalidate()
  150.         End If
  151.  
  152.     End Sub
  153.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  154.         MyBase.OnTextChanged(e)
  155.         Invalidate()
  156.     End Sub
  157.     Sub New()
  158.         MyBase.New()
  159.         MinimumSize = New Size(20, 20)
  160.         ForeColor = Color.FromArgb(146, 149, 152)
  161.         Font = New Font("Trebuchet MS", 10.0F)
  162.         DoubleBuffered = True
  163.         Pal = New Palette
  164.         Pal.ColHighest = Color.FromArgb(100, 105, 110)
  165.         Pal.ColHigh = Color.FromArgb(65, 67, 69)
  166.         Pal.ColMed = Color.FromArgb(40, 42, 44)
  167.         Pal.ColDim = Color.FromArgb(30, 32, 34)
  168.         Pal.ColDark = Color.FromArgb(15, 16, 17)
  169.         BackColor = Pal.ColDim
  170.     End Sub
  171. End Class
  172. #End Region
  173. #Region "Theme"
  174. Public Class AzenisForm : Inherits ThemedContainer
  175.     Sub New()
  176.         MyBase.New()
  177.         MinimumSize = New Size(305, 150)
  178.         Dock = DockStyle.Fill
  179.         TopGrip = 30
  180.         Font = New Font("Segoe UI", 10.0F)
  181.     End Sub
  182.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  183.         Dim G As Graphics = e.Graphics
  184.         MyBase.OnPaint(e)
  185.         Try
  186.             Me.ParentForm.TransparencyKey = Color.Fuchsia
  187.             Me.ParentForm.MinimumSize = MinimumSize
  188.             If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
  189.                 Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  190.             End If
  191.         Catch ex As Exception : End Try
  192.         G.Clear(Me.ParentForm.TransparencyKey)
  193.  
  194.         '|====| Main shape
  195.        Dim MainShape As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 8)
  196.         Dim DoStuffPath As GraphicsPath = D.RoundRect(New Rectangle(5, TopGrip + 2, Width - 11, Height - TopGrip - 8), 8)
  197.         G.FillPath(New SolidBrush(Pal.ColHighest), MainShape)
  198.         '| Interior shading (behind all else)
  199.        Dim ColBlend As ColorBlend = New ColorBlend(3)
  200.         Dim BlurScale As Integer = Math.Sqrt((Width * Width) + (Height * Height)) / 10
  201.         ColBlend.Colors = {Color.Transparent, Color.FromArgb(255, Pal.ColDim), Color.FromArgb(255, Pal.ColDim)}
  202.         ColBlend.Positions = {0, 1 / BlurScale, 1}
  203.         '| Looks best when square. Not sure how I would approach scaling for rectangular shapes.
  204.        D.DrawShadowPath(G, ColBlend, MainShape)
  205.         '| Adds a border inside the light blending on the edges
  206.        G.DrawPath(New Pen(Pal.ColDark), DoStuffPath)
  207.         '|====| Top bar
  208.        G.SmoothingMode = SmoothingMode.HighQuality
  209.         Dim TopPath As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 2, TopGrip + 3), 8)
  210.         Dim TopPathLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip + 5), Pal.ColHighest, Color.Transparent)
  211.         Dim LineLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip + 5), Pal.ColHighest, Color.Transparent)
  212.         Dim LineLGBAlt As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip + 5), Pal.ColDim, Color.Transparent)
  213.         G.FillPath(TopPathLGB, TopPath)
  214.         G.DrawLine(New Pen(LineLGB), New Point(9, 0), New Point(9, TopGrip + 5))
  215.         G.DrawLine(New Pen(LineLGB), New Point(Width - 10, 0), New Point(Width - 10, TopGrip + 5))
  216.         G.DrawLine(New Pen(Pal.ColDim), New Point(8, 0), New Point(8, TopGrip + 5))
  217.         G.DrawLine(New Pen(Pal.ColDim), New Point(Width - 9, 0), New Point(Width - 9, TopGrip + 5))
  218.         '|====| Top bar - Inner
  219.        Dim BaRct As New Rectangle(15, 4, Width - 31, TopGrip * (4 / 5))
  220.         Dim DP As GraphicsPath = D.RoundRect(BaRct, 5)
  221.         Dim TextureBrush As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Pal.ColMed, Color.Transparent)
  222.         G.DrawPath(New Pen(Pal.ColDark, 3), DP)
  223.         G.FillPath(New SolidBrush(Pal.ColDark), DP)
  224.         G.FillPath(TextureBrush, DP)
  225.         D.FillDualGradPath(G, Pal.ColDark, Color.Transparent, BaRct, DP, GradientAlignment.Horizontal)
  226.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHigh)), DP)
  227.         '|====|  Border
  228.        G.SmoothingMode = SmoothingMode.None
  229.         G.DrawPath(New Pen(Pal.ColDim), MainShape)
  230.         D.DrawTextWithShadow(G, New Rectangle(0, 0, Width - 1, TopGrip), Text, Font, HorizontalAlignment.Center, Pal.ColHighest, Pal.ColDark)
  231.     End Sub
  232. End Class
  233. Public Class AzenisButton : Inherits ThemedControl
  234.     Sub New()
  235.         MyBase.New()
  236.         Font = New Font("Trebuchet MS", 10.0F)
  237.     End Sub
  238.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  239.         Dim G As Graphics = e.Graphics
  240.         MyBase.OnPaint(e)
  241.         G.Clear(BackColor)
  242.         G.SmoothingMode = SmoothingMode.HighQuality
  243.         Dim MainShape As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2)
  244.         Dim LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHigh, Pal.ColDim)
  245.         G.FillPath(LGB, MainShape)
  246.  
  247.         Dim TextCol, TopColor As Color
  248.         Select Case State
  249.             Case MouseState.None
  250.                 TopColor = Pal.ColHighest
  251.                 TextCol = Color.FromArgb(Pal.ColHighest.R + 10, Pal.ColHighest.R + 10, Pal.ColHighest.R + 10)
  252.             Case MouseState.Over
  253.                 TopColor = Color.FromArgb(Pal.ColHighest.R + 20, Pal.ColHighest.R + 20, Pal.ColHighest.R + 20)
  254.                 G.FillPath(New SolidBrush(Color.FromArgb(10, Color.WhiteSmoke)), MainShape)
  255.                 TextCol = Color.FromArgb(Pal.ColHighest.R + 60, Pal.ColHighest.R + 60, Pal.ColHighest.R + 60)
  256.             Case MouseState.Down
  257.                 TopColor = Pal.ColDark
  258.                 G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDark)), MainShape)
  259.                 TextCol = Color.FromArgb(Pal.ColHighest.R - 20, Pal.ColHighest.R - 20, Pal.ColHighest.R - 20)
  260.         End Select
  261.         Dim LGB2 As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), TopColor, Pal.ColDark)
  262.         G.DrawPath(New Pen(LGB2), MainShape)
  263.         D.DrawTextWithShadow(G, New Rectangle(0, 0, Width - 1, Height - 1), Text, Font, HorizontalAlignment.Center, TextCol, Pal.ColDark)
  264.     End Sub
  265. End Class
  266. Public Class AzenisCheckbox : Inherits ThemedControl
  267.     Public Property Checked As Boolean
  268.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  269.         MyBase.OnMouseDown(e)
  270.         Checked = Not Checked
  271.     End Sub
  272.     Sub New()
  273.         MyBase.New()
  274.         Font = New Font("Trebuchet MS", 10.0F)
  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(BackColor)
  280.         Height = 21
  281.         G.SmoothingMode = SmoothingMode.HighQuality
  282.         '|====| Main Shape
  283.        '| Fill
  284.        Dim MainShape As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Height - 1, Height - 1), 2)
  285.         Dim LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHigh, Pal.ColDim)
  286.         G.FillPath(LGB, MainShape)
  287.         '| Border
  288.        Dim TextCol As Color = Color.FromArgb(Pal.ColHighest.R + 10, Pal.ColHighest.R + 10, Pal.ColHighest.R + 10)
  289.         Dim LGB2 As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHighest, Pal.ColDark)
  290.         G.DrawPath(New Pen(LGB2), MainShape)
  291.         '|====| Inner Shape
  292.        '| Fill
  293.        Dim InnerShape As GraphicsPath = D.RoundRect(New Rectangle(2, 2, Height - 5, Height - 5), 2)
  294.         Dim LGB3 As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColDark, Pal.ColHighest)
  295.         G.FillPath(LGB3, InnerShape)
  296.         '| Checked
  297.        If Checked Then
  298.             Dim InnerCheckShape As GraphicsPath = D.RoundRect(New Rectangle(3, 3, Height - 7, Height - 8), 2)
  299.             G.FillPath(New SolidBrush(Color.CadetBlue), InnerCheckShape)
  300.             Dim ColBlend As ColorBlend = New ColorBlend(2)
  301.             ColBlend.Colors = {Color.FromArgb(255, Color.FromArgb(11, 20, 70)), Color.Transparent}
  302.             ColBlend.Positions = {0, 1}
  303.             D.DrawShadowPath(G, ColBlend, InnerCheckShape)
  304.             G.DrawPath(Pens.Black, InnerCheckShape)
  305.         End If
  306.         D.DrawTextWithShadow(G, New Rectangle(Height + 3, 0, Width - 1, Height - 4), Text, Font, HorizontalAlignment.Left, TextCol, Pal.ColDark)
  307.     End Sub
  308. End Class
  309. Public Class AzenisRadiobutton : Inherits ThemedControl
  310.     Public Property Checked As Boolean
  311.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  312.         MyBase.OnMouseDown(e)
  313.         For Each Cont As Control In Parent.Controls
  314.             If TypeOf Cont Is AzenisRadiobutton Then
  315.                 DirectCast(Cont, AzenisRadiobutton).Checked = False
  316.                 Cont.Invalidate()
  317.             End If
  318.         Next
  319.         Checked = True
  320.     End Sub
  321.     Sub New()
  322.         MyBase.New()
  323.         Font = New Font("Trebuchet MS", 10.0F)
  324.     End Sub
  325.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  326.         Dim G As Graphics = e.Graphics
  327.         MyBase.OnPaint(e)
  328.         G.Clear(BackColor)
  329.         Height = 21
  330.         G.SmoothingMode = SmoothingMode.HighQuality
  331.         '|====| Main Shape
  332.        '| Fill
  333.        Dim MainShape As New Rectangle(0, 0, Height - 1, Height - 1)
  334.         Dim LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHigh, Pal.ColDim)
  335.         G.FillEllipse(LGB, MainShape)
  336.         '| Border
  337.        Dim TextCol As Color = Color.FromArgb(Pal.ColHighest.R + 10, Pal.ColHighest.R + 10, Pal.ColHighest.R + 10)
  338.         Dim LGB2 As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHighest, Pal.ColDark)
  339.         G.DrawEllipse(New Pen(LGB2), MainShape)
  340.         '|====| Inner Shape
  341.        '| Fill
  342.        Dim InnerShape As New Rectangle(2, 2, Height - 5, Height - 5)
  343.         Dim LGB3 As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColDark, Pal.ColHighest)
  344.         G.FillEllipse(LGB3, InnerShape)
  345.         '| Checked
  346.        If Checked Then
  347.             Dim InnerCheckShape As New Rectangle(3, 3, Height - 8, Height - 8)
  348.             G.FillEllipse(New SolidBrush(Color.CadetBlue), InnerCheckShape)
  349.             D.DrawShadowEllipse(G, Color.FromArgb(11, 20, 70), InnerCheckShape)
  350.             G.DrawEllipse(Pens.Black, InnerCheckShape)
  351.         End If
  352.         D.DrawTextWithShadow(G, New Rectangle(Height + 3, 0, Width - 1, Height - 4), Text, Font, HorizontalAlignment.Left, TextCol, Pal.ColDark)
  353.     End Sub
  354. End Class
  355. Public Class WhiteUIHorizontalBar : Inherits ThemedControl
  356.     Public Property Minimum As Integer = 0
  357.     Public Property Value As Integer = 50
  358.     Public Property Maximum As Integer = 100
  359.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  360.         MyBase.OnMouseDown(e)
  361.         If e.Button = Windows.Forms.MouseButtons.Left Then
  362.             Dim NewMin = Minimum - 10
  363.             Dim NewMax = Maximum + 10
  364.             Dim Offset As Integer = 24
  365.             If e.X > Offset And e.X < Width - Offset Then
  366.                 Value = (NewMin + (e.X * ((NewMax - NewMin) / Width)))
  367.             ElseIf e.X <= Offset Then
  368.                 Value = (NewMin + (Offset * ((NewMax - NewMin) / Width)))
  369.             ElseIf e.X >= Width - Offset Then
  370.                 Value = (NewMin + ((Width - Offset) * ((NewMax - NewMin) / Width)))
  371.             End If
  372.             Invalidate()
  373.         End If
  374.     End Sub
  375.     Sub New()
  376.         MyBase.New()
  377.         Font = New Font("Segoe UI", 10.0F, FontStyle.Bold)
  378.     End Sub
  379.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  380.         Dim G As Graphics = e.Graphics
  381.         MyBase.OnPaint(e)
  382.         G.Clear(Me.Parent.BackColor)
  383.         G.SmoothingMode = SmoothingMode.HighQuality
  384.         Dim MainPath As GraphicsPath = D.RoundRect(New Rectangle(2, 4, Width - 6, Height - 14), 4)
  385.         Dim MainPathHighlight As GraphicsPath = D.RoundRect(New Rectangle(2, 4, Width - 6, Height - 14), 4)
  386.         Dim MainPathShadow As GraphicsPath = D.RoundRect(New Rectangle(2, 6, Width - 6, Height - 14), 4)
  387.         Dim MainPathLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height - 1), Color.FromArgb(20, 100, 180), Color.FromArgb(15, 70, 140))
  388.         Dim MainPathHighlightLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(80, 80, 80), Color.FromArgb(22, 22, 22))
  389.         '|====| Main shape
  390.        G.FillPath(MainPathLGB, MainPath)
  391.         G.DrawPath(New Pen(Color.FromArgb(60, Color.Black), 2), MainPathShadow)
  392.         G.DrawPath(New Pen(MainPathHighlightLGB, 2), MainPathhighlight)
  393.  
  394.         '|====| Grip
  395.        Dim GripX As Integer = ValueToPercentage(Value) * Width - 15
  396.         Dim GripRect As New Rectangle(GripX, 0, 30, Height - 5)
  397.         Dim GripPath As GraphicsPath = D.RoundRect(GripRect, 6)
  398.         Dim GripShadowRect As New Rectangle(GripX - 2, -1, 34, Height)
  399.         Dim GripInnerRect As New Rectangle(GripX + 2, 2, 26, Height - 7)
  400.         Dim GripShadowPath As GraphicsPath = D.RoundRect(GripShadowRect, 6)
  401.         Dim GripInnerPath As GraphicsPath = D.RoundRect(GripInnerRect, 6)
  402.         Dim GripLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(80, 80, 80), Color.FromArgb(22, 22, 22))
  403.         Dim GripLGB2 As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(22, 22, 22), Color.FromArgb(80, 80, 80))
  404.         '| dropshadow
  405.        Dim ColBlend As ColorBlend = New ColorBlend(2)
  406.         ColBlend.Colors = {Color.Transparent, Color.FromArgb(70, Color.Black)}
  407.         ColBlend.Positions = {0, 1}
  408.         D.DrawShadowPath(G, ColBlend, GripShadowPath)
  409.         '| drawing
  410.        G.FillPath(GripLGB, GripPath)
  411.         G.FillPath(GripLGB2, GripInnerPath)
  412.         G.DrawPath(New Pen(New LinearGradientBrush(New Point(0, 0), New Point(0, Height - 3), Color.FromArgb(130, 130, 130), Color.FromArgb(22, 22, 22))), GripPath)
  413.     End Sub
  414.     Private Function ValueToPercentage(value As Integer) As Single
  415.         Dim min = Minimum - 10
  416.         Dim max = Maximum + 10
  417.         Return (value - min) / (max - min)
  418.         'vertical:  Return 1 - (value - min) / (max - min)
  419.    End Function
  420. End Class
  421. Public Class AzenisCombobox : Inherits ThemedComboBox
  422.     Private StrtIndex As Integer = 0
  423.     Public Property StartIndex As Integer
  424.         Get
  425.             Return StrtIndex
  426.         End Get
  427.         Set(ByVal value As Integer)
  428.             StrtIndex = value
  429.             Try
  430.                 MyBase.SelectedIndex = value
  431.             Catch
  432.             End Try
  433.             Invalidate()
  434.         End Set
  435.     End Property
  436.     Sub New()
  437.         MyBase.New()
  438.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  439.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  440.         DropDownStyle = ComboBoxStyle.DropDownList
  441.         Font = New Font("Trebuchet MS", 10.0F)
  442.     End Sub
  443.     Protected Sub OnItemPaint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  444.         Dim G As Graphics = e.Graphics
  445.         e.DrawBackground()
  446.         Dim BorderRect As Rectangle = e.Bounds
  447.         Try
  448.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  449.                 G.FillRectangle(New SolidBrush(Color.FromArgb(0, 145, 235)), BorderRect)
  450.             End If
  451.             G.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, New SolidBrush(e.ForeColor), e.Bounds)
  452.         Catch
  453.         End Try
  454.         e.DrawFocusRectangle()
  455.     End Sub
  456.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  457.         Dim G As Graphics = e.Graphics
  458.         MyBase.OnPaint(e)
  459.         G.Clear(BackColor)
  460.         G.SmoothingMode = SmoothingMode.HighQuality
  461.         Dim MainShape As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2)
  462.         Dim TextRect As GraphicsPath = D.RoundRect(New Rectangle(3, 3, Width - 21, Height - 7), 2)
  463.  
  464.         Dim LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHigh, Pal.ColDim)
  465.         G.FillPath(LGB, MainShape)
  466.         G.FillPath(New SolidBrush(Pal.ColDim), TextRect)
  467.         G.DrawPath(New Pen(Pal.ColDark), TextRect)
  468.         Dim TopColor As Color = Color.FromArgb(Pal.ColHighest.R + 10, Pal.ColHighest.R + 10, Pal.ColHighest.R + 10)
  469.         Dim LGB2 As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHighest, Pal.ColDark)
  470.         G.DrawPath(New Pen(LGB2), MainShape)
  471.  
  472.         G.DrawLine(New Pen(Pal.ColDark, 3), New Point(Width - 15, 7), New Point(Width - 3, 7))
  473.         G.DrawLine(New Pen(Pal.ColHighest, 1), New Point(Width - 15, 7), New Point(Width - 3, 7))
  474.  
  475.         G.DrawLine(New Pen(Pal.ColDark, 3), New Point(Width - 15, Height - 9), New Point(Width - 3, Height - 9))
  476.         G.DrawLine(New Pen(Pal.ColHighest, 1), New Point(Width - 15, Height - 9), New Point(Width - 3, Height - 9))
  477.  
  478.         G.DrawLine(New Pen(Pal.ColDark, 3), New Point(Width - 15, Height - 13), New Point(Width - 3, Height - 13))
  479.         G.DrawLine(New Pen(Pal.ColHighest, 1), New Point(Width - 15, Height - 13), New Point(Width - 3, Height - 13))
  480.  
  481.         D.DrawTextWithShadow(G, New Rectangle(5, 0, Width - 11, Height - 1), Text, Font, HorizontalAlignment.Left, Pal.ColHighest, Pal.ColDark)
  482.     End Sub
  483. End Class
  484. #End Region
  485. #Region "Theme Utility Stuff"
  486. Public Class Palette
  487.     Public ColHighest As Color
  488.     Public ColHigh As Color
  489.     Public ColMed As Color
  490.     Public ColDim As Color
  491.     Public ColDark As Color
  492. End Class
  493. Public Enum MouseState As Byte
  494.     None = 0
  495.     Over = 1
  496.     Down = 2
  497.     Block = 3
  498. End Enum
  499. Public Enum GradientAlignment As Byte
  500.     Vertical = 0
  501.     Horizontal = 1
  502. End Enum
  503. Public Class DrawUtils    
  504.     Public Sub FillDualGradPath(ByVal g As Graphics, ByVal Col1 As Color, ByVal Col2 As Color, ByVal rect As Rectangle, ByVal gp As GraphicsPath, ByVal align As GradientAlignment)
  505.         Dim stored As SmoothingMode = g.SmoothingMode
  506.         Dim Blend As New ColorBlend
  507.         g.SmoothingMode = SmoothingMode.HighQuality
  508.         Select Case align
  509.             Case GradientAlignment.Vertical
  510.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black)
  511.                 Blend.Positions = {0, 1 / 2, 1}
  512.                 Blend.Colors = {Col1, Col2, Col1}
  513.                 PathGradient.InterpolationColors = Blend
  514.                 g.FillPath(PathGradient, gp)
  515.             Case GradientAlignment.Horizontal
  516.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black)
  517.                 Blend.Positions = {0, 1 / 2, 1}
  518.                 Blend.Colors = {Col1, Col2, Col1}
  519.                 PathGradient.InterpolationColors = Blend
  520.                 PathGradient.RotateTransform(0)
  521.                 g.FillPath(PathGradient, gp)
  522.         End Select
  523.         g.SmoothingMode = stored
  524.     End Sub
  525.     Public Sub DrawShadowPath(ByVal G As Graphics, ByVal ColBlend As ColorBlend, ByVal Path As GraphicsPath)
  526.         Using ShadowBrush As PathGradientBrush = New PathGradientBrush(Path)
  527.             ShadowBrush.InterpolationColors = ColBlend
  528.             G.FillPath(ShadowBrush, Path)
  529.         End Using
  530.     End Sub
  531.     Public Sub DrawShadowEllipse(ByVal G As Graphics, ByVal col As Color, ByVal Path As Rectangle)
  532.         Dim GPath As New GraphicsPath()
  533.         GPath.AddEllipse(Path)
  534.         Dim PathGradBrush As New PathGradientBrush(GPath)
  535.         With PathGradBrush
  536.             .CenterPoint = New PointF(Path.X + Path.Width / 2, Path.Y + Path.Height / 2)
  537.             .CenterColor = col
  538.             .SurroundColors = New Color() {Color.Transparent}
  539.             .SetBlendTriangularShape(0.1F, 1.0F)
  540.             .FocusScales = New PointF(0.0F, 0.0F)
  541.         End With
  542.         G.FillPath(PathGradBrush, GPath)
  543.     End Sub
  544.     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)
  545.         DrawText(G, New Rectangle(ContRect.X + 1, ContRect.Y + 2, ContRect.Width + 1, ContRect.Height + 2), Text, TFont, TAlign, BColor)
  546.         DrawText(G, ContRect, Text, TFont, TAlign, TColor)
  547.     End Sub
  548.     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)
  549.         If String.IsNullOrEmpty(Text) Then Return
  550.         Dim TextSize As Size = G.MeasureString(Text, TFont).ToSize
  551.         Dim CenteredY As Integer = ContRect.Height \ 2 - TextSize.Height \ 2
  552.         Select Case TAlign
  553.             Case HorizontalAlignment.Left
  554.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X, CenteredY)
  555.             Case HorizontalAlignment.Right
  556.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X + ContRect.Width - TextSize.Width - 5, CenteredY)
  557.             Case HorizontalAlignment.Center
  558.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X + 4 + ContRect.Width \ 2 - TextSize.Width \ 2, CenteredY)
  559.         End Select
  560.     End Sub
  561.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  562.         Dim Path As New GraphicsPath
  563.         Dim ArcRectangleWidth As Integer = Curve * 2
  564.         With Path
  565.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  566.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  567.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  568.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  569.             .AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  570.         End With
  571.         Return Path
  572.     End Function
  573.     Public Function RoundedTopRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  574.         Dim Path As GraphicsPath = New GraphicsPath()
  575.         Dim ArcRectangleWidth As Integer = Curve * 2
  576.         With Path
  577.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  578.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  579.             .AddLine(New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height))
  580.             .AddLine(New Point(Rectangle.X, Rectangle.Height + Rectangle.Y), New Point(Rectangle.X, Rectangle.Y + Curve))
  581.         End With
  582.         Return Path
  583.     End Function
  584. End Class
  585. #End Region
Advertisement
Add Comment
Please, Sign In to add comment