Class Name: |
RTFPlus |
HL7+ Category: |
Restricted (There is a unique exception for this object see Restriction Exception below) |
Description: |
General purpose RichText manipulation and document creation tool. |
The RTFPlus object class is a general purpose utility object for easily creating formatted RichText (RTF) documents and reports. It is not intended to be a comprehensive RichText manipulation tool but rather as a straightforward top-to-bottom document creation tool which you can easily create and use with only a few key properties and methods.
The architecture is simple, you instantiate the object and then start adding text with formatting options. The architecture is streamlined in that documents are created from top to bottom, meaning that there are no methods for inserting text or richtext into a document, everything is always appended to the end. Once you're done, you retrieve the RTF property and display it (in a RichTextBox for instance) or save it.
Programming Note: The best way to evaluate this object is to just jump in and start using it and experiment with it.
*All example code is in Visual Basic.Net
'Where MyController is a HL7PlusController object Dim RT1 As New RTFPlus(MyController) With RT1 Dim sBuff As String = "" .rtFormat() .rtFontSize = 12 .rtAlignment = HorizontalAlignment.Center .rtFontStyle = FontStyle.Bold + FontStyle.Italic .AddLine() .AddLine("This is dynamic data set by using RTFPlus.") .AddLine("") Dim oFMT As New LabelDataFormat With oFMT .AddNewLineAfter = True .BoldData = False .BoldLabel = True .LabelColor = Color.Black .DataColor = Color.Blue End With .rtAlignment = HorizontalAlignment.Left .rtFontSize = 10 .rtFontStyle = FontStyle.Regular sBuff = "Now we'll show some uses of the Label/Data methods." .AddLine(sBuff) .AddLabelData("This is a Label:", "This Is Some Data", oFMT) oFMT.AddNewLineAfter = False .AddLabelData("Label 1:", "Data 1. Next Label on same line.", oFMT) oFMT.DataColor = Color.Red .AddLabelData("Label 2 (Warning):", "Data 2 In Red", oFMT) .AddLines(2) .AddLine("Now we'll play with indents/margins") .LeftIndent = 25 .RightIndent = 25 oFMT.AddNewLineAfter = True oFMT.DataColor = Color.Green oFMT.BoldData = False .AddLabelData("Left Indent: ", "25", oFMT) .rtAlignment = HorizontalAlignment.Right .AddLabelData("Right Indent: ", "25", oFMT) .RightIndent = 5 .AddLines(2) .rtAlignment = HorizontalAlignment.Right oFMT.AddNewLineAfter = True oFMT.DataColor = Color.Black oFMT.BoldData = False .rtFontStyle = FontStyle.Bold .AddLine("HermeTech International Ltd") .rtFontSize = 8 .rtFontStyle = FontStyle.Italic .AddLine("A Division of TransWorld Scribes") .rtFontSize = 10 .AddLabelData("Web Site:", "http://www.hermetechnz.com/EasyHL7/", oFMT) .AddLabelData("Online Help:", "http://www.hermetechnz.com/documentation/hl7plus/Components/", oFMT) 'Where RTBox1 is a RichTextBox Control RTBox1.Rtf = .RTF End With
|
*All example code is in Visual Basic.Net
This class is flagged as Restricted. This means that you cannot create the object without passing a HL7PlusController object to it like so:
'Where MyController is a HL7PlusController object Dim RT1 As New RTFPlus(MyController)
However, unlike other Restricted objects you can use the RTFPlus object even if the IsRunnable property of your HL7PlusController object is False. When you create the object (as shown above) an internal call is made to the IsRunnable property of your HL7PlusController. If it is False then a System Exception is thrown BUT you can TRAP this exception and continue to use the object without further exceptions like so:
Dim RT1 As RTFPlus = Nothing Try 'Where MyController is a HL7PlusController object RT1 = New RTFPlus(MyController) Catch exNotIsRunnable As Exception 'OOPS, if I got this exception it's because IsRunnable is False in MyController 'So I'll just do nothing and carry on End Try
With RT1 Dim sBuff As String = "" .rtFormat() .rtFontSize = 12 .rtAlignment = HorizontalAlignment.Center .rtFontStyle = FontStyle.Bold + FontStyle.Italic .AddLine() .AddLine("This is dynamic data set by using RTFPlus.") .AddLine("Etc.") .AddLine("Etc.") .AddLine("Etc.") .AddLine("Etc.")
'Where RTBox1 is a RichTextBox Control RTBox1.Rtf = .RTF End With
|
|
|