A Tablet PC As a Smart Client


The Tablet PC operating system is a Windows XP Tablet PC Edition that is a superset of the traditional desktop application. One of the main advantages of this device is that it is built on top of the Windows XP platform and provides users with the same features as the traditional desktop with enhanced features targeted for mobility. As a superset of Windows XP, it provides additional capabilities that can be used to extend these types of devices. Installing the .NET Framework by default, Windows XP Tablet PC Edition allows you to take full advantage of managed code and VB.NET and C# applications ”without having to worry about redistributing the .NET Framework.

Not only can you take full advantage of the exciting new capabilities of the Tablet PC platform with ink, pen, and handwriting recognition APIs, but you also have the full power of Windows and all the existing Windows APIs, components , developer tools, and applications that run on Windows XP. The Tablet provides additional capabilities that extend these types of devices. The benefit of using the Tablet PC with InfoPath is that this combination can take advantage of these advanced functions and provide additional capabilities over the traditional PCs, as seen in Figure 8.7.

click to expand
Figure 8.7: A developer s view of the Tablet PC platform.

The Ink Control

 CD-ROM    One of the main features of InfoPath when used with the Tablet is that you can directly enable the ink on the form. (This is available on the companion CD-ROM in \Code\Chapter 8\Tablet\Ink Form\ink.xsn.) One of the advantages of this is that you can show the file and collection annotations. The ink control is actually one of the features of the Tablet SDK. It is important to remember that this feature is available only when you re using a Tablet PC. Figure 8.8 shows an InfoPath form that uses the ink control.

click to expand
Figure 8.8: InfoPath form with the Ink Picture control.

Figure 8.9 shows what happens when this form is loaded and ink is added.

click to expand
Figure 8.9: A completed ink form.

What Is Base 64?

When you use inking within InfoPath, the contents of saved XML are converted and stored in Base 64. The Base 64 Content-Transfer-Encoding is designed to represent arbitrary sequences of octets in a form that is not humanly readable. The encoding and decoding algorithms are simple, but encoded data is only about 33 percent larger than un-encoded data. This is important to keep in mind as encoding images can start to substantially increase the size of your files. This encoding is identical to the one used in Privacy Enhanced Mail (PEM) applications that are defined as part of RFC 1421. The only change that Base 64 encoding made to this RFC is that it eliminates the * mechanism for sending embedded clear text.

Note  

Within Base 64 a 65-character subset of ASCII that allows for 6 bits per printable character is used. The extra character, = , is used to signify a special processing instruction.

The Base 64 encoding process represents 24-bit groups of input bits as output strings of four encoded characters . You create the 24-bit input group of an encoded file by concatenating three 8-bit input groups. These 24 bits are then treated as four concatenated 6-bit groups, each translated into a single digit in the Base 64 alphabet. The encoding rules guarantee that the bit stream is ordered with the most significant bit first.

Each 6-bit group is used as an index into an array of 64 printable characters. Any character referenced by the index is placed in the output string. These characters, identified in Table 8.1, are selected as part of the index. The value set automatically excludes characters with special meaning, like FTP, CR, and LF.

Table 8.1: The Base 64 alphabet.

Value

Encoding

Value

Encoding

Value

Encoding

Value

Encoding

A

17

R

34

i

51

z

1

B

18

S

35

j

52

2

C

19

T

36

k

53

1

3

D

20

U

37

l

54

2

4

E

21

V

38

m

55

3

5

F

22

W

39

n

56

4

6

G

23

X

40

o

57

5

7

H

24

Y

41

p

58

6

8

I

25

Z

42

q

59

7

9

J

26

a

43

r

60

8

10

K

27

b

44

s

61

9

11

L

28

c

45

t

62

+

12

M

29

d

46

u

63

/

13

N

30

e

47

v

   

14

O

31

f

48

w

pad

=

15

P

32

g

49

x

   

16

Q

33

h

50

y

   

The resulting output stream is required to be presented in lines that don t exceed 76 total characters each. Within Base 64, the decoding software automatically ignores any characters not found in Table 8.1. When the actual stream is decoded, these are considered transmission errors.

 CD-ROM    When the sample Ink Form (included on the CD-ROM in \Code\Chapter 8\Tablet\Ink Form\saved.xml)is saved, the resulting XML file contains the Base 64 encoded field, as shown in Figure 8.10.

click to expand
Figure 8.10: Notepad view of the Base 64 encoded form.

Reusing Base 64 with a Smart Client Application

Using Visual Studio, we can take the saved Base 64-encoded XML and convert that into a bitmap image that can be shown in a Windows Form application, as shown in Listing 8.8.

Listing 8.8:
start example
 Imports System.Drawing Imports System.IO Imports System.Xml Private Sub BtnConvert_Click(ByVal sender As System.Object, ByVal e As  System.EventArgs) Handles BtnConvert.Click     Dim retnbit As Bitmap     Dim rdr As New XmlTextReader("saved.xml")     rdr.WhitespaceHandling = WhitespaceHandling.None     ' Read the file. Stop at the Base64 element.     While rdr.Read()       If "my:field1" = rdr.Name Then         Dim base64txt = rdr.ReadElementString()         retnbit = BitmapFromBase64(base64txt)         Exit While       End If     End While     PicImage.Image = retnbit   End Sub Public Function BitmapFromBase64(ByVal base64 As String) As  System.Drawing.Bitmap     Dim oBitmap As System.Drawing.Bitmap     Dim memory As New  System.IO.MemoryStream(Convert.FromBase64String(base64))     oBitmap = New System.Drawing.Bitmap(memory)     memory.Close()     memory = Nothing     Return oBitmap   End Function 
end example
 

When applied against the existing saved XML form, this decodes the image and converts it into a bitmap like that shown in Figure 8.11.

click to expand
Figure 8.11: Base 64 converted to a bitmap in a reusable client.



Programming Microsoft Infopath. A Developers Guide
Programming Microsoft Infopath: A Developers Guide
ISBN: 1584504536
EAN: 2147483647
Year: 2006
Pages: 111
Authors: Thom Robbins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net