Tablets Vista and WPF - Part II

Published 27 May 7 9:41 PM | William

Well, in the first part, I said I was going to start working on getting it working with WPF/E Silverlight.  All I realized was that it looked a little easier than I first thought.  Anyway, I wanted to play with a few tweaks first.

So I added a few buttons.  One to perform Recognitions.  Another to Speak the text that was recognized if there was in fact any text recognized.  There are a lot of possibilities in terms of productivity apps that you could make here.  So let's say I was doing a little Janusian Thinking and figured I'd write the first thing that came to my mind...

I'd ink some text, then check the Title of my WPF form to make sure it worked.  If it works correctly, the Form's Title will match what was scribbled, in the first case it does:


Janusian Thinking 1

Cool, that worked.  Now, I let my mind wander a little more, let me see if it can do something a little more complex:


Janusian Thinking 1

Well, the first one was clearly correct, the second one though, LearnASP Six?  Wrong Vowel for sure.  But that's mainly b/c of my terrible handwriting, if I write it a little more clearly, it gets it right no problem (more on this later);

 So first, I just create an System.Windows.Ink.InkAnalyzer object scoped for the class, instantiate it in the constructor, and use the following to Analyze the strokes. I create a property named TextToSpeak which I set after the recognition.  This is used in the Speech portion of the application.


if (icMain.Strokes != null && icMain.Strokes.Count > 0)
{
   azr.AddStrokes(icMain.Strokes);//Add strokes from the InkCanvas to the Analyzer
   azr.Analyze(); //This coverts the strokes to text if possible
   this.TextToSpeak = azr.GetRecognizedString();//If text was recognized, this is it.
   this.Title = this.TextToSpeak;
}

To get the app to speak, it's laughably easy.  Using the System.Speech namespace on Vista, it couldn't be easier:


SpeechSynthesizer sz = new SpeechSynthesizer();
sz.SpeakAsync(this.TextToSpeak);

Depending on how close your recognition gets to real language, you'll be very impressed by how well and how accurately the Speech Synthesizer works.

I have a form that doesn't lend itself well to screen shots unless it's shrunken down which I started working on to let you scribble away. When you're done, you can use Speech commands to open the file into your app and have it read back whatever you scribbled.  There's a lot of software that already does this stuff for you, but it's pretty cool to use to familiarize yourself with some of these APIs.

 This is a really basic intro to Recognitions and it gets a lot more involved than this if you want it to. As I add more features to the app, I'll illustrate them.  My Homie Frank LaVigne has written quite a bit on this subject and his blog is a goldmine for finding more resources on Tablet. 

To be honest, most of what I covered is extremely basic, so much so it's not even blog worthy if it weren't for the fact that, well, it's done in WPF.  Until recently I never really used the WPF Inking features and for some reason, it never dawned on me there'd be specific Tablet Support.  Once again, I was wrong and quite pleasantly surprised.

The more I tried digging into WPF/E Silverlight, the more I realized it was going to be a bit of a challenge to get everything to work the way I wanted.  What I'm sort of looking to do is use a fixed set of recognizable gestures to control media - like Fast Forward with strokes, Record with a Circular stroke, Triangle for Play - you get the idea.   But I need to spend some more time doing and less time talking about it, so off I go.

 

 

 

 

Search

This Blog

Tags

Community

Archives

News

  • William G Ryan William Ryan Bill Ryan W.G. Ryan Charles Mark Carroll Charles M Carroll
    My Blog Juice Microsoft MVP
    Bill Ryan W.G. Ryan William Ryan
    Cuckooz' MySpace Page View Bill Ryan's profile on LinkedIn
    My Profile on Twitter
    Please note that this is my personal blog and the opinions expressed are my own. Also, comment moderation is about one of the least important things in my life so please keep that in mind. I can't vouch for the authenticity of any of the posters so please don't hold me accountable. And whatever you do, don't pretend to be Noted Option Strict Off expert and AspFriend Charles Mark Carroll when you post. Doing so will lead him to become apoplectic and write absurd accusatory posts about me that are as coherent and thought out as they are factually correct. He does a stellar job proving his reputation is well deserved and he doesn't need any help from you making himself look foolish. If I have to listen to him banging his spoon off of his high chair one more time, I'm going to burst into flames so please don't make that happen!

    My other sites

    Cool Stuff

    Book Stuff

    Security

    ORM

    Data Access

    Funny Stuff

    Compact Framework Stuff

    Web Casts

    My KnowledgeBase Articles

    My MVP Profile

    Design Patterns

    Performance

    Debugging

    Remoting

    My Fellow Authors

    My Books

    LINQ

    Misc

    Speech

    Syndication

    Email Notifications