Dr. Neil Roodyn

Subscribe to Dr. Neil Roodyn: eMailAlertsEmail Alerts
Get Dr. Neil Roodyn: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Article

From .NETDJ's Next Issue: "Shiny New Tablets"

Coming close to the paper near you...

[This article appears in .NET Developer's Journal Industry Newsletter exclusively and is being made to newsletter subscribers only. It is taken from the upcoming issue of .NET DJ, and is not yet available publicly.]

The Tablet PC is nothing new. It is an evolutionary step upwards towards the dream of electronic paper. It is a big increment and represents one of the largest movements in that direction that we have seen for some time. For example to use the Tablet PC you don't have to learn a new way of writing, in fact, it even recognizes most of my joined-up writing, which is amazing because most human beings don't seem to be able to do that!

But it is still not new. I remember working with the Pen for Windows SDK in the early 1990s and thinking "hey, wow, this is cool," and then the Newton from Apple and a host of PDA devices came along and they all tried to steal the thunder from paper. Yet in many ways traditional paper still contains some features that the technology has yet to tackle. It doesn't break when I drop it on the floor, it is very tactile, and I can fold it and carry it in my back pocket without worrying about sitting on it. Paper also accepts a wide variety of input devices - pens, markers, pencils, and erasers.

So why use a Tablet PC? The electronic paper presented by a Tablet can do things you can't do with traditional paper. I can store all my notes in one place, I can stretch the page to squeeze new text between existing lines, I can connect it to Microsoft Outlook and e-mail notes, set tasks, and take minutes for meetings. The dream of the paperless office is one step closer, but in order to really make the difference we software developers have to write applications to take advantage of the new features and help add business value to our organizations through the use of the technology.

The new Windows XP Tablet PC Edition 2005 has been released and the Tablet PC Platform SDK 1.7 is now available. You can download the SDK from http://msdn.microsoft.com/TabletPC.

This new version of the platform ships at the same time that Tablet PCs are coming down in price and supporting more features. We are starting to see Tablet PCs with larger screens, Bluetooth support, faster CPUs, and more memory. At the same time digitizer screens are being fitted to more conventional machines with prices only a couple of hundred dollars from the equivalent laptop.

The new features presented in the SDK for us developers can be broken down into three areas: context, stylus input. and Web support.

Context
The context support provides hints to the TIP (Tablet Input Panel) in order to aid the recognition process. For example, you may wish to tag a TextBox as a phone number field. The recognizer will then use this guidance to improve the accuracy of the recognition. For a phone number it is more likely that a vertical line is the number one than a lower case letter L.

Context can be applied programmatically within the application code or via an additional XML file. The advantage of using the XML file is that you can apply the context for a set of input fields without having to change the code of an existing application.

Adding the code to recognize with context is simple:


// Create a recognizer context from the recognizer
recognizerContext = recognizer.CreateRecognizerContext();
// Setup the RecognizerContext's Text Context (Word List and factoid)
recognizerContext.Factoid = "(!IS_TELEPHONE_FULLTELEPHONENUMBER)";

You'll notice that the Factoid property is a string. Currently there are around 50 constants defined in the SDK. In the COM API these context strings are defined in an enumerated type. Managed code developers currently have no default-type safe mechanism. I would suggest that if you are going to heavily use context strings you define your own enumerated type.

Stylus Input
One of the issues I have encountered in developing applications that utilize Digital Ink is a noticeable degradation of performance that occurs when you trap the stylus (pen) actions in an event handler. Remember that the digitizer has a very high sampling rate. By default some of the events are not even switched on until an event handler is attached. An example is the NewPackets event that fires as the stylus moves across the digitizer.

To solve this problem the Tablet development team have produced the RealTimeStylus (RTS) class. The RTS allows you to programmatically trap the events produced from the stylus. The RealTimeStylus class provides a queue that holds the events generated from the stylus. This queue is filled from a separate thread so as to not impact the UI performance. In order to use the events in the queue you need to create a class that implements IstylusSyncPlugin (see Listing 1).

An object that supports the IStylusPlugin is called a RealTimeEventSink object. By creating your own RealTimeEventSink objects you can customize how the ink gets displayed. You can also use build a gesture recognizer this way. The Framework provides a DynamicRenderer and GestureRecognizer; you can use these to get started.

In the CustomRenderer class the Packets are intercepted from the queue and being used to draw small blue circles on the Graphics object.

The RealTimeStylus queue is a fixed size. The fixed size means that if you implement something which is processor intensive you may lose some packet data. With regular sized packets the queue can buffer approximately 10 seconds of packet data.

In order to use the CustomRenderer just defined you need a class that implements the IStylusPlugin interface (see Listing 2).

In this example an instance of a CustomRenderer is added to the RealTimeStylus. The CustomRenderer will draw the blue circles in the GroupBox. I left out the details of the IStylusAsyncPlugin implementation because they are not required for this simple example.

Web Support
The final big addition to the Tablet SDK is the support that has been added to allow inking online. Inking online is achieved through a slight of hand. First a Windows control needs to be created that can accept Ink (see Listing 3)

This control can then be embedded in a web page, using the Object HTML tag.


<OBJECT id="inkComment" height="200" width="400"
classid="WinInkComment.dll#WinInkComment.InkComment" VIEWASTEXT>
</OBJECT>

It is then possible to call methods in the embedded object via JavaScript code on the Web page.

If you plan to provide a substantial amount of Ink support on your Web site I suggest that you create a Web User control that hosts the Ink-enabled Windows control.

To help you further, when a request for a Web page is made from a Tablet PC running Edition 2005, an identifier is placed in the UserAgent string. You can use this identifier to alter the way a Web site appears to a Tablet PC user (see Listing 4).

Write On
The new capabilities of the Tablet PC Edition 2005 and the tools provided in the Platform SDK 1.7 provide us with another small nudge closer to digital paper. Tablet takeup so far has been mostly limited to vertical markets where the advantages can be seen to have immediate business benefit. These vertical markets include health care, real estate, and insurance. The opportunities for Digital Ink within horizontal markets have only been taken up by a few software products, such as Franklin Covey's Tablet Planner and One Note. I believe that in the coming months developer components will become available that utilize the features of the new platform. The new components will lower the entry barriers for development of Tablet applications. I hope to see more Ink-enabled applications in the next year.

More Stories By Dr. Neil Roodyn

Dr. Neil is an independent itinerant consultant, trainer, and author. He travels the world working with software companies. Dr. Neil loves Australia, where he spends the summer enjoying the Sydney lifestyle and helping software development teams get more productive. Dr. Neil spends his other summer each year flying between northern Europe and the USA, working with software teams and writing about his experiences. Neil brings his business and technical skills to the companies he works with to ensure he has happy customers. His latest book, eXtreme .NET, introduces eXtreme Programming Techniques to .NET developers. You can find out more from his Web site www.Roodyn.com.

Comments (2)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.