Click here to Skip to main content
15,891,513 members
Articles / Desktop Programming / Windows Forms

Object-oriented Printing with Inka, Part 1

Rate me:
Please Sign up or sign in to vote.
4.00/5 (4 votes)
27 Feb 2009LGPL35 min read 34.4K   396   28  
The basics of Inka, an open source printing component
Namespace Elements
    Public Class LabelElement


        Inherits Core.Element
        Private _text As String
        Public Property Text() As String
            Get
                Return _text
            End Get
            Set(ByVal value As String)
                _text = value
            End Set
        End Property


        Private _fontName As String
        Public Property FontName() As String
            Get
                Return _fontName
            End Get
            Set(ByVal value As String)
                _fontName = value
            End Set
        End Property


        Private _fontSize As Single
        Public Property FontSize() As Single
            Get
                Return _fontSize
            End Get
            Set(ByVal value As Single)
                _fontSize = value
            End Set
        End Property


        Private _bold As Boolean
        Public Property Bold() As Boolean
            Get
                Return _bold
            End Get
            Set(ByVal value As Boolean)
                _bold = value
            End Set
        End Property


        Private _italic As Boolean
        Public Property Italic() As Boolean
            Get
                Return _italic
            End Get
            Set(ByVal value As Boolean)
                _italic = value
            End Set
        End Property


        Private _underline As Boolean
        Public Property Underline() As Boolean
            Get
                Return _underline
            End Get
            Set(ByVal value As Boolean)
                _underline = value
            End Set
        End Property


        Private _strikeout As Boolean
        Public Property Strikeout() As Boolean
            Get
                Return _strikeout
            End Get
            Set(ByVal value As Boolean)
                _strikeout = value
            End Set
        End Property


        Private _color As String="Black"
        Public Property Color() As String
            Get
                Return _color
            End Get
            Set(ByVal value As String)
                _color = value
            End Set
        End Property


        Private _value As String
        Public ReadOnly Property Value() As String
            Get
                If _value Is Nothing Then _value = Me.GetValue()
                Return _value
            End Get
        End Property

		Protected Overridable Function GetValue() As String
			If _text Is Nothing Then Return ""
			Return Me._text
		End Function


        Public Overrides Sub DoPrint(ByVal canvas As Core.ICanvas, ByVal shift As Core.Utils.Shift)
            canvas.DrawString(Me.Value, shift, Me.FontName, Me.FontSize, Me.Bold, Me.Italic, Me.Strikeout, Me.Underline, Me.Color)
        End Sub

        Public Overrides Function Measure() As Core.Utils.Rectangle
            Return Me.Size
        End Function

        Public Overrides Function ToString() As String
            Return String.Format("{0}, Text={1}", MyBase.ToString(), Me.Text)
        End Function
    End Class
End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Software Developer GeekSoft
Lithuania Lithuania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions