Last active
December 2, 2016 17:04
-
-
Save Azahet/a86e1cd3043a1ab619769280fa77d92f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Sidewinder Theme | |
'Made by Azahet | |
'Base by AeroRev9 | |
Imports System.ComponentModel | |
Imports System.Drawing.Drawing2D | |
Imports System.Drawing.Text | |
Public Module Helpers | |
Enum RoundingStyle As Byte | |
All = 0 | |
Top = 1 | |
Bottom = 2 | |
Left = 3 | |
Right = 4 | |
TopRight = 5 | |
BottomRight = 6 | |
End Enum | |
Public Function FullRectangle(S As Size, Subtract As Boolean) As Rectangle | |
If Subtract Then | |
Return New Rectangle(0, 0, S.Width - 1, S.Height - 1) | |
Else | |
Return New Rectangle(0, 0, S.Width, S.Height) | |
End If | |
End Function | |
Public Sub CenterString(G As Graphics, T As String, F As Font, C As Color, R As Rectangle) | |
Dim TS As SizeF = G.MeasureString(T, F) | |
Using B As New SolidBrush(C) | |
G.DrawString(T, F, B, New Point(R.Width / 2 - (TS.Width / 2), R.Height / 2 - (TS.Height / 2))) | |
End Using | |
End Sub | |
Public Sub CenterStringWidth(G As Graphics, T As String, F As Font, C As Color, R As Rectangle) | |
Dim TS As SizeF = G.MeasureString(T, F) | |
Using B As New SolidBrush(C) | |
G.DrawString(T, F, B, New Point(R.Width / 2 - (TS.Width / 2), (50 - TS.Height) / 2)) | |
End Using | |
End Sub | |
Public Function RoundRect(ByVal Rect As Rectangle, ByVal Rounding As Integer, Optional ByVal Style As RoundingStyle = RoundingStyle.All) As Drawing2D.GraphicsPath | |
Dim GP As New Drawing2D.GraphicsPath() | |
Dim AW As Integer = Rounding * 2 | |
GP.StartFigure() | |
If Rounding = 0 Then | |
GP.AddRectangle(Rect) | |
GP.CloseAllFigures() | |
Return GP | |
End If | |
Select Case Style | |
Case RoundingStyle.All | |
GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90) | |
GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90) | |
Case RoundingStyle.Top | |
GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90) | |
GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height)) | |
Case RoundingStyle.Bottom | |
GP.AddLine(New Point(Rect.X, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y)) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90) | |
GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90) | |
Case RoundingStyle.Left | |
GP.AddArc(New Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90) | |
GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height)) | |
GP.AddArc(New Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90) | |
Case RoundingStyle.Right | |
GP.AddLine(New Point(Rect.X, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y)) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90) | |
Case RoundingStyle.TopRight | |
GP.AddLine(New Point(Rect.X, Rect.Y + 1), New Point(Rect.X, Rect.Y)) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90) | |
GP.AddLine(New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height - 1), New Point(Rect.X + Rect.Width, Rect.Y + Rect.Height)) | |
GP.AddLine(New Point(Rect.X + 1, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height)) | |
Case RoundingStyle.BottomRight | |
GP.AddLine(New Point(Rect.X, Rect.Y + 1), New Point(Rect.X, Rect.Y)) | |
GP.AddLine(New Point(Rect.X + Rect.Width - 1, Rect.Y), New Point(Rect.X + Rect.Width, Rect.Y)) | |
GP.AddArc(New Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90) | |
GP.AddLine(New Point(Rect.X + 1, Rect.Y + Rect.Height), New Point(Rect.X, Rect.Y + Rect.Height)) | |
End Select | |
GP.CloseAllFigures() | |
Return GP | |
End Function | |
Public Sub DrawRoundRect(G As Graphics, R As Rectangle, Curve As Integer, C As Color) | |
Using P As New Pen(C) | |
G.DrawArc(P, R.X, R.Y, Curve, Curve, 180, 90) | |
G.DrawLine(P, CInt(R.X + Curve / 2), R.Y, CInt(R.X + R.Width - Curve / 2), R.Y) | |
G.DrawArc(P, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90) | |
G.DrawLine(P, R.X, CInt(R.Y + Curve / 2), R.X, CInt(R.Y + R.Height - Curve / 2)) | |
G.DrawLine(P, CInt(R.X + R.Width), CInt(R.Y + Curve / 2), CInt(R.X + R.Width), CInt(R.Y + R.Height - Curve / 2)) | |
G.DrawLine(P, CInt(R.X + Curve / 2), CInt(R.Y + R.Height), CInt(R.X + R.Width - Curve / 2), CInt(R.Y + R.Height)) | |
G.DrawArc(P, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90) | |
G.DrawArc(P, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90) | |
End Using | |
End Sub | |
End Module | |
Public Class SpotifyForm | |
Inherits ContainerControl | |
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) | |
Dim G As Graphics = e.Graphics | |
G.FillRectangle(New SolidBrush(Color.FromArgb(18, 18, 18)), New Rectangle(0, 0, Me.Width, 50)) | |
Dim TextHeight As Single = G.MeasureString(NewText, New Font("Segoe UI", 9)).Height | |
Dim TextWhidth As Single = G.MeasureString(NewText, New Font("Segoe UI", 9)).Width | |
CenterStringWidth(G, NewText, New Font("Segoe UI", 9), Color.White, New Rectangle(0, 0, Width, Height)) | |
MyBase.OnPaint(e) | |
G.Dispose() | |
End Sub | |
Protected Overrides Sub OnResize(ByVal e As System.EventArgs) | |
Me.Invalidate() | |
MyBase.OnResize(e) | |
End Sub | |
Private MousePoint As New Point(0, 0) | |
Private IsDown As Boolean = False | |
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) | |
MyBase.OnMouseDown(e) | |
If e.Button = System.Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, 50).Contains(e.Location) Then | |
IsDown = True | |
MousePoint = e.Location | |
End If | |
End Sub | |
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) | |
MyBase.OnMouseUp(e) | |
IsDown = False | |
End Sub | |
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) | |
MyBase.OnMouseMove(e) | |
If IsDown Then | |
Me.Parent.Location = MousePosition - MousePoint | |
End If | |
End Sub | |
Protected Overrides Sub OnCreateControl() | |
MyBase.OnCreateControl() | |
Me.ParentForm.FormBorderStyle = FormBorderStyle.None | |
Me.ParentForm.AllowTransparency = False | |
Me.ParentForm.TransparencyKey = Color.Fuchsia | |
Me.ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen | |
Me.Dock = DockStyle.Fill | |
Me.Invalidate() | |
Me.BackColor = Color.FromArgb(18, 18, 18) | |
Me.Text = "Spotify Theme" | |
End Sub | |
Dim NewText As String | |
Overrides Property Text As String | |
Get | |
Return MyBase.Text | |
End Get | |
Set(ByVal value As String) | |
MyBase.Text = value | |
NewText = value | |
Me.Invalidate() | |
End Set | |
End Property | |
End Class | |
Public Class SpotifyTextBox | |
Inherits Control | |
Enum MouseState As Byte | |
None = 0 | |
Over = 1 | |
Down = 2 | |
End Enum | |
Private WithEvents TB As New TextBox | |
Private G As Graphics | |
Private State As MouseState | |
Private IsDown As Boolean | |
Protected Overrides Sub OnTextChanged(ByVal e As EventArgs) | |
MyBase.OnTextChanged(e) | |
Invalidate() | |
End Sub | |
Protected Overrides Sub OnGotFocus(ByVal e As EventArgs) | |
MyBase.OnGotFocus(e) | |
TB.Focus() | |
End Sub | |
Private Sub TextChangeTb() Handles TB.TextChanged | |
Text = TB.Text | |
End Sub | |
Private Sub TextChng() Handles MyBase.TextChanged | |
TB.Text = Text | |
End Sub | |
Public Sub NewTextBox() | |
With TB | |
.Text = String.Empty | |
.BackColor = Color.White | |
.ForeColor = Color.FromArgb(40, 40, 40) | |
.TextAlign = HorizontalAlignment.Left | |
.BorderStyle = BorderStyle.None | |
.Location = New Point(3, 3) | |
.Font = New Font("Segoe UI", 9) | |
.Size = New Size(Width - 3, Height - 3) | |
End With | |
End Sub | |
Sub New() | |
MyBase.New() | |
NewTextBox() | |
Controls.Add(TB) | |
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True) | |
DoubleBuffered = True | |
ForeColor = Color.FromArgb(40, 40, 40) | |
Font = New Font("Segoe UI", 9) | |
Size = New Size(130, 29) | |
Enabled = True | |
End Sub | |
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) | |
G = e.Graphics | |
G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality | |
G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit | |
MyBase.OnPaint(e) | |
G.Clear(Color.FromArgb(18, 18, 18)) | |
G.FillPath(New SolidBrush(Color.White), RoundRect(FullRectangle(Size, True), 12)) | |
TB.ForeColor = Color.FromArgb(40, 40, 40) | |
End Sub | |
Protected Overrides Sub OnResize(e As EventArgs) | |
Dim tbheight As Integer = TB.Height | |
TB.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer)) | |
TB.Size = New Size(Width - 20, tbheight) | |
End Sub | |
Protected Overrides Sub OnEnter(e As EventArgs) | |
MyBase.OnEnter(e) | |
State = MouseState.Down : Invalidate() | |
End Sub | |
Protected Overrides Sub OnLeave(e As EventArgs) | |
MyBase.OnLeave(e) | |
State = MouseState.None : Invalidate() | |
End Sub | |
End Class | |
Public Class SpotifyTab | |
Inherits TabControl | |
#Region " Drawing " | |
Private G As Graphics | |
Private Rect As Rectangle | |
Private LastIndex As Integer | |
Private _Index As Integer = -1 | |
Private Property Index As Integer | |
Get | |
Return _Index | |
End Get | |
Set(value As Integer) | |
_Index = value | |
Invalidate() | |
End Set | |
End Property | |
Sub New() | |
DoubleBuffered = True | |
ItemSize = New Size(40, 170) | |
Alignment = TabAlignment.Left | |
End Sub | |
Protected Overrides Sub OnControlAdded(e As ControlEventArgs) | |
MyBase.OnControlAdded(e) | |
e.Control.BackColor = Color.FromArgb(24, 24, 24) | |
e.Control.ForeColor = Color.FromArgb(72, 75, 82) | |
e.Control.Font = New Font("Segoe UI", 10) | |
SizeMode = TabSizeMode.Fixed | |
End Sub | |
Protected Overrides Sub OnCreateControl() | |
MyBase.OnCreateControl() | |
SetStyle(ControlStyles.UserPaint, True) | |
End Sub | |
Protected Overrides Sub OnPaint(e As PaintEventArgs) | |
G = e.Graphics | |
G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality | |
G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit | |
MyBase.OnPaint(e) | |
G.Clear(Color.FromArgb(18, 18, 18)) | |
For i As Integer = 0 To TabPages.Count - 1 | |
Rect = GetTabRect(i) | |
If String.IsNullOrEmpty(TabPages(i).Tag) Then | |
If SelectedIndex = i Then | |
Using B As New SolidBrush(Color.FromArgb(30, 214, 96)) | |
G.FillRectangle(B, New Rectangle(Rect.X - 2, Rect.Y + 10, 7, 20)) | |
End Using | |
Using B As New SolidBrush(Color.White) | |
G.DrawString(TabPages(i).Text, New Font("Segoe UI", 10), B, New Point(Rect.X + 55, Rect.Y + 12)) | |
End Using | |
Else | |
Using B As New SolidBrush(Color.FromArgb(18, 18, 18)) | |
G.FillRectangle(B, Rect) | |
End Using | |
Using B As New SolidBrush(Color.FromArgb(144, 144, 144)) | |
G.DrawString(TabPages(i).Text, New Font("Segoe UI", 10), B, New Point(Rect.X + 55, Rect.Y + 12)) | |
End Using | |
End If | |
Else | |
Using B As New SolidBrush(Color.FromArgb(158, 160, 157)) | |
G.DrawString(TabPages(i).Text.ToUpper, New Font("Segoe UI semibold", 9), B, New Point(Rect.X + 25, Rect.Y + 18)) | |
End Using | |
End If | |
Next | |
End Sub | |
Protected Overrides Sub OnSelecting(e As TabControlCancelEventArgs) | |
MyBase.OnSelecting(e) | |
If Not IsNothing(e.TabPage) Then | |
If Not String.IsNullOrEmpty(e.TabPage.Tag) Then | |
e.Cancel = True | |
Else | |
Index = -1 | |
End If | |
End If | |
End Sub | |
Protected Overrides Sub OnMouseMove(e As MouseEventArgs) | |
MyBase.OnMouseMove(e) | |
For i As Integer = 0 To TabPages.Count - 1 | |
If GetTabRect(i).Contains(e.Location) And Not SelectedIndex = i And String.IsNullOrEmpty(TabPages(i).Tag) Then | |
Index = i | |
Exit For | |
End If | |
Next | |
End Sub | |
Protected Overrides Sub OnMouseLeave(e As EventArgs) | |
MyBase.OnMouseLeave(e) | |
Index = -1 | |
End Sub | |
#End Region | |
End Class | |
Public Class SpotifyButton1 | |
Inherits Control | |
Enum MouseState As Byte | |
None = 0 | |
Over = 1 | |
Down = 2 | |
End Enum | |
Private G As Graphics | |
Private State As MouseState | |
Public Shadows Event Click(sender As Object, e As EventArgs) | |
Sub New() | |
DoubleBuffered = True | |
Enabled = True | |
End Sub | |
Protected Overrides Sub OnPaint(e As PaintEventArgs) | |
G = e.Graphics | |
G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality | |
G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit | |
MyBase.OnPaint(e) | |
If Enabled Then | |
Select Case State | |
Case MouseState.Over | |
Using Border As New Pen(Color.White) | |
G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 12)) | |
End Using | |
Case Else | |
Using Border As New Pen(Color.Gray) | |
G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 12)) | |
End Using | |
End Select | |
Using ButtonFont As New Font("Segoe UI", 9), Border As New Pen(ColorFromHex("#C3C3C3")) | |
G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 12)) | |
CenterString(G, Text, ButtonFont, ColorFromHex("#7C858E"), FullRectangle(Size, False)) | |
End Using | |
Else | |
Using Background As New SolidBrush(ColorFromHex("#F3F4F7")), Border As New Pen(ColorFromHex("#DCDCDC")), ButtonFont As New Font("Segoe UI", 9) | |
G.FillPath(Background, RoundRect(FullRectangle(Size, True), 12)) | |
G.DrawPath(Border, RoundRect(FullRectangle(Size, True), 12)) | |
CenterString(G, Text, ButtonFont, ColorFromHex("#D0D3D7"), FullRectangle(Size, False)) | |
End Using | |
End If | |
End Sub | |
Protected Overrides Sub OnMouseEnter(e As EventArgs) | |
MyBase.OnMouseEnter(e) | |
State = MouseState.Over : Invalidate() | |
End Sub | |
Protected Overrides Sub OnMouseLeave(e As EventArgs) | |
MyBase.OnMouseLeave(e) | |
State = MouseState.None : Invalidate() | |
End Sub | |
Protected Overrides Sub OnMouseUp(e As MouseEventArgs) | |
MyBase.OnMouseUp(e) | |
If Enabled Then | |
RaiseEvent Click(Me, e) | |
End If | |
State = MouseState.Over : Invalidate() | |
End Sub | |
Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
MyBase.OnMouseDown(e) | |
State = MouseState.Down : Invalidate() | |
End Sub | |
End Class | |
Public Class SpotifyButton2 | |
Inherits Control | |
Enum MouseState As Byte | |
None = 0 | |
Over = 1 | |
Down = 2 | |
End Enum | |
Private G As Graphics | |
Private State As MouseState | |
Public Shadows Event Click(sender As Object, e As EventArgs) | |
Sub New() | |
DoubleBuffered = True | |
Enabled = True | |
End Sub | |
Protected Overrides Sub OnPaint(e As PaintEventArgs) | |
G = e.Graphics | |
G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality | |
G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit | |
MyBase.OnPaint(e) | |
Select Case State | |
Case MouseState.Over | |
G.FillPath(New SolidBrush(Color.White), RoundRect(FullRectangle(Size, True), Height / 2)) | |
Case Else | |
G.FillPath(New SolidBrush(Color.FromArgb(27, 216, 94)), RoundRect(FullRectangle(Size, True), Height / 2)) | |
End Select | |
Using ButtonFont As New Font("Segoe UI", 9, FontStyle.Bold), Border As New Pen(ColorFromHex("#C3C3C3")) | |
CenterString(G, Text.ToUpper, ButtonFont, Color.White, FullRectangle(Size, False)) | |
End Using | |
End Sub | |
Protected Overrides Sub OnMouseEnter(e As EventArgs) | |
MyBase.OnMouseEnter(e) | |
State = MouseState.Over : Invalidate() | |
End Sub | |
Protected Overrides Sub OnMouseLeave(e As EventArgs) | |
MyBase.OnMouseLeave(e) | |
State = MouseState.None : Invalidate() | |
End Sub | |
Protected Overrides Sub OnMouseUp(e As MouseEventArgs) | |
MyBase.OnMouseUp(e) | |
If Enabled Then | |
RaiseEvent Click(Me, e) | |
End If | |
State = MouseState.Over : Invalidate() | |
End Sub | |
Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
MyBase.OnMouseDown(e) | |
State = MouseState.Down : Invalidate() | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment