Hi
I'm trying to convert http://www.codeproject.com/KB/tabs/tabstrips.aspx[^] to vb.net, but have encountered a few problems.. There's 8 errors that i just can't figure out how to deal with, so maybe some of you can solve it.. Here's the code (the errors at bottom):
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms.VisualStyles
Imports VisualStyles = System.Windows.Forms.VisualStyles
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Collections
Imports System.Windows.Forms.Design
Namespace Messir.Windows.Forms
Public Class SelectedTabChangedEventArgs
Inherits EventArgs
Public SelectedTab As TabStripButton
Public Sub SelectedTabChangedEventArgs(ByVal tab As TabStripButton)
SelectedTab = tab
End Sub
End Class
''' <summary>
''' Represents a TabStrip control
''' </summary>
Public Class TabStrip
Inherits ToolStrip
Private myRenderer As New TabStripRenderer()
Protected mySelTab As TabStripButton
Dim insPage As DesignerVerb = Nothing
Public Sub TabStrip()
'MyBase.new()
InitControl()
End Sub
Public Sub New(ByVal ParamArray buttons() As TabStripButton)
MyBase.New(buttons)
InitControl()
End Sub
Protected Sub InitControl()
MyBase.RenderMode = ToolStripRenderMode.ManagerRenderMode
MyBase.Renderer = myRenderer
myRenderer.RenderMode = Me.RenderStyle
insPage = New DesignerVerb("Insert tab page", New EventHandler(AddressOf OnInsertPageClicked))
End Sub
Public Overrides Property Site() As ISite
Get
Dim curSite As ISite = MyBase.Site
If ((Not (curSite) Is Nothing) _
AndAlso curSite.DesignMode) Then
Dim comp As IContainer = curSite.Container
If (Not (comp) Is Nothing) Then
Dim host As IDesignerHost = CType(comp, IDesignerHost)
If (Not (host) Is Nothing) Then
Dim designer As IDesigner = host.GetDesigner(curSite.Component)
If ((Not (designer) Is Nothing) _
AndAlso Not designer.Verbs.Contains(insPage)) Then
designer.Verbs.Add(insPage)
End If
End If
End If
End If
Return curSite
End Get
Set(ByVal value As ISite)
MyBase.Site = value
End Set
End Property
Protected Sub OnInsertPageClicked(ByVal sender As Object, ByVal e As EventArgs)
Dim site As ISite = MyBase.Site
If Not site Is Nothing And site.DesignMode Then
Dim container As IContainer = site.Container
If Not container Is Nothing Then
Dim btn As TabStripButton = New TabStripButton()
container.Add(btn)
btn.Text = btn.Name
End If
End If
End Sub
''' <summary>
''' Gets custom renderer for TabStrip. Set operation has no effect
''' </summary>
Public Shadows Property Renderer() As ToolStripRenderer
Get
Return myRenderer
End Get
Set(ByVal value As ToolStripRenderer)
MyBase.Renderer = myRenderer
End Set
End Property
''' <summary>
''' Gets or sets layout style for TabStrip control
''' </summary>
Public Shadows Property LayoutStyle() As ToolStripLayoutStyle
Get
Return MyBase.LayoutStyle
End Get
Set(ByVal value As ToolStripLayoutStyle)
Select Case (value)
Case ToolStripLayoutStyle.StackWithOverflow, ToolStripLayoutStyle.HorizontalStackWithOverflow, ToolStripLayoutStyle.VerticalStackWithOverflow
MyBase.LayoutStyle = ToolStripLayoutStyle.StackWithOverflow
Case ToolStripLayoutStyle.Table
MyBase.LayoutStyle = ToolStripLayoutStyle.Table
Case ToolStripLayoutStyle.Flow
MyBase.LayoutStyle = ToolStripLayoutStyle.Flow
Case Else
MyBase.LayoutStyle = ToolStripLayoutStyle.StackWithOverflow
End Select
End Set
End Property
''' <summary>
'''
''' </summary>
<Obsolete("Use RenderStyle instead"), _
Browsable(False)> _
Public Shadows Property RenderMode() As ToolStripRenderMode
Get
Return MyBase.RenderMode
End Get
Set(ByVal value As ToolStripRenderMode)
RenderStyle = value
End Set
End Property
''' <summary>
''' Gets or sets render style for TabStrip, use it instead of
''' </summary>
<Category("Appearance"), _
Description("Gets or sets render style for TabStrip. You should use this property instead of RenderMode.")> _
Public Property RenderStyle() As ToolStripRenderMode
Get
Return myRenderer.RenderMode
End Get
Set(ByVal value As ToolStripRenderMode)
myRenderer.RenderMode = value
Me.Invalidate()
End Set
End Property
Protected Overrides ReadOnly Property DefaultPadding() As Padding
Get
Return Padding.Empty
End Get
End Property
<Browsable(False)> _
Public Shadows Property Padding() As Padding
Get
Return DefaultPadding
End Get
Set(ByVal value As Padding)
End Set
End Property
''' <summary>
''' Gets or sets if control should use system visual styles for painting items
''' </summary>
<Category("Appearance"), _
Description("Specifies if TabStrip should use system visual styles for painting items")> _
Public Property UseVisualStyles() As Boolean
Get
Return myRenderer.UseVS
End Get
Set(ByVal value As Boolean)
myRenderer.UseVS = value
Me.Invalidate()
End Set
End Property
''' <summary>
''' Gets or sets if TabButtons should be drawn flipped
''' </summary>
<Category("Appearance"), _
Description("Specifies if TabButtons should be drawn flipped (for right- and bottom-aligned TabStrips)")> _
Public Property FlipButtons() As Boolean
Get
Return myRenderer.Mirrored
End Get
Set(ByVal value As Boolean)
myRenderer.Mirrored = value
Me.Invalidate()
End Set
End Property
''' <summary>
''' Gets or sets currently selected tab
''' </summary>
Public Property SelectedTab() As TabStripButton
Get
Return mySelTab
End Get
Set(ByVal value As TabStripButton)
If (value Is Nothing) Then
Return
End If
If mySelTab = value Then
Return
End If
If (value.Owner <> Me) Then
Throw New ArgumentException("Cannot select TabButtons that do not belong to this TabStrip")
End If
OnItemClicked(New ToolStripItemClickedEventArgs(value))
End Set
End Property
Public Event SelectedTabChanged As EventHandler
Protected Sub OnTabSelected(ByVal tab As TabStripButton)
Me.Invalidate()
If Not SelectedTabChanged Is Nothing Then SelectedTabChanged(Me, New SelectedTabChangedEventArgs(tab))
End Sub
Protected Overrides Sub OnItemAdded(ByVal e As ToolStripItemEventArgs)
MyBase.OnItemAdded(e)
If (TypeOf e.Item Is TabStripButton) Then
SelectedTab = CType(e.Item, TabStripButton)
End If
End Sub
Protected Overrides Sub OnItemClicked(ByVal e As ToolStripItemClickedEventArgs)
Dim clickedBtn As TabStripButton = CType(e.ClickedItem, TabStripButton)
If (Not (clickedBtn) Is Nothing) Then
Me.SuspendLayout()
mySelTab = clickedBtn
Me.ResumeLayout()
OnTabSelected(clickedBtn)
End If
MyBase.OnItemClicked(e)
End Sub
End Class
''' <summary>
''' Represents a renderer class for TabStrip control
''' </summary>
Class TabStripRenderer
Inherits ToolStripRenderer
Private Const selOffset As Integer = 2
Private currentRenderer As ToolStripRenderer = Nothing
Public renderMode As ToolStripRenderMode = ToolStripRenderMode.Custom
Public mirrored As Boolean = False
Public useVS As Boolean = Application.RenderWithVisualStyles
''' <summary>
'''Gets or sets render mode for this renderer
''' </summary>
Public Property RenderMode() As ToolStripRenderMode
Get
Return renderMode
End Get
Set(ByVal value As ToolStripRenderMode)
renderMode = value
Select renderMode
Case ToolStripRenderMode.Professional
currentRenderer = New ToolStripProfessionalRenderer()
Case ToolStripRenderMode.System
currentRenderer = New ToolStripSystemRenderer()
Case Else
currentRenderer = Nothing
End Select
End Set
End Property
''' <summary>
''' Gets or sets whether to mirror background
''' </summary>
''' <remarks>Use false for left and top positions, true for right and bottom</remarks>
Public Property Mirrored() As Boolean
Get
Return mirrored
End Get
Set(ByVal value As Boolean)
mirrored = value
End Set
End Property
''' <summary>
''' Returns if visual styles should be applied for drawing
''' </summary>
Public Property UseVS() As Boolean
Get
Return useVS
End Get
Set(ByVal value As Boolean)
If (value _
AndAlso Not Application.RenderWithVisualStyles) Then
Return
End If
useVS = value
End Set
End Property
Protected Overrides Sub Initialize(ByVal ts As ToolStrip)
MyBase.Initialize(ts)
End Sub
Protected Overrides Sub OnRenderToolStripBorder(ByVal e As ToolStripRenderEventArgs)
Dim c As Color = SystemColors.AppWorkspace
If (UseVS) Then
Dim rndr As VisualStyleRenderer = New VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal)
c = rndr.GetColor(ColorProperty.BorderColorHint)
End If
Dim p As Pen = New Pen(c)
Dim p2 As Pen = New Pen(e.BackColor)
Dim r As Rectangle = e.ToolStrip.Bounds
Dim x1 As Integer
Dim y1 As Integer
If mirrored = False Then x1 = 0 Else x1 = r.Width - 1 - e.ToolStrip.Padding.Horizontal
If mirrored = False Then y1 = 0 Else y1 = r.Height - 1
If (e.ToolStrip.Orientation = Orientation.Horizontal) Then
e.Graphics.DrawLine(p, 0, y1, r.Width, y1)
Else
e.Graphics.DrawLine(p, x1, 0, x1, r.Height)
If Not (mirrored) Then
Dim i As Integer = (x1 + 1)
Do While (i < r.Width)
e.Graphics.DrawLine(p2, i, 0, i, r.Height)
i = (i + 1)
Loop
End If
For Each x As ToolStripItem In e.ToolStrip.Items
If (x.IsOnOverflow) Then Continue For
'TabStripButton btn = x as TabStripButton;
Dim btn As TabStripButton = TryCast(x, TabStripButton)
If btn Is Nothing Then Continue For
Dim rc As Rectangle = btn.Bounds
Dim x2 As Integer
Dim y2 As Integer
If mirrored Then x2 = rc.Left Else x2 = rc.Right
If mirrored Then y2 = rc.Top Else y2 = rc.Bottom - 1
Dim addXY As Integer
If mirrored Then addXY = 0 Else addXY = 1
If e.ToolStrip.Orientation = Orientation.Horizontal Then
e.Graphics.DrawLine(p, rc.Left, y2, rc.Right, y2)
If (btn.Checked) Then e.Graphics.DrawLine(p2, rc.Left + 2 - addXY, y2, rc.Right - 2 - addXY, y2)
Else
e.Graphics.DrawLine(p, x2, rc.Top, x2, rc.Bottom)
If (btn.Checked) Then e.Graphics.DrawLine(p2, x2, rc.Top + 2 - addXY, x2, rc.Bottom - 2 - addXY)
End If
Next
End If
End Sub
Protected Overrides Sub OnRenderToolStripBackground(ByVal e As ToolStripRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawToolStripBackground(e) Else MyBase.OnRenderToolStripBackground(e)
End Sub
Protected Overrides Sub OnRenderButtonBackground(ByVal e As ToolStripItemRenderEventArgs)
Dim g As Graphics = e.Graphics
Dim tabs As TabStrip = CType(e.ToolStrip, TabStrip)
Dim tab As TabStripButton = CType(e.Item, TabStripButton)
If ((tabs Is Nothing) _
OrElse (tab Is Nothing)) Then
If (Not (currentRenderer) Is Nothing) Then
currentRenderer.DrawButtonBackground(e)
End If
Else
MyBase.OnRenderButtonBackground(e)
Return
End If
Dim selected As Boolean = tab.Checked
Dim hovered As Boolean = tab.Selected
Dim top As Integer = 0
Dim left As Integer = 0
Dim width As Integer = (tab.Bounds.Width - 1)
Dim height As Integer = (tab.Bounds.Height - 1)
Dim drawBorder As Rectangle
If (useVS) Then
If tabs.Orientation = Orientation.Horizontal Then
If Not selected Then
top = selOffset
height -= (selOffset - 1)
Else
top = 1
drawBorder = New Rectangle(0, 0, width, height)
End If
Else
If Not selected Then
left = selOffset
width -= (selOffset - 1)
Else
left = 1
drawBorder = New Rectangle(0, 0, height, width)
End If
End If
Dim b As Bitmap = New Bitmap(drawBorder.Width, drawBorder.Height)
Dim el As VisualStyleElement = VisualStyleElement.Tab.TabItem.Normal
If (selected) Then el = VisualStyleElement.Tab.TabItem.Pressed
If (hovered) Then el = VisualStyleElement.Tab.TabItem.Hot
If Not tab.Enabled Then el = VisualStyleElement.Tab.TabItem.Disabled
If Not selected Or hovered Then drawBorder.Width += 1 Else drawBorder.Height += 1
Dim gr As Graphics = Graphics.FromImage(b)
Dim rndr As VisualStyleRenderer = New VisualStyleRenderer(el)
rndr.DrawBackground(gr, drawBorder)
If tabs.Orientation = Orientation.Vertical Then
If (mirrored) Then
b.RotateFlip(RotateFlipType.Rotate270FlipXY)
Else
b.RotateFlip(RotateFlipType.Rotate270FlipNone)
End If
Else
If (mirrored) Then
b.RotateFlip(RotateFlipType.RotateNoneFlipY)
End If
If (mirrored) Then
left = tab.Bounds.Width - b.Width - left
top = tab.Bounds.Height - b.Height - top
End If
g.DrawImage(b, left, top)
End If
Else
If tabs.Orientation = Orientation.Horizontal Then
If Not selected Then
top = selOffset
height -= (selOffset - 1)
Else
top = 1
If (mirrored) Then
left = 1
top = 0
Else
top += 1
width -= 1
End If
End If
else
If Not selected Then
left = selOffset
width -= 1
Else
left = 1
If (mirrored) Then
left = 0
top = 1
End If
End If
height -= 1
drawBorder = New Rectangle(left, top, width, height)
Dim gp As GraphicsPath = New GraphicsPath()
If (mirrored And tabs.Orientation = Orientation.Horizontal) Then
gp.AddLine(drawBorder.Left, drawBorder.Top, drawBorder.Left, drawBorder.Bottom - 2)
gp.AddArc(drawBorder.Left, drawBorder.Bottom - 3, 2, 2, 90, 90)
gp.AddLine(drawBorder.Left + 2, drawBorder.Bottom, drawBorder.Right - 2, drawBorder.Bottom)
gp.AddArc(drawBorder.Right - 2, drawBorder.Bottom - 3, 2, 2, 0, 90)
gp.AddLine(drawBorder.Right, drawBorder.Bottom - 2, drawBorder.Right, drawBorder.Top)
ElseIf (Not mirrored And tabs.Orientation = Orientation.Horizontal) Then
gp.AddLine(drawBorder.Left, drawBorder.Bottom, drawBorder.Left, drawBorder.Top + 2)
gp.AddArc(drawBorder.Left, drawBorder.Top + 1, 2, 2, 180, 90)
gp.AddLine(drawBorder.Left + 2, drawBorder.Top, drawBorder.Right - 2, drawBorder.Top)
gp.AddArc(drawBorder.Right - 2, drawBorder.Top + 1, 2, 2, 270, 90)
gp.AddLine(drawBorder.Right, drawBorder.Top + 2, drawBorder.Right, drawBorder.Bottom)
ElseIf (mirrored And tabs.Orientation = Orientation.Vertical) Then
gp.AddLine(drawBorder.Left, drawBorder.Top, drawBorder.Right - 2, drawBorder.Top)
gp.AddArc(drawBorder.Right - 2, drawBorder.Top + 1, 2, 2, 270, 90)
gp.AddLine(drawBorder.Right, drawBorder.Top + 2, drawBorder.Right, drawBorder.Bottom - 2)
gp.AddArc(drawBorder.Right - 2, drawBorder.Bottom - 3, 2, 2, 0, 90)
gp.AddLine(drawBorder.Right - 2, drawBorder.Bottom, drawBorder.Left, drawBorder.Bottom)
Else
gp.AddLine(drawBorder.Right, drawBorder.Top, drawBorder.Left + 2, drawBorder.Top)
gp.AddArc(drawBorder.Left, drawBorder.Top + 1, 2, 2, 180, 90)
gp.AddLine(drawBorder.Left, drawBorder.Top + 2, drawBorder.Left, drawBorder.Bottom - 2)
gp.AddArc(drawBorder.Left, drawBorder.Bottom - 3, 2, 2, 90, 90)
gp.AddLine(drawBorder.Left + 2, drawBorder.Bottom, drawBorder.Right, drawBorder.Bottom)
End If
If (selected Or hovered) Then
Dim fill As Color
If (hovered) Then fill = Color.WhiteSmoke Else fill = Color.White
If (renderMode = ToolStripRenderMode.Professional) Then
If (hovered) Then fill = ProfessionalColors.ButtonCheckedGradientBegin Else fill = ProfessionalColors.ButtonCheckedGradientEnd
Dim br As LinearGradientBrush = New LinearGradientBrush(tab.ContentRectangle, fill, ProfessionalColors.ButtonCheckedGradientMiddle, LinearGradientMode.Vertical)
g.FillPath(br, gp)
Else
Dim br As SolidBrush = New SolidBrush(fill)
g.FillPath(br, gp)
End If
End If
'using (Pen p = new Pen((selected) ? ControlPaint.Dark(SystemColors.AppWorkspace) : SystemColors.AppWorkspace))
Dim p As Pen = New Pen(Color.Blue)
If selected Then p.Color = ControlPaint.Dark(SystemColors.AppWorkspace) Else p.Color = SystemColors.AppWorkspace
g.DrawPath(p, gp)
End If
End If
End Sub
Protected Overrides Sub OnRenderItemImage(ByVal e As ToolStripItemImageRenderEventArgs)
Dim rc As Rectangle = e.ImageRectangle
Dim btn As TabStripButton = CType(e.Item, TabStripButton)
If (Not (btn) Is Nothing) Then
'int delta = ((Mirrored) ? -1 : 1) * ((btn.Checked) ? 1 : selOffset);
Dim delta As Integer
Dim theOffset As Integer
If btn.checked = True Then theOffset = 1 Else theOffset = selOffset
If mirrored Then delta = -1 * theOffset Else delta = 1 * theOffset
If (e.ToolStrip.Orientation = Orientation.Horizontal) Then
'rc.Offset((Mirrored) ? 2 : 1, delta + ((Mirrored) ? 1 : 0));
If mirrored Then
rc.Offset(2, delta + 1)
Else
rc.Offset(1, delta)
End If
Else
rc.Offset(delta + 2, 0)
End If
Dim x As ToolStripItemImageRenderEventArgs = New ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, e.Image, rc)
If (Not currentRenderer Is Nothing) Then
currentRenderer.DrawItemImage(x)
Else
MyBase.OnRenderItemImage(x)
End If
End If
End Sub
Protected Overrides Sub OnRenderItemText(ByVal e As ToolStripItemTextRenderEventArgs)
Dim rc As Rectangle = e.TextRectangle
Dim btn As TabStripButton = CType(e.Item, TabStripButton)
Dim c As Color = e.TextColor
Dim f As Font = e.TextFont
If (Not (btn) Is Nothing) Then
'int delta = ((Mirrored) ? -1 : 1) * ((btn.Checked) ? 1 : selOffset);
Dim delta As Integer
Dim theOffset As Integer
If btn.checked = True Then theOffset = 1 Else theOffset = selOffset
If mirrored Then delta = -1 * theOffset Else delta = 1 * theOffset
If (e.ToolStrip.Orientation = Orientation.Horizontal) Then
'rc.Offset((Mirrored) ? 2 : 1, delta + ((Mirrored) ? 1 : -1));
If mirrored Then
rc.Offset(2, delta + 1)
Else
rc.Offset(1, delta - 1)
End If
Else
rc.Offset(delta + 2, 0)
If (btn.Selected) Then
c = btn.HotTextColor
ElseIf (btn.Checked) Then
c = btn.SelectedTextColor
End If
If (btn.Checked) Then
f = btn.SelectedFont
End If
Dim x As ToolStripItemTextRenderEventArgs = New ToolStripItemTextRenderEventArgs(e.Graphics, e.Item, e.Text, rc, c, f, e.TextFormat)
x.TextDirection = e.TextDirection
If Not currentRenderer Is Nothing Then
currentRenderer.DrawItemText(x)
Else
MyBase.OnRenderItemText(x)
End If
End If
End If
End Sub
Protected Overrides Sub OnRenderArrow(ByVal e As ToolStripArrowRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawArrow(e) Else MyBase.OnRenderArrow(e)
End Sub
Protected Overrides Sub OnRenderDropDownButtonBackground(ByVal e As ToolStripItemRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawDropDownButtonBackground(e) Else MyBase.OnRenderDropDownButtonBackground(e)
End Sub
Protected Overrides Sub OnRenderGrip(ByVal e As ToolStripGripRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawGrip(e) Else MyBase.OnRenderGrip(e)
End Sub
Protected Overrides Sub OnRenderImageMargin(ByVal e As ToolStripRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawImageMargin(e) Else MyBase.OnRenderImageMargin(e)
End Sub
Protected Overrides Sub OnRenderItemBackground(ByVal e As ToolStripItemRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawItemBackground(e) Else MyBase.OnRenderItemBackground(e)
End Sub
Protected Overrides Sub OnRenderItemCheck(ByVal e As ToolStripItemImageRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawItemCheck(e) Else MyBase.OnRenderItemCheck(e)
End Sub
Protected Overrides Sub OnRenderLabelBackground(ByVal e As ToolStripItemRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawLabelBackground(e) Else MyBase.OnRenderLabelBackground(e)
End Sub
Protected Overrides Sub OnRenderMenuItemBackground(ByVal e As ToolStripItemRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawMenuItemBackground(e) Else MyBase.OnRenderMenuItemBackground(e)
End Sub
Protected Overrides Sub OnRenderOverflowButtonBackground(ByVal e As ToolStripItemRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawOverflowButtonBackground(e) Else MyBase.OnRenderOverflowButtonBackground(e)
End Sub
Protected Overrides Sub OnRenderSeparator(ByVal e As ToolStripSeparatorRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawSeparator(e) Else MyBase.OnRenderSeparator(e)
End Sub
Protected Overrides Sub OnRenderSplitButtonBackground(ByVal e As ToolStripItemRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawSplitButton(e) Else MyBase.OnRenderSplitButtonBackground(e)
End Sub
Protected Overrides Sub OnRenderStatusStripSizingGrip(ByVal e As ToolStripRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawStatusStripSizingGrip(e) Else MyBase.OnRenderStatusStripSizingGrip(e)
End Sub
Protected Overrides Sub OnRenderToolStripContentPanelBackground(ByVal e As ToolStripContentPanelRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawToolStripContentPanelBackground(e) Else MyBase.OnRenderToolStripContentPanelBackground(e)
End Sub
Protected Overrides Sub OnRenderToolStripPanelBackground(ByVal e As ToolStripPanelRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawToolStripPanelBackground(e) Else MyBase.OnRenderToolStripPanelBackground(e)
End Sub
Protected Overrides Sub OnRenderToolStripStatusLabelBackground(ByVal e As ToolStripItemRenderEventArgs)
If (Not (currentRenderer) Is Nothing) Then currentRenderer.DrawToolStripStatusLabelBackground(e) Else MyBase.OnRenderToolStripStatusLabelBackground(e)
End Sub
End Class
''' <summary>
''' Represents a TabButton for TabStrip control
''' </summary>
<ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip)> _
Public Class TabStripButton
Inherits ToolStripButton
Public Sub New()
MyBase.New()
InitButton()
End Sub
Public Sub New(ByVal image As Image)
MyBase.New(image)
InitButton()
End Sub
Public Sub New(ByVal text As String)
MyBase.New(text)
InitButton()
End Sub
Public Sub New(ByVal text As String, ByVal image As Image)
MyBase.New(text, image)
InitButton()
End Sub
Public Sub New(ByVal Text As String, ByVal Image As Image, ByVal Handler As EventHandler)
MyBase.New(Text, Image, Handler)
InitButton()
End Sub
Public Sub New(ByVal Text As String, ByVal Image As Image, ByVal Handler As EventHandler, ByVal name As String)
MyBase.New(Text, Image, Handler, name)
InitButton()
End Sub
Private Sub InitButton()
m_SelectedFont = Me.Font
End Sub
Public Overrides Function GetPreferredSize(ByVal constrainingSize As Size) As Size
Dim sz As Size = MyBase.GetPreferredSize(constrainingSize)
If ((Not (Me.Owner) Is Nothing) _
AndAlso (Me.Owner.Orientation = Orientation.Vertical)) Then
sz.Width = (sz.Width + 3)
sz.Height = (sz.Height + 10)
End If
Return sz
End Function
Protected Overrides ReadOnly Property DefaultMargin() As Padding
Get
Return New Padding(0)
End Get
End Property
<Browsable(False)> _
Public Shadows Property Margin() As Padding
Get
Return MyBase.Margin
End Get
Set(ByVal value As Padding)
End Set
End Property
<Browsable(False)> _
Public Shadows Property Padding() As Padding
Get
Return MyBase.Padding
End Get
Set(ByVal value As Padding)
End Set
End Property
Dim m_HotTextColor As Color = Control.DefaultForeColor
Private m_SelectedTextColor As Color = Control.DefaultForeColor
<Category("Appearance"), _
Description("Text color when TabButton is highlighted")> _
Public Property HotTextColor() As Color
Get
Return m_HotTextColor
End Get
Set(ByVal value As Color)
m_HotTextColor = value
End Set
End Property
<Category("Appearance"), _
Description("Text color when TabButton is selected")> _
Public Property SelectedTextColor() As Color
Get
Return m_SelectedTextColor
End Get
Set(ByVal value As Color)
m_SelectedTextColor = value
End Set
End Property
Dim m_SelectedFont As Font
<Category("Appearance")> _
<Description("Font when TabButton is selected")> _
Public Property SelectedFont() As Font
Get
If m_SelectedFont Is Nothing Then m_SelectedFont = MyBase.Font
Return (m_SelectedFont)
End Get
Set(ByVal value As Font)
m_SelectedFont = value
End Set
End Property
<Browsable(False), _
DefaultValue(False)> _
Public Shadows Property Checked() As Boolean
Get
Return IsSelected
End Get
Set(ByVal value As Boolean)
End Set
End Property
''' <summary>
''' Gets or sets if this TabButton is currently selected
''' </summary>
<Browsable(False)> _
Public Property IsSelected() As Boolean
Get
Dim owner As TabStrip = CType(Me.Owner, TabStrip)
If (Not (owner) Is Nothing) Then
Return (Me = Me.Owner.SelectedTab)
End If
Return False
End Get
Set(ByVal value As Boolean)
If (value = False) Then
Return
End If
Dim owner As TabStrip = CType(Me.Owner, TabStrip)
If (owner Is Nothing) Then
Return
End If
owner.SelectedTab = Me
End Set
End Property
Protected Overrides Sub OnOwnerChanged(ByVal e As EventArgs)
If ((Not (Owner) Is Nothing) _
AndAlso Not (TypeOf Owner Is TabStrip)) Then
Throw New Exception(("Cannot add TabStripButton to " + Owner.GetType.Name))
End If
MyBase.OnOwnerChanged(e)
End Sub
End Class
End Namespace
And the errors:
Error 2 Operator '=' is not defined for types 'LuceneSearch.Messir.Windows.Forms.TabStripButton' and 'LuceneSearch.Messir.Windows.Forms.TabStripButton'. 207<br />
<br />
Error 3 Operator '<>' is not defined for types 'System.Windows.Forms.ToolStrip' and 'LuceneSearch.Messir.Windows.Forms.TabStrip'. 210<br />
<br />
Error 4 'Public Event SelectedTabChanged(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. 221<br />
<br />
Error 5 Too many arguments to 'Public Sub New()'. 221<br />
Error 6 'RenderMode' is already declared as 'Public renderMode As System.Windows.Forms.ToolStripRenderMode' in this class. 260<br />
Error 7 'Mirrored' is already declared as 'Public mirrored As Boolean' in this class. 281<br />
<br />
Error 8 'UseVS' is already declared as 'Public useVS As Boolean' in this class. 293<br />
<br />
Error 9 'SelectedTab' is not a member of 'System.Windows.Forms.ToolStrip'. 787
I really hope someone know's how to deal with this, because i'm very eager to use this control.
modified on Wednesday, February 27, 2008 1:07 PM
|