The key problem with the code in my first post is that it renders all strokes the same. Even if they are selected. If you can tolerate this (it doesn't look too bad as you still get the selection frame), then go ahead and use that code.
Sadly, I'm a perfectionist. I searched long and hard for a built in way to get selected strokes drawn properly. Long story short: there isn't one. Fortunately, I stumbled upon a sample chapter from "Building Tablet PC Applications" which has a solution (talk about lucky)! The book looks like it's probably worth the money if you are serious about Tablet PC support, so I would suggest buying it.
Anyway, here's the newly modified OnPaint override (this is very close to the books code, with a few very minor alterations):
/// <summary>
/// Overrides <see cref="Control"/>.OnPaint.
/// </summary>
protected override void OnPaint( PaintEventArgs e )
{
base.OnPaint( e );
// Adjust for any change in the view position
HandleScroll();
// Doing all our redrawing here enables us to take
// full advantage of the automatic double buffering
ink.Renderer.Draw( e.Graphics, ink.Ink.Strokes );
// If you aren't selecting you can go home now :)
if ( inkMode != InkMode.Select )
return;
// Get the amount to increase size of selected lines
Point strokeExtra = new Point( 4, 4 );
ink.Renderer.PixelToInkSpace( e.Graphics, ref strokeExtra );
// Redraw the selection strokes as they should look
for( int i = 0; i < ink.Selection.Count; ++i )
{
// You could use foreach here for simplicity,
// but for is faster and faster is good here
Stroke stroke = ink.Selection[i];
DrawingAttributes da = stroke.DrawingAttributes.Clone();
// Draw the extra thick stroke
da.IgnorePressure = true;
da.Width += strokeExtra.X;
da.Height += strokeExtra.Y;
ink.Renderer.Draw( e.Graphics, stroke, da );
// Draw the white center
da.Width -= strokeExtra.X;
da.Height -= strokeExtra.Y;
// Uncomment these four lines to try something
// different when the stroke is a highlight. If
// you use this method, any stroke under the
// highlight will not be shown, and the white
// center will not be smoothed:
//ExtendedProperties ep = stroke.ExtendedProperties;
//if ( ep.DoesPropertyExist( HighlightGuid ) )
// da.RasterOperation = RasterOperation.White;
//else
da.Color = Color.White;
ink.Renderer.Draw( e.Graphics, stroke, da );
}
}
Notice the code that is commented out. This provides a slightly different method for displaying selected highlights. I recommend you try the code with and without this to see which you prefer (I prefer without). If you look at the very end of that sample chapter, you will find a slightly fancier way of drawing selected strokes that you could also use if you prefer.
By the way, all of this code should work if we derive from UserControl as well. In fact you should be able to inherit from any class that itself inherits from ScrollableControl.
So that concludes my ramblings about the Tablet PC. If you have anything else you want me to write about, please let me know (comments are best -- dodgy email still :) ).