Thursday, October 23, 2008

My Adventures with Ink

I don't know how I've gone this long without attempting to program applications specifically for Tablet PC's before. It was a strange string of events that resulted in my new obsession.

Last Wednesday I went to WIPTE where I presented my poster on STUG and attended several informational sessions. As a result I missed collecting the DyKnow in class problem for the calculus classes. As a result I was given the files on a standard jump drive. This was nothing too crazy and may not seem related to programming, but everything comes together very quickly.

My job in the calculus class can be divided into two main tasks. First, I provide technical support during class to help the students quickly resolve their problems. The other part of my job is managing the in class problem. This job goes even farther than just collecting and managing in that I am designing a system to make easier for future semesters. Next semester when I'm not there they will likely not have a student willing to write a computer program to solve technical problems as they arise.

The accident that started my new obsession was an unintended right click. I simply right clicked one of these DyKnow files and realized that Al Zip could unzip it. I've looked into parsing DyKnow's file format earlier and ran into, what I assumed was, compression. This confirmed my assumption. After unzipping the file it was revealed that DyKnow simply uses XML to store all of the information. A fairly standard approach for storing files that contain digital ink.

As a result I was able to read the file in using a simple C# program and read in the information that I care about. So far I have not done anything too complicated. One of the biggest problem I was having with DyKnow was not having any ability to export the user names of the students whose panels were collected for the in class problem. I spent almost 20 minutes manually transcribing these names. Now I have a simple program that can extract the tames and I can copy and paste them from my simple GUI.

Here is just a short C# code sample that I use to actually open the DyKnow file:

//Open the file
FileStream input = new FileStream(dyKnowFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
//Uncompress the file
GZipStream gzip = new GZipStream(input, CompressionMode.Decompress, true);
//Read the uncompressed file as XML
XmlTextReader textReader = new XmlTextReader(gzip);


This simply opens the file as a stream, uncompresses the stream, then reads the stream as XML. However, this is only the first half of the story.

I ended up having to do some very simple reverse engineering to understand how DyKnow's file format works. I won't post any of that information in this post, but if I post some more code I will explain the tags that I had to use. After I got past the standard compression it was trivial to understand the data that is being stored.

The part that now has me busy is understanding the ink data that is stored as part of the file. I have learned that ink strokes are stored as base64 strings. This appears to be standard for Microsoft inking applications and I simply need to pass it to the correct methods to display it. I have found some example code but I haven't made much progress yet. It seems that ink applications are still slightly complicated to make.

Wednesday, October 22, 2008

Programming with Ink

I've only recently started programming applications that have a GUI. I've spent most of my time working on the web. However, I have had a recent obsession with programing with Ink on Tablet PC's. It is only logical, I'm already a Tablet PC nut.

At first I found it difficult to get started. I am running Vista Ultimate with Visual Studio 2008 so I expected it to work without any problems. Well, apparently I should have read the fine print when I stumbled across some Digital Ink Sample Programs on Microsoft's website. I have been able to compile these are make some small modifications to them to start to learn about the ink support. Baby steps... compiling examples is a good start.

I have also run across Stefan Wick's Weblog - Development with Silverlight, WPF and Tablet PC. There are a number of very useful code samples posted on his blog that I will definitely be playing with soon. This also raised my interested in programming for the Ink on a Tablet with Silverlight.

While I haven't made much progress making any programs of my own, I have learned that I will be needing to study up on XAML. I realized it was used in making the interface for many Windows applications, but I didn't realize how extensively it was used when dealing with Ink. Basically, you can have an inking application with only XAML code and no actual C# written.

I'm not sure what direction I'm going to take with this new obsession, but the rate at which I've been making progress is exciting. However, I should probably get back to the homework I've been ignoring.

Powered By Blogger