Using the context tagging tool under time pressure

by Sander Gerz December 18, 2004 21:14

Yesterday I had the opportunity to present my knowledge of developing with the Tablet PC for a group of around 30 developers at the SDE meeting.As I was approaching the end of the session, I decided to show the function and use of the context tagging tool. Since there's no support for Dutch handwriting recognition, context tagging, especially the use of wordlists may be needed. Anyway, the case was a simple form to enter carbrands or types. Automagically, most of the brands were already recognized flawlessly, but of course the 'lelijke eend' (a coloquial name for a Citroen 2CV) was not. On to the context tagging tool. But no, you need to set the accessible name for the form and textbox first.

Once in the context tagging tool, I was sure I followed all the correct steps, and the clock was ticking... Unfortunately, I missed step three, were you need to “Add the new association to the context file”. I knew it was there, and I missed it. Well, that's life when doing demos. They don't always work.

Context tagging is an cumbersome process (no no, I'm trying to excuse my mistake), but here's a good article explaining all the steps, although step nr. 3 is also not mentioned too explicitly.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Using the RealTimeStylus

by Sander Gerz December 12, 2004 22:16

This article discusses the function and use of the RealTimeStylus, which was introduced in the Tablet PC SDK 1.7. Being more of an advanced topic, I will not discuss the basics of the Tablet PC or introduce Tablet PC development with the SDK. Excellent articles are already available, the list of which you can find at the end of this article.

 

One of the issues developers have encountered in developing applications that utilize Ink is a degradation of performance that occurs when you trap the stylus actions in an event handler. The digitizer has a very high sampling rate of 133 packets per second. Also, some of the events are not switched on until an event handler is attachted. For example, the NewPackets event that fires as the stylus moves across the digitizer.

 

To solve this problem, the Tablet PC development team has added the RealTimeStylus (RTS) class to the SDK. 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 gets filled from a separate thread so it will not impact the UI performance.

 

Another use of the RealTimeStylus is intercepting the Ink to manipulate the way it's rendered.

 

Locating the RealTimeStylus

The RTS is located in a namespace of its own. While most Tablet PC classes reside in the Microsoft.Ink namespace, you need to use the Microsoft.Stylus namespace for the RealTimeStylus. You get access to both when you add a reference to the Microsoft Tablet PC API in your project.

 

In order to use the events in the queue, we need to create a class that implements IStylusAsyncPlugin.

Imports Microsoft.StylusInput
Imports Microsoft.Ink

Public Class Form1
    Inherits System.Windows.Forms.Form
    Implements IStylusAsyncPlugin
Entering the Implements keyword with the desired interface in VB.NET conveniently inserts all the methods that are required by this interface. We’ll get to the implementation in a moment.

 

Now we need to create a RealTimeStylus object and attach it to a control on the form. Let’s use the Panel control to attach the RTS to. First the declaration is made in the Form class.

    Private myRTS As RealTimeStylus

 

Then, in the Form_Load event, the class gets instantiated with a reference to the form.

   myRTS = New RealTimeStylus(PanelRTS.Handle)

In the DataInterest property of the form, we need to add the notifications for StylusDown, Packets and StylusUp.

    Public ReadOnly Property DataInterest() As Microsoft.StylusInput.DataInterestMask Implements _
Microsoft.StylusInput.IStylusAsyncPlugin.DataInterest Get Return DataInterestMask.StylusDown + DataInterestMask.StylusUp + DataInterestMask.Packets End Get End Property

In order to display the Ink on the screen, we need to implement the methods for StylusDown, Packets and StylusUp.

 

 

 

Remember, the form in which all this code resides implements IStylusAsyncPlugin. To allow the plug-in to interact with the data stream from the tablet pen, the RealTimeStylus object maintains two plug-in collecton, which are accessible through the SyncPluginCollection and AsyncPluginCollection properties. You can add a plug-in by calling either StylusSyncPluginCollection.Add or the StylusAsyncPluginCollection.Add method of the collection within the appropriate property.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen | Modified by Mooglegiant