CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

January 2005 - Posts

  • Hypnotizing dot mixer (everybody a DJ)

    Next week is VS live in San Fransisco. I surfed the net browsing for other attractions over there. On the site of the museum of science, art and human perception I found the dotmixer. Recomended to anybody who does like music or has any interest in sound at all. I know what to do on my day off.

    Peter

  • Tablet PC pen capabilities and the tablet API

    In a recent post I played around with different pens for my tablet PC. The samples of the "Building Tablet PC applications" book clearly pointed out what the problem with one of them was. The pen of a tablet reports a variety of information including X and Y position and the pressure applied to its tip, the pen fell short in pressure values returned. I a comment Casey asked about some of the other pen data coming in. In this post I'll dive deeper into the many subtleties a pen can report to your apps.

    Pen input is collected using an InkCollector object, which can be wrapped up in another object like an InkOverlay. The InkCollector class is part of the managed API. It's constructor takes a windows handle, as long this handle points to a control within the process of your application you can scribble on that control. The application will be notified by events firing on the InkCollector. The raw data comes in packets. The NewInAirPackets event fires when a pen comes in the proximity of the control. (You don't have to touch the tablet's screen to see the mouse move). The NewPackets event fires when the pen actually touches the digitizer surface. The packet data is in the arguments of the event handler. What data these packets contain is up to the application. The Inkcollector object has a DesiredPacketDescription property which is an is array of guids. These guids are enumerated as static members of the PacketProperty class, also part of the manged API.

    This is quite an impressive list. Not every one of these has to be supported by your specific tablet, according to the specs only the X and Y position are mandatory. The nice thing about the tablet input system is that your application will not be bothered by any data it is not going use. For instance I can not imagine the pen's serialnumber being of any interest to the average scribbler. And I don't expect every tablet to provide something as complicated as the roll-rotation. You set up an array of pen properties your app is interested in and assign this array to the Inkcollector's DesiredPacketDescription. After that only packets containing that type of data will arrive in your inkcollector object. By default the InkCollector collects X, Y and pressure. The set of property-data you subscribe to can be pretty small. Only the X and the Y position is the bare minimum. That's about all data  a mouse can supply. You can draw with a mouse, but the stroke thickness is always the same as a mouse does not have a substitute for pressure. 

    To check which properties are supported by the tablet use the IsPacketPropertySupported method of the Tablet class. The DeviceWalker sample uses this method in combination with the enumeration to list all packet properties supported by the tablet. Also the PacketPropertyWatcher sample uses the method to build the checkboxlist. Only supported properties appear in the list. When you check a property it adds the packet property to the DesiredPacketDescription. Both my Acer Tablet PC and external Wacom tablet claim to support X, Y, status, timertick, pressure XTiltOrientatiton  and YTiltOrientatiton. But the latter two properties always have a value of 0 in the sample. I suspect a drawing application like ArtRage to do something with this property. A line drawn with a tilted pencil looks so different form one drawn with a pencil held upright. But on my tablet all lines look the same.

    So here is a difference between supporting a property of the pen and actually providing variation in the properties value. Combining that you could make a small tool to compare tablet (PC)'s. One which will list the supported properties as well as display the variations in the values coming in. Going to work on that and hope to have it available before Windows Anywhere. I am very curious what you will find on your tablets.

    See you in San Fransico.

    Peter

  • Adding an external tablet to a tablet PC and peaking around with the tablet API

    In a recent post I introduced my Wacom USB drawing tablet. When you attach that to a tablet PC (I use an Acer Travelmate C110) the functionality is far better than attached to a "normal" PC. The click-and-hold action, illustrated in the previous post, now works for the PC's pen and for the tablet's pen.

    For a more detailed exploration of this dual-tablet machine I'm going to use the samples which come with the "Building tablet applications book". The samples are organized in solutions, one solution for every chapter. Chapter 4 deals with input. That is the bare input, just the presence of a pen and motions it does make. No ink yet, that's another layer. The DeviceWalker sample enumerates all tablet devices found and their capabilities. The Tablets class in the API is the starting point, it is a collection of Tablet objects present. Every tablet has a number of properties, like the size of the input panel and it's hardware capabilities. The Devicewalker sums up the tablets found and displays their capabilities one at a time. You will see that the external Wacom is recognized and a full player.

    The only property which is different from the built in device is integrated. Makes sense, the tablet is external.

    The first opportunity to intercept the raw tablet input is by subscribing to events fired by the drivers of the hardware. There are quite a number of different events, from a tablet device being attached or removed to the pen hovering over the scribbling surface. In the InputWatcher sample you select subscriptions; the app will list the events coming in with some of the data. As in every .NET event the event data are in the second eventargs parameter. There are several tablet eventargs classes in the API, each of them with appropriate properties. The property almost all share is the CursorId. On a tablet every tip of a pen is a cursor and every cursor has an ID. The mouse has one (you can scribble with a mouse). The pen of a typical tablet usually has an eraser tip on the back, so the pen has two. The value in the event arguments will tell you which pen tip was used. The external pen of the Wacom has it's own ID.

    Here I first clicked the drawing surface with the mouse, then with the tablet's pen, with the tablets eraser and with the Wacom pen. The app reports the corresponding Id's.

    As a next experiment I tried changing the pens. Moving the Wacom pen over the display does move the mouse. But moving the PC's pen over the Wacom tablet did not result in any movement. Another difference is the thickness of the strokes drawn. A tablet pen is pressure sensitive, the harder you press, the thicker the line. Trying to draw with the Wacom pen on the PC's screen results in very thin lines when the sensitivity is set to "firm" and to no lines at all when set to “soft” tip. The inputwatcher does display the same events with both pens, the difference will be in the values of the data.

    When an event is fired a packet containing the input data is received. In this packet are things like the coordinates of the pen and the pen-pressure. Another sample application, the PacketPropertyWatcher inspects the packages arriving from the default tablet. That is the integrated digitizer, when you draw on the external this app does nothing. The sample displays the X and Y coordinates of the pen in tablet metrics. Which is far more precise than pixels. As a third value you can select the pressure applied to the pen.

    When drawing with the tablet pen this lists anything between 0 and 255, when using the Wacom pen it does not get past 16. It looks like the difference between the two pens is the strength of the pressure signal. As another alternative I tried the pens of various junior tablets, none of them resulted in any packet at all. So I am still waiting for the universal pen.

    I hope this gave you a glimpse of the architecture of the tablet input system. If you want to know more, do read the book, and come to Windows Anywhere.

    Peter

  • What's wrong with the pen buttons of a drawing tablet and what the Tablet PC does about it

    Despite my diversity in mice I still have a sore shoulder and hand. Anything which helps is welcome so I added a small Wacom drawing tablet. Pen input on a tablet PC works very well, pen input to my desktop is worth the try. The physical implementation of the device was somewhat disappointing, the Wacom thing is built as cheap as possible. Very light and only two out of the four feet are rubber. As a result the thing is somewhat slippery. But works. The pen is a reasonable substitute for the mouse. Clicking is a tap, double clicking is two taps. Works without a problem, just like the tablet PC pen you can adjust the tolerance in the distance of the two taps.

    To right-click there is a button on the pen. This is imho flawed by design. When you want to right click something you first point at it, then you finger has to find the button after which you click it. While finding the button your hand is most likely to move. As a result you're pointing at something else and will right-click that. A real tablet PC recognizes the click and hold action. Press something with the pen, like you want to drag it, but don't move the tip. After a short (again configurable) amount of time has passed the action is considered a right-click. The tablet does give a clear visual feedback:

    when the circle of dots is complete the mouse picture pops up. Works like a charm: press, hold, ready.

    The combination of a tablet and a desktop does not feel quite like a tablet yet. Attaching the (external) tablet to the tablet PC is quite another story. More on that in an upcoming post.

    Peter

  • Setup a new PC ? Start with MS -anti spyware

    Had to set up a new PC. The first piece of software I installed was the MS anti-syware. And I really enjoyed it. It is very informative in popping up messages on what is going on. Gives you a far better understanding what all the software you are installing is doing with your machine. The good thing is that it never gets in the way, the messages pop up (in the system tray) and go away without the need to click them. Except when there is a (potential) problem. Then it will give a clear suggestion what to do.

    I'm not quite sure how safe the machine is, but I do trust MS-ASW. Its usability really shines. Especially when compared to something like ad-aware.

    Peter

  • Building tablet applications, the book

    The only real developers book for Tablet PC's I know is "Building Tablet PC applications" by Rob Jarrett and Philip Su (MS press). A couple of reviews nominate that book as the printed form of the Tablet SDK help files. That's pretty unjust.

    A tablet PC is a machine running XP pro with extra's. Besides applications designed for the tablet you can run any existing Windows app on a Tablet. A tablet app will run on "normal" Windows as well, provided you include the right dll's in the setup. But over there it will not provide all Tablet functionality; a mouse can be used as a substitute for the pen but the text recognition just does not work. So it does make sense to add tablet functionality to an existing application as that will not make the application dependent on a tablet.

    The tablet SDK does comes with a lot of documentation. The nice thing about the tablet API is that is provides multiple program interfaces. Of course there are the managed API's but almost all functionality can also be addressed via good old COM. Besides a full reference of the classes in the API the SDK contains samples. These samples are written in a variety of languages and technologies, from C# to C++, from NET to COM. The SDK does not  make a choice which audience to target. The tablets COM api interface is the way to add tablet functionality to an existing C++ or VB6 application.

    Rob and Philips's book does make a choice: the managed API is the way to go, when you need the COM api you have to find the corresponding interfaces yourself. As both API's have the same structure that is not too difficult. When it comes to samples included the book really shines. A very well structured set of C# code samples clearly demonstrate the architecture of the Tablet API and how to build on that.

    The tablet PC is defined in the appendix, which lists the logo requirements:

    • A digitizer with pen meeting specific quality requirements.
    • Power management. The battery should last long enough and the machine should resume fast enough
    • Changing view mode (from portrait to landscape) without rebooting
    • Support surprise docking. That is: the user can pick up her tablet and walk away. The machine should handle the (for instance) bluetooth keyboard left behind without the need of user intervention.
    • Legacy free
    • Have a ctr-alt-del button

    Some of these points are broader than just the tablet. Take the surprise-undock requirement. This means that your apps cannot keep connections to databases or files open. When the resources are on a network whose connection is dependent on the docking state of the tablet you are in deep trouble when the user does walk away. But when you think of your tablet app as a disconnected web-client you are in the (hopefully) familiar asp.net world again.

    The book focuses on pen-input. The main part follows the API's architecture which is layered

    • Pen gestures and strokes
    • Collecting ink
    • Rendering ink
    • Serializing and persisting ink
    • Recognize ink as handwriting

    Pen input consists of gestures and strokes. In a separate layer these strokes are transferred to actions or ink, drawn on the screen, transformed or persisted. In another layer the strokes can be recognized as handwriting. The samples will guide you step by step, the illustrations make clear how the parts of the API stick together and how it fits into Windows.

    These main chapters are wrapped in an introduction to the history of the tablet and an investigation of the two ink enabled controls which come with the SDK. Having finished the book you will have a clear comprehension of building tablet apps. Keep it close at hand (an e-book version is included on the accompanying disk), scribble away and see you at Windows Anywhere

    Peter

  • The Consumer Electronics Show, Bill Gates and adultry

    Microsoft has published a video of Bill Gates' keynote on the CES. It is worth seeing. The CES is about all those new fascinating gadgets which are flooding the market. The video is fascinating because it “experiences” (the CES  buzzword) so well. You can browse through the entire show (over an hour) remarkably well. Almost as good as through a DVD, by far better than an VHS. While the media server is 100 of miles away on the net.

    It is worthwile to see the whole show. Not just because there are so many things going wrong: a malfunctioning remote control, a failing internet connection and a crashing Xbox. In case you are in a hurry : the most hilarious part, as promised in this post's title, is at 32:20.

    There is a more detailed review of the keynote on the Windows Super Site.

    Peter

  • From the trenches

    .Text - Application Error!

    Details

    ArgumentException
    The Blogspam with ParameterName @BlogSpam is already contained by another BlogspamCollection.

    Return to site

    (Don't give up the fight)

  • Adding images to a blog post

    An image says more than a thousand words. I like to add images to a my posts. In a comment on a decorated post, Ben asked how to do that. This my recipe:

    The result is that the image will show at the place of the <IMG> tag.

    Peter

     

  • Exploring a database with SQL enterprise manager's Diagram wizard

    A picture says more than a thousand words. I received an existing database to be used in an application. The database is pretty complex: it has over 40 tables and there is not that much documentation. The diagram wizard in the SQL enterprise manager proved very usefulll to generate some diagrams which displayed quite clearly what the database was about.

    When you create a new diagram in SQL manager a wizard pops up; it asks for a table to add to the diagram. The best part is the “Add related tables automaticaly” checkbox.

    When checking that the wizard adds all all tables having a primary or foreign key relation with the selected table and fits them in a quite nice layout.

    Impresive, but somewhat intimidating. You can set the number of levels you want to add. Raising this to two:

    Wow ! All of this without any manual manipulation. Very very usefull

    Peter

    Posted Jan 17 2005, 07:10 AM by pvanooijen with 5 comment(s)
    Filed under:
  • Virtual PC and FAT32

    Virtual PC virtualizes your hard disk into a single file. The maximum file size on FAT32 is 4GB, the maximum disk size in virtual PC is far larger. When you store your virtual PC on a machine with a FAT32 drive (as a surprise my tablet came with a FAT32 formated disk) virtual PC will split the virtual hard disk in several files. Leading in very worying error messages when you copy (part of) a virtual hard-disk. JoeN has a very nice post on this. Time for some hard core disk maintenance...

    Peter

  • 2005 as the ... sees it

    In every Dutch textbook on the development of Information systems is a set of cartoons of a swing in a tree. <update>It's international, Sashidar just posted an English version, here on the DNJ. </update> Trint-It has a lovely version of that to wish you an automated 2005. Enjoy ! (The foto is a real house which is their real office)

    Peter

  • Localhost, local network and sp2 (Cannot find server or dns error)

    Keeping a development webserver alive is almost a daytime task for me. Blogging some the tricks I learned lead to so much responses from fellow desperates. Most of the problems are due to a lack of rights. So here is another trick.

    I mainly use an XP localhost for development. To see how  the site behaves on a consumer's machine I take my wife's or the kid's XP home machine to view some pages. Since we have sp2 installed this no longer works out of the box, a request like http://Brochis/MyWebApp/ (Brochis is my VS box) would result in a “Cannot find server or dns error”. Here you bump your request agaianst the sp2 firewall. To be able to browse to a XP-pro “localhost” webserver from another machine in your local network you have to apply these settings on the webserver

    • Windows firewall
    • Exceptions
    • Add port 80
    • Set the scope to My network (subnet)

    Peter

  • Pixar Sun-set

    Every winter holiday me and my family visit the cinema to see the latest Pixar movie. Last year it was “Finding Nemo”, this year “the Incredibles”. Wow. Interesting detail: finding Nemo mentions Sun in the credits, the Incredibles Intel.

    Peter

  • C# vs Object Pascal/Delphi

    Before the .NET days I was a Delphi addict. When the first beta's of C# came out I started comparing Delphi vs. C#. Now Delphi has also jumped the .NET train there is a whole lot more to compare. I gave up on that but DerangedCode still keeps up. He compares Delphi, C#, C++ and Java. A detailed read.

    Peter

    Posted Jan 04 2005, 09:16 AM by pvanooijen with no comments
    Filed under:
More Posts

Our Sponsors

Free Tech Publications

This Blog

Syndication

News