Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class SideShow
- 'Creator: ibennz
- 'Version: 1.0 (sketch)
- Inherits Control
- Sub New()
- Size = New Size(120, 23)
- End Sub
- Private _items As New List(Of itemd)
- <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
- Public Property Items As itemd()
- Get
- Return _items.ToArray
- End Get
- Set(value As itemd())
- _items = New List(Of itemd)(value)
- End Set
- End Property
- Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.Clear(BackColor)
- G.SmoothingMode = SmoothingMode.HighQuality
- 'right arrow
- G.DrawLine(Pens.Red, New Point(Width - 9, 5), New Point(Width - 6, (Height / 2) - 1))
- G.DrawLine(Pens.Red, New Point(Width - 9, 15), New Point(Width - 6, (Height / 2) - 1))
- 'left arrow
- G.DrawLine(Pens.Red, New Point(9, 5), New Point(6, (Height / 2) - 1))
- G.DrawLine(Pens.Red, New Point(9, 15), New Point(6, (Height / 2) - 1))
- If Not (IsNothing(_items)) Then
- For Each i As itemd In _items
- Dim tData As String = GetItem(_indx).data
- Dim ms As Integer = G.MeasureString(tData, Font, Width, StringFormat.GenericTypographic).Width
- G.DrawString(tData, Font, Brushes.Black, New PointF((Width / 2) - (ms / 2), 5))
- Next
- End If
- Dim GP1 As GraphicsPath = RoundRec(New Rectangle(0, 0, Width - 1, Height - 1), 5)
- G.DrawPath(Pens.Red, GP1)
- MyBase.OnPaint(e)
- End Sub
- Private _indx As Integer = 0
- Protected Overrides Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs)
- If e.X <= 14 Then
- _indx -= 1
- End If
- If e.X >= 104 Then
- _indx += 1
- End If
- Invalidate()
- MyBase.OnMouseDown(e)
- End Sub
- Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
- Dim P As GraphicsPath = New GraphicsPath()
- Dim ArcRectangleWidth As Integer = Curve * 2
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
- P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
- Return P
- End Function
- Public Function GetItem(ByVal index As Integer) As itemd
- For Each i As itemd In _items
- If i.Index = index Then
- Return i
- End If
- Next
- If index >= _items.Count - 1 Then
- _indx = 0
- Return _items(0)
- Else
- _indx = _items.Count - 1
- End If
- Return _items(_indx)
- End Function
- Public Class itemd
- Private _data As String
- Public Property data() As String
- Get
- Return _data
- End Get
- Set(value As String)
- _data = value
- End Set
- End Property
- Public Overrides Function ToString() As String
- Return data
- End Function
- Private _index As Integer = 0
- Public Property Index() As Integer
- Get
- Return _index
- End Get
- Set(value As Integer)
- _index = value
- End Set
- End Property
- End Class
- End Class
Advertisement
Add Comment
Please, Sign In to add comment