Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Master the Pen Using Ink Controls in Your Tablet Applications : Page 2

Although you can treat Microsoft's new Tablet PC Ink Data like image data, the Ink controls and objects provide a much wider variety of options for incorporating pen input into your applications. Learn how to persist ink in many formats, depending on your needs.


advertisement
Exploring Ink Data File Formats
You can represent ink in a number of different formats, including Ink Serialized Format (ISF), HTML, RTF, and XML. Of these, the most important and basic format is Ink Serialized Format (ISF), which is a highly compressed binary representation of the ink data from a lone ink object. The ISF format contains stroke information as well as the original device coordinates and is extensible through Microsoft's support for arbitrary properties. In this case, Microsoft provides the extended property object for adding additional properties. For example, if you were storing a signature in ISF format, you could embed the client's name and a security value in the extended property object. When you store and later reload the signature, your application can use this data to validate against the client's user records to prevent possible fraud.

Applications whose documents contain only ink would use ISF. Applications that are concerned only with the "Ink as Ink" and not with handwriting recognition would fall into this category. For example, you would use ISF to for adding a layer of annotation to images without compromising the original image.

The low-level binary ISF format is the most compact representation of Ink, so it's the format you should prefer for applications that support copy and paste Ink operations, using the ClipboardCopy(Rectangle), ClipboardCopy(Strokes), and ClipboardPaste() methods. The Tablet PC platform contains built-in methods for both collecting and copying-and-pasting ISF. ISF allows for the lowest level of ink interoperability. You must load data produced by an ISF Application into an ink-aware application to view it. Machines without the ink components installed (via the Microsoft Tablet PC SDK or your application's install) will not be able to interpret the ISF format. In situations where interoperability between Windows platforms is essential, it is best to use a more commonly understood format—HTML.

HTML allows for many varied types of content. Ink data is represented in HTML as an image by applications that do not recognize ink. The Tablet PC Platform APIs provide the fortified GIF persistence format used for generating the image and, to an ink-enabled application, there is a rich set of data underlying the image. Fortified GIFs have ISF embedded within them.

It is possible to represent ink with other file formats as well. For example, you can embed OLE objects that contain ink within RTF files, meaning, you can paste ink into older applications, such as Microsoft Word, that do not natively recognize ink. You can use still other formats, such as binary or XML-based formats, in the appropriate circumstances. Unfortunately, HTML is not suitable for storing structured data. If your application gathers, stores, and manipulates structured data, you might find XML to be a more useful ink storage format. The Inking objects and controls of the Tablet PC platform SDK help you generate and interpret these formats whether you choose to implement using the Managed Library or the Automation API interfaces.

Persisting Ink Data
This sample code included with this article demonstrates how to save and load ink. It lets you save ink data in Ink Serialized Format (ISF), XML, and HTML format. The XML format stores ink as Base64-encoded ISF, while the HTML format stores the ink as a Base64-encoded fortified GIF image.

Using the sample you can open files saved using the XML and ISF formats, but the sample does not support loading from the HTML format. You can view the HTML output with your browser or MS Word. Using HTML can be a "one-way" street. Though the ink controls generate fortified GIF files, the application used to view the HTML is in charge of evaluating the .GIF, and the results can vary. For your HTML to invoke the ActiveX Inking Controls, you need to generate the HTML to include the <OBJECT> tags. Loading the HTML into an application that is not ink-aware without the ActiveX <OBJECT> references will display the fortified .GIF as an image. You'll see how to generate the HTML a bit later in this article.

Author Note: As of this writing, Internet Explorer has no built-in capability for working with ink.

Collecting Ink
Figure 2: Selecting the Microsoft InkEdit Control and/or InkPicture control will add these controls to your toolbox.
To get started, create a new .NET Windows application, and then click the Add Reference item in the Solution Explorer. That brings up the Add Reference dialog box. Click the .NET tab, and then select the Microsoft Tablet PC API component to add the reference. Adding the reference gives your application access to the Tablet PC object model and controls. By default, the library installs to systemdrive:\Program Files\Microsoft Tablet PC Platform SDK\Include\Microsoft.Ink.dll.

Unfortunately, adding the library reference doesn't automatically add the available controls to the ToolBox. To do that, right-click within the Toolbox, and then click the Customize Toolbox item. In the Customize Toolbox dialog box, click the .NET Framework Components tab. Select the InkEdit and/or InkPicture controls from the list box (see Figure 2), and then click OK.

Add an Imports statement for the Microsoft.Ink library to the top of your code module.

Imports Microsoft.Ink

Then in the New() constructor for the form, create an InkCollector for the form and enable it.

myInkCollector = New InkCollector(gbInkArea.Handle) myInkCollector.Enabled = True



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date