Freigeben über


Using Ink on the Web

Using Ink on the Web

This topic contains notes on various ways to use ink on Web applications.

The Ink Blog sample demonstrates several useful techniques that can be used in ink-enabled web applications. These include: testing if the client machine can support ink-enabled controls, submitting ink data to a server, and displaying ink data on a Web page.

Testing Ink Enablement

It can be useful to test if the client machine can display ink-enabled controls. This way the web page can show one control if the client is a Tablet PC, and a different one if not. One way to test this is to attempt to create an object such as an InkOverlay, which can only be created on a machine that has the Microsoft® Windows® XP Tablet PC Edition operating system or the Windows XP Tablet PC Edition Software Development Kit (SDK) installed. If you create the object inside a try/catch block and catch any exceptions that are thrown (often a FileNotFoundException Leave Site will be thrown to indicate that the assembly with this control cannot be found), you can detect whether the client machine can support ink-enabled controls. In the sample, this code can be found in the constructor of the InkArea class.

Submitting Ink Data

A simple way to submit data is to take the data from your ink-enabled control, transfer it into a hidden form, and then submit the form. The ink can be serialized using the Save method, and then converted into a String Leave Site. In the sample, the hidden form is defined in AddBlog.aspx, and the ink serialization is handled in InkArea.SerializeInkData, where the ink is serialized into a GIF image. (Note that it could be serialized similarly in other formats as well such as ink serialized format (ISF).)

Displaying Ink Data

In the sample, AddBlog.aspx.cs has a method called Page_Load that retrieves the data that is posted to the server and saves it into to files. It then generates Web pages on the server that contain img tags that reference the files with the GIF images. Now you only need to navigate to those pages to see images of the ink. (Note that if you had serialized the ink with a different format, such as Ink Serialized Format (ISF), then you would need to convert the ink to an image on the server in order to display it on clients that are not tablets.)

For tablet clients, it's possible to load the ink back into an ink-enabled control and allow the user to edit the ink by using ISF. This is even true for ink saved in the Gif format, since the ISF data is contained in the GIF metadata.