Compartir a través de


Custom Ink Rendering in Silverlight 2

Drawing ink with the built-in stroke objects works great for handwriting and annotations. In some scenarios, however, you may want something more fancy that takes advantage of Silverlight's rich graphics capabilities.

Creating ink strokes with a customized appearance is fairly straight forward with Silverlight 2. You basically collect StylusPoints in mouse events as usual, but instead of adding them to stroke objects, you just draw your own geometries or shapes at the stylus/mouse location.

When collecting sample points during the MouseMove event, please be sure to call the StylusDevice.GetStylusPoints() method and process all points returned from that call. This will ensure that stylus users will get the full fidelity of input points, since their pointing device reports points more often than the MouseMove events fires. Also it is good practice to interpolate points between sample points, since they won't usually be equidistant.

I have a attached a sample project that demonstrates the concept end-to-end using Ellipse shapes with a LinearGradientBrush to give my ink strokes a custom look. Below is live version of the sample for you to play with.

CustomInkRendering.zip

Comments

  • Anonymous
    December 09, 2008
    I'm looking to get a tablet PC in January.. preferably one of the new multi touch ones. I'm looking forward to coding some ink specific apps. But can you answer me this. How come there is no amazing Tablet WPF interface examples? Surely WPF is the ideal technology to take advantage of touch based interfaces? I'm starting to save a collection of images of those wonderful futuristic touch screen computer interfaces you see in sci-fi shows/films like Stargate Atlantis, Ironman, etc with the aim of recreating them in WPF. How come this hasn't been done yet? -- Lee

  • Anonymous
    December 10, 2008
    I completely agree: WPF is an awesome platform for Tablet PC development. I have a couple of small WPF Tablet examples on my blog attached to earlier posts. The main reason I focus more on Silverlight examples recently is purely personal: because I work on the Silverlight team :-) Cheers, Stefan

  • Anonymous
    February 18, 2012
    I completely agree: WPF is an awesome platform for Tablet PC development