Advertisment

Context Tagging Tool in the Tablet PC SDK 1.7

author-image
CIOL Bureau
Updated On
New Update

In the past we had covered a lot of different features of the Tablet PC. We discussed about the tools available in the SDK, the controls available as part of the SDK so that developing applications with Visual Studio .NET 2003 was the same as developing applications for the desktop and client/sever applications.

Advertisment

Recall that the majority of the new features of the Tablet PC was shipped as part of Windows XP Service Pack 2.

Let us see why the Context Tagging tool is of vital importance and what benefits it offers. We will walk through an example and demonstrate the limitations that the user might face when filling out forms with the Tablet PC Input Panel (TIP). It is not actually the limitations of the Tablet PC Input Panel but rather a short coming recognition feature due to the complexity of the functioning of the human mind which computers cannot decipher.



Advertisment

If you see the figure above you will see that this is a very familiar form which a majority of the computer users are exposed to and which they must fill out in order to complete their task. It could be registering for a free email account, or registering their name on a website so as to receive monthly mailers etc. The list is never ending.

Now when the user uses the Tablet PC to fill out these kind of forms, they will be making use of the (Tablet PC Input Panel) TIP to fill out the text. The TIP appears when the user hovers his pen over the control, and the user can enter any values into the handwriting area. This is fine in the case of multiline edit control where the user can enter a discussion of the sales contact, but the TIP has its limitation when it comes to enter a particular phrase such as a telephone number, pincode, or an email id. Also the application can be programmed to limit the entry by the keyboard with the help of Regular Expressions. This Regular Expression is provided as part of the .NET Framework SDK and is highly useful when the user uses the keyboard to enter the data. But when it comes to using the TIP, this restriction cannot be applied because the user user can write anything they want in Input Panel. The final result is that the user would want the input to be restricted/validated whether he uses the keyboard or the TIP.

The Context Tagging tool makes it extremely easy for the programmer of Tablet PC Applications to provide limiting input to Input Panel without even changing the application's code. Using the Context Tagging tool, the developer can point it at the various edit fields in your application and specify the type of input for the field. You can restrict the input to predefined restrictions-such as an SMTP e-mail address or specific numerical values. If you have specific values, you can also specify a phrase list of any length you'd like. For unique items, you can also specify a regular expression.

Advertisment

Let us walk through an example and write some code to show how the Context Tagging Tool is used to restrict the input with the TIP. Note that in this sample we will not be focusing on developing the code for the application but just focusing on how to use the Context Tagging Tool for restricting the input. Note that the Context Tagging tool can be used for "already developed applications".

Start Visual Studio .NET 2003 and then design the form as shown in Figure 2. Note that we are capturing the basic information like age, date of birth and telephone number. This makes it a good candidate for the Context Tagging Tool because all the three controls have special formatted data which has to be specified. In the first case it is a pure number and using the TIP can confuse between using 2 and Z. In the other two cases the date of birth and telephone numbers need regular expression styles to be used with.



Advertisment

Now make sure that you have installed the Tablet PC SDK 1.7 and the Context Tagging Tool. This will appear in the Start Menu as seen in Figure 3.



Now start the Context Tagging Tool by clicking on the menu item and the Context tagging tool looks as in Figure 4.

Advertisment



A brief introduction on what the Context Tagging Tool is, how to use the Context Tagging tool forms the first screen. Now we have to point the path of the executable to the Context Tagging tool so that it can embed the information. For this we will return to Visual Studio .NET 2003 and build the solution so that we will have an executable in the bin folder of the application.

After building the solution and confirming that the build was successful, return to the Context Tagging Tool and now browse to the path of the application. We will name the Visual Studio .NET application "ContextTagging" so that the name of the executable will be ContextTagging.exe. After browsing to the path and selecting the file the output is seen in Figure 5.

Advertisment



After doing this we will have to create a context file. The Context file is a XML file which contains the association between the controls and their input values. These associations are contained in an XML file (.ctm) created by the tool and that resides within the application directory. The Tablet PC Input Panel (TIP) reads the .ctm file and sends the information to the recognition engine, increasing the accuracy.

Click on the button "New Context file" and the wizard to create the file will appear. The screen lis seen in Figure 6.

Advertisment



Before working with the Context Tagging Tool there is a very important requirement for this to work and this is the AccessibleName of the control in order for the Context Tagging tool and Input Panel to figure out exactly which control the limiting input should be applied to. In case of already developed applications this might require opening the application in design mode and setting the values for all the controls.

For this we will return back to the Visual Studio .NET 2003 and then fill out the Accessiblity name of all the controls. This is done by selecting the control, pressing F4 to open the Properties dialog box and then filling out the Accessibility Name. Let us fill out the Accessibility Name with the same name of the controls. In this example I have named them txtName, txtAge, txtDOB and txtTelephone.

After filling out the names return back to the Context Tagging tool and the first step wil be to select the control for tagging. Now place the screen in such a way that the design form and the tool appear in view. This is because the control can be selected only by dragging and dropping. The adjustment of the two applications is shown in Figure 7.



Now click on the button which says "click to select a control". A new dialog box will appear as seen in Figure 8.



Clearly it is seen that the application name, version, language and more importantly the Accessiblity name have to be provided. And without providing these details the control cannot be tagged. Holding the mouse click on the button with cross arrows and pull it to the first control on the application that says Date of Birth and then leave the mouse. Now you will see that the details have been populated in the dialog box and the OK button is enabled. The application name, version, language, accessibility name, class name are all populated. That means the control can be tagged. Now click on OK and then the focus will return to the Context Tagging tool.



Now we find ourselves on Step 2 of the wizard. Expand the Common Input scope and then select Date (full) from the available list and then click on the >> button. This means that the control Date of Birth will have to be of the format Date when using the TIP.

Complete Step 3 by adding the tag to the context file.

Finally save this file by clicking on the Save button. This completes the creation of the ctm file.

Now let us see the recognition capabilities of the application that we created just now. Start the application, place the focus on the "Date of Birth" text box, open the TIP and write out today's date. Do not write the date in a clear legible handwriting but ensure that you write it in such a way that the handwriting is not legible and 2 and Z look alike.



After pressing the OK button it is seen that the date appeared correctly in the text box without any spelling mistake or without any fault. This wouldn't have been possible without the Context Tagging Tool. The output is seen in Figure 11.

We have now seen how the Context Tagging tool helps a lot in defining the expression to be recognized by the TIP. The tool also provides additional advanced features for dynamic usage and we will see that in the next episode.

tech-news