30-12-15, 02:49 AM
#Region "SLCTabControl"
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.White)
'//Big square shadow
Dim GP1 As GraphicsPath = Borderpts()
g.DrawPath(Pens.LightGray, GP1)
'// small border
Dim tmp1 As GraphicsPath = BorderptsInside()
Dim PB2 As PathGradientBrush
PB2 = New PathGradientBrush(tmp1)
PB2.CenterColor = Color.FromArgb(250, 250, 250)
PB2.SurroundColors = {Color.FromArgb(237, 237, 237)}
PB2.FocusScales = New PointF(0.9F, 0.9F)
g.FillPath(PB2, tmp1)
g.DrawPath(Pens.Gray, 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(227, 227, 227), Color.Transparent, 180.0F)
Dim linear3 As New LinearGradientBrush(New Rectangle(rec2.X, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(227, 227, 227), Color.Transparent, 180.0F)
g.FillRectangle(New SolidBrush(Color.FromArgb(242, 242, 242)), rec2)
g.DrawRectangle(Pens.White, rec2)
g.DrawRectangle(New Pen(Color.FromArgb(70, Color.FromArgb(39, 93, 127)), 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))
'// circle
g.SmoothingMode = SmoothingMode.HighQuality
' g.DrawEllipse(New Pen(Color.FromArgb(200, 200, 200), 3), New Rectangle(rec2.X + 6.5, rec2.Y + 7, 14, 14))
' g.DrawEllipse(New Pen(Color.FromArgb(150, 150, 150), 1), New Rectangle(rec2.X + 6.5, rec2.Y + 7, 14, 14))
Dim GPF As New GraphicsPath
GPF.AddEllipse(New Rectangle(rec2.X + 8, rec2.Y + 8, 12, 12))
Dim PB3 As PathGradientBrush
PB3 = New PathGradientBrush(GPF)
PB3.CenterPoint = New Point(rec2.X - 10, rec2.Y - 10)
PB3.CenterColor = Color.FromArgb(56, 142, 196)
PB3.SurroundColors = {Color.FromArgb(64, 106, 140)}
PB3.FocusScales = New PointF(0.9F, 0.9F)
g.FillPath(PB3, GPF)
g.DrawPath(New Pen(Color.FromArgb(49, 63, 86)), GPF)
g.SetClip(GPF)
g.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.WhiteSmoke)), New Rectangle(rec2.X + 10.5, rec2.Y + 11, 6, 6))
g.ResetClip()
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(227, 227, 227), Color.Transparent, 180.0F)
Dim linear3 As New LinearGradientBrush(New Rectangle(rec2.X, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(227, 227, 227), Color.Transparent, 180.0F)
g.FillRectangle(New SolidBrush(Color.FromArgb(242, 242, 242)), rec2)
g.DrawRectangle(Pens.White, rec2)
g.DrawRectangle(New Pen(Color.FromArgb(70, Color.FromArgb(39, 93, 127)), 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.FillEllipse(Brushes.LightGray, New Rectangle(rec2.X + 8, rec2.Y + 8, 12, 12))
g.DrawEllipse(New Pen(Color.FromArgb(100, 100, 100), 1), New Rectangle(rec2.X + 8, rec2.Y + 8, 12, 12))
g.SmoothingMode = SmoothingMode.None
End If
If Me.RightToLeft = Windows.Forms.RightToLeft.Yes And Me.RightToLeftLayout = True Then
g.MultiplyTransform(New System.Drawing.Drawing2D.Matrix(-1, 0, 0, 1, rec.Width, 0))
g.DrawString(TabPages(i).Text, Font, New SolidBrush(Color.FromArgb(56, 106, 137)), rec, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
g.ResetTransform()
Else
g.DrawString(TabPages(i).Text, Font, New SolidBrush(Color.FromArgb(56, 106, 137)), rec, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End If
Next
e.Graphics.DrawImage(b.Clone, 0, 0)
g.Dispose()
b.Dispose()
MyBase.OnPaint(e)
End Sub
End Class
#End Region
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.White)
'//Big square shadow
Dim GP1 As GraphicsPath = Borderpts()
g.DrawPath(Pens.LightGray, GP1)
'// small border
Dim tmp1 As GraphicsPath = BorderptsInside()
Dim PB2 As PathGradientBrush
PB2 = New PathGradientBrush(tmp1)
PB2.CenterColor = Color.FromArgb(250, 250, 250)
PB2.SurroundColors = {Color.FromArgb(237, 237, 237)}
PB2.FocusScales = New PointF(0.9F, 0.9F)
g.FillPath(PB2, tmp1)
g.DrawPath(Pens.Gray, 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(227, 227, 227), Color.Transparent, 180.0F)
Dim linear3 As New LinearGradientBrush(New Rectangle(rec2.X, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(227, 227, 227), Color.Transparent, 180.0F)
g.FillRectangle(New SolidBrush(Color.FromArgb(242, 242, 242)), rec2)
g.DrawRectangle(Pens.White, rec2)
g.DrawRectangle(New Pen(Color.FromArgb(70, Color.FromArgb(39, 93, 127)), 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))
'// circle
g.SmoothingMode = SmoothingMode.HighQuality
' g.DrawEllipse(New Pen(Color.FromArgb(200, 200, 200), 3), New Rectangle(rec2.X + 6.5, rec2.Y + 7, 14, 14))
' g.DrawEllipse(New Pen(Color.FromArgb(150, 150, 150), 1), New Rectangle(rec2.X + 6.5, rec2.Y + 7, 14, 14))
Dim GPF As New GraphicsPath
GPF.AddEllipse(New Rectangle(rec2.X + 8, rec2.Y + 8, 12, 12))
Dim PB3 As PathGradientBrush
PB3 = New PathGradientBrush(GPF)
PB3.CenterPoint = New Point(rec2.X - 10, rec2.Y - 10)
PB3.CenterColor = Color.FromArgb(56, 142, 196)
PB3.SurroundColors = {Color.FromArgb(64, 106, 140)}
PB3.FocusScales = New PointF(0.9F, 0.9F)
g.FillPath(PB3, GPF)
g.DrawPath(New Pen(Color.FromArgb(49, 63, 86)), GPF)
g.SetClip(GPF)
g.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.WhiteSmoke)), New Rectangle(rec2.X + 10.5, rec2.Y + 11, 6, 6))
g.ResetClip()
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(227, 227, 227), Color.Transparent, 180.0F)
Dim linear3 As New LinearGradientBrush(New Rectangle(rec2.X, rec2.Y + 1, 10, rec2.Height - 1), Color.FromArgb(227, 227, 227), Color.Transparent, 180.0F)
g.FillRectangle(New SolidBrush(Color.FromArgb(242, 242, 242)), rec2)
g.DrawRectangle(Pens.White, rec2)
g.DrawRectangle(New Pen(Color.FromArgb(70, Color.FromArgb(39, 93, 127)), 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.FillEllipse(Brushes.LightGray, New Rectangle(rec2.X + 8, rec2.Y + 8, 12, 12))
g.DrawEllipse(New Pen(Color.FromArgb(100, 100, 100), 1), New Rectangle(rec2.X + 8, rec2.Y + 8, 12, 12))
g.SmoothingMode = SmoothingMode.None
End If
If Me.RightToLeft = Windows.Forms.RightToLeft.Yes And Me.RightToLeftLayout = True Then
g.MultiplyTransform(New System.Drawing.Drawing2D.Matrix(-1, 0, 0, 1, rec.Width, 0))
g.DrawString(TabPages(i).Text, Font, New SolidBrush(Color.FromArgb(56, 106, 137)), rec, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
g.ResetTransform()
Else
g.DrawString(TabPages(i).Text, Font, New SolidBrush(Color.FromArgb(56, 106, 137)), rec, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End If
Next
e.Graphics.DrawImage(b.Clone, 0, 0)
g.Dispose()
b.Dispose()
MyBase.OnPaint(e)
End Sub
End Class
#End Region
