Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class SLCTabControl
- Inherits TabControl
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
- DoubleBuffered = True
- SizeMode = TabSizeMode.Fixed
- ItemSize = New Size(30, 120)
- End Sub
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Alignment = TabAlignment.Left
- End Sub
- Public Function Borderpts() As GraphicsPath
- Dim P As New GraphicsPath()
- Dim PS As New List(Of Point)
- PS.Add(New Point(0, 0))
- PS.Add(New Point(Width - 1, 0))
- PS.Add(New Point(Width - 1, Height - 1))
- PS.Add(New Point(0, Height - 1))
- P.AddPolygon(PS.ToArray())
- Return P
- End Function
- Public Function BorderptsInside() As GraphicsPath
- Dim P As New GraphicsPath()
- Dim PS As New List(Of Point)
- PS.Add(New Point(1, 1))
- PS.Add(New Point(122, 1))
- PS.Add(New Point(122, Height - 2))
- PS.Add(New Point(1, Height - 2))
- P.AddPolygon(PS.ToArray())
- Return P
- End Function
- Public Function BigBorder() As GraphicsPath
- Dim P As New GraphicsPath()
- Dim PS As New List(Of Point)
- PS.Add(New Point(50, 1))
- PS.Add(New Point(349, 50))
- PS.Add(New Point(349, 50))
- PS.Add(New Point(50, 349))
- P.AddPolygon(PS.ToArray())
- Return P
- End Function
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim b As New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- g.Clear(Color.FromArgb(40, 40, 40))
- Dim GP1 As GraphicsPath = Borderpts()
- g.DrawPath(New Pen(New SolidBrush(Color.FromArgb(20, 20, 20))), GP1)
- '// small border
- Dim tmp1 As GraphicsPath = BorderptsInside()
- Dim PB2 As PathGradientBrush
- PB2 = New PathGradientBrush(tmp1)
- PB2.CenterColor = Color.FromArgb(40, 40, 40)
- PB2.SurroundColors = {Color.FromArgb(50, 50, 50)}
- PB2.FocusScales = New PointF(0.9F, 0.9F)
- g.FillPath(PB2, tmp1)
- 'g.DrawPath(New Pen(New SolidBrush(Color.FromArgb(20, 20, 20))), tmp1)
- '// items
- For i = 0 To TabCount - 1
- Dim rec As Rectangle = GetTabRect(i)
- Dim rec2 As Rectangle = rec
- '//inside small
- rec2.Width -= 3
- rec2.Height -= 3
- rec2.Y += 1
- rec2.X += 1
- If i = SelectedIndex Then
- Dim linear As New LinearGradientBrush(New Rectangle(rec2.X + 108, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(60, 60, 60), Color.Transparent, 200.0F)
- Dim linear3 As New LinearGradientBrush(New Rectangle(rec2.X, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(60, 60, 60), Color.Transparent, 200.0F)
- g.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), rec2)
- g.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(60, 60, 60))), rec2)
- g.DrawRectangle(New Pen(Color.FromArgb(70, Color.FromArgb(60, 60, 60)), 2), rec)
- g.FillRectangle(linear, New Rectangle(rec2.X + 113, rec2.Y + 1, 6, rec2.Height - 1))
- g.FillRectangle(linear3, New Rectangle(rec2.X, rec2.Y + 1, 6, rec2.Height - 1))
- g.SmoothingMode = SmoothingMode.AntiAlias
- Dim GP2 As New GraphicsPath
- GP2.AddPolygon(New Point() {New Point(rec2.X - 4, rec2.Y + 23), New Point(rec2.X - 4, rec2.Y + 5), New Point(rec.X + 12, rec.Y + 15)})
- g.DrawPath(New Pen(New SolidBrush(Color.Black), 1), GP2)
- Dim GP3 As New GraphicsPath
- GP3.AddPolygon(New Point() {New Point(rec2.X - 3, rec2.Y + 21), New Point(rec2.X - 3, rec2.Y + 7), New Point(rec.X + 11, rec.Y + 15)})
- g.DrawPath(New Pen(New SolidBrush(Color.FromArgb(90, 90, 90)), 1), GP3)
- Dim GP4 As New GraphicsPath
- GP4.AddPolygon(New Point() {New Point(rec2.X + 119, rec2.Y + 22), New Point(rec2.X + 119, rec2.Y + 6), New Point(rec2.X + 105, rec2.Y + 15)})
- g.DrawPath(New Pen(New SolidBrush(Color.Black), 1), GP4)
- Dim GP5 As New GraphicsPath
- GP5.AddPolygon(New Point() {New Point(rec2.X + 119, rec2.Y + 21), New Point(rec2.X + 119, rec2.Y + 7), New Point(rec2.X + 106, rec2.Y + 15)})
- g.DrawPath(New Pen(New SolidBrush(Color.FromArgb(90, 90, 90)), 1), GP5)
- g.SmoothingMode = SmoothingMode.None
- Else
- g.SmoothingMode = SmoothingMode.HighQuality
- Dim linear As New LinearGradientBrush(New Rectangle(rec2.X + 108, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(60, 60, 60), Color.Transparent, 200.0F)
- Dim linear3 As New LinearGradientBrush(New Rectangle(rec2.X, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(60, 60, 60), Color.Transparent, 200.0F)
- g.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), rec2)
- g.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(60, 60, 60))), rec2)
- g.DrawRectangle(New Pen(Color.FromArgb(70, Color.FromArgb(60, 60, 60)), 2), rec)
- 'g.FillRectangle(linear, New Rectangle(rec2.X + 112, rec2.Y + 1, 6, rec2.Height - 1))
- 'g.FillRectangle(linear3, New Rectangle(rec2.X, rec2.Y + 1, 6, rec2.Height - 1))
- g.SmoothingMode = SmoothingMode.None
- End If
- g.DrawString(TabPages(i).Text, Font, New SolidBrush(Color.FromArgb(69, 202, 83)), rec, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Next
- e.Graphics.DrawImage(b.Clone, 0, 0)
- g.Dispose()
- b.Dispose()
- MyBase.OnPaint(e)
- End Sub
- Protected Overrides Sub OnControlAdded(ByVal e As ControlEventArgs)
- If TypeOf e.Control Is TabPage Then
- e.Control.BackColor = Color.FromArgb(40, 40, 40)
- End If
- MyBase.OnControlAdded(e)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment