TX Text Control .NET for Windows Forms

Product Architecture

Topic

Every Windows Forms application with TX Text Control has the TextControl at its center. The ribbon, the toolbars, the rulers, the status bar and the sidebar are separate controls that you connect to it, MailMerge and ServerTextControl work with documents in code, and one document engine does the work for all of them. Once you know how these parts connect, you know what to place on a form, what to set in code and which files your application ships.

Architecture at a Glance

The parts of TX Text Control .NET for Windows Forms fall into three layers:

  • The editor and its user interface. TextControl shows and edits the document. The ribbon, the toolbars, the rulers, the status bar and the sidebar are controls of their own that display and change the attributes of the connected TextControl.
  • The components without a user interface. ServerTextControl processes documents in code, and MailMerge merges data into templates. They can work with a TextControl or on their own.
  • The document engine. .NET assemblies and native Windows libraries load, format, render, print and save the documents for all components.

The following diagram shows one form with a complete editor and the components your code uses beside it:

Form
+--------------------------------------------------------------+
| Ribbon  (tabs: Formatting, Insert, Page Layout, View, ...)   |
+---------+------------------------------------+---------------+
|         | RulerBar                           |               |
| Vertical|------------------------------------|   Sidebar     |
| RulerBar| TextControl                        |               |
|         |                                    |               |
+---------+------------------------------------+---------------+
| StatusBar                                                    |
+--------------------------------------------------------------+

MailMerge --TextComponent--> TextControl or ServerTextControl

TX Text Control engine: .NET assemblies + native libraries (win-x64, win-x86)

TextControl and Its Bars

TextControl, ButtonBar, RulerBar and StatusBar are Windows Forms controls, derived from System.Windows.Forms.Control. The bars do nothing on their own: each one is connected to a TextControl through a property of the TextControl.

Property of TextControlConnects
ButtonBarA ButtonBar, which shows and sets font and paragraph attributes
RulerBarThe horizontal RulerBar, which shows and sets indents, margins and tabs
VerticalRulerBarA second RulerBar, shown vertically beside the editor
StatusBarA StatusBar, which shows the input position, the section and the page
RibbonA Ribbon, which replaces the menu bar and the toolbars

In the Visual Studio designer, the smart tag of the TextControl adds the bars and connects them without code; Visual Studio Designer Integration describes it. In code, you assign the bars to these properties, for example in the constructor of the form, as Connect the Controls in Code shows. A property that is not set is null, and the editor works without that bar.

Ribbon Tabs and the Sidebar

The ribbon hosts tabs, and TX Text Control provides predefined ones for all features of the editor, such as RibbonFormattingTab and RibbonReportingTab. A predefined tab controls a TextControl only when that TextControl is connected to the ribbon that hosts the tab. Built-in Ribbon Tabs lists them, with what some of them need in addition, such as a spell checker for the proofing tab.

The Sidebar is connected the other way around: its own TextControl property names the editor it works with, and ribbon buttons can open it. See Sidebar.

ServerTextControl and MailMerge

ServerTextControl is a component, not a control. It has the same programming interface as TextControl but no window, so it suits work that the user does not watch. Unlike TextControl, it has to be initialized with Create before you use any other member.

MailMerge in the TXTextControl.DocumentServer namespace merges data into templates. It holds no document itself: its TextComponent property connects it to a TextControl, where the user sees the merged result, or to a ServerTextControl, which merges in the background.

ServerTextControl and MailMerge introduce the two components.

The Document Engine

All components use the same engine. It consists of .NET assemblies and native Windows libraries.

  • The .NET assemblies hold the classes. TXTextControl.Windows.Forms.dll contains TextControl, the bars, the ribbon and the sidebar, TXTextControl.Server.dll contains ServerTextControl, and TXDocumentServer.dll contains MailMerge. Further assemblies add barcodes, drawings, PDF and images.
  • The native libraries format and render the documents and read and write the file formats, with one library per format family. They exist in a 32-bit and a 64-bit version; 32-bit and 64-bit Applications shows where each set is.
  • Windows components. The native libraries need the Microsoft Visual C++ runtime, and the XML features the Microsoft XML parser, as Windows Versions describes.

Because the native libraries are built for 32-bit and 64-bit Windows, the bitness of your application decides which set it loads, and an application built as AnyCPU needs the set that matches the process. x86, x64, and AnyCPU explains the build settings, and Managed Assemblies and Native Libraries lists the files you ship.

Formatting, Dialog Boxes and Printing

The engine formats a document with the text dimensions of a printer, so that it looks the same on the screen and on paper; One Engine for Display and Printing explains the setting. The dialog boxes are built in and are opened by methods of TextControl, as Built-in Dialog Boxes describes, and printing uses the print dialog and the printers of Windows, as Printing and Print Preview describes.

Next Steps