
' リスト5：DrawTextのカスタムプロパティ
Private mSF As New StringFormat
Private mTextAlign As ContentAlignment
Private mMultiLine As Boolean
Private mMutilLineText() As String
Private mAngle As Single
Private mTabStopValue As Single
Private mMyRect As Rectangle
Private mDrawPoint As Point

Public Sub New()
    MyBase.New()

    Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
    Me.BackColor = Color.Transparent

    Me.Size = New Size(75, 23)
    Me.Text = Me.ToString
    Me.TextAlign = ContentAlignment.MiddleCenter
    Me.ResizeRedraw = True
    mAngle = 0
    mDrawPoint = New Point(0, 0)
End Sub

<Category("DotNetMagazine")> _
Public Property DrawPoint() As Point
    Get
        Return mDrawPoint
    End Get
    Set(ByVal Value As Point)
        mDrawPoint = Value
        Me.Invalidate()
    End Set
End Property

<Category("DotNetMagazine")> _
Public Property TabStopValue() As Single
    Get
        Return mTabStopValue
    End Get
    Set(ByVal Value As Single)
        mTabStopValue = Value
        Me.Invalidate()
    End Set
End Property

<Category("DotNetMagazine"), _
TypeConverter(GetType(MyRectConverter))> _
Public Property MyRect() As Rectangle
    Get
       Return mMyRect
    End Get
    Set(ByVal Value As Rectangle)
        mMyRect = Value
        Me.Invalidate()
    End Set
End Property

<Category("DotNetMagazine")> _
Public Property Angle() As Single
    Get
        Return mAngle
    End Get
    Set(ByVal Value As Single)
        mAngle = Value
        Me.Invalidate()
    End Set
End Property

<Category("DotNetMagazine")> _
Public Property TextAlign() As ContentAlignment
    Get
        Return mTextAlign
    End Get
    Set(ByVal Value As ContentAlignment)
        mTextAlign = Value
        Me.Invalidate()
    End Set
End Property