borice

Hello.

Is there any way to modify the default selection adorner in an InkCanvas For example, I would like to make the resize handles round instead of square, change their color, or even enable/disable some of them depending on the element selected.

If this is not possible with InkCanvas, where should I start to building towards this result

Thank you.



Re: Notebook, Tablet PC, and UMPC Development InkCanvas selection adorner

Stefan Wick - MSFT

Hi,

InkCanvas's selection adorner does not currently have a built-in extensibility mechanism. This is something we are looking into for future versions of WPF. There are two ways to do this today: (a) roll your own Ink control by using the building blocks we provide (InkPresenter, DynamicRenderer, etc.) and then implement your own selection adorner from scratch - or (b) derive from InkCanvas and add your own EditingMode that provides your specialized selection behavior.

Going down route (b) is probably faster and simpler. If you choose to go down route (a), you might find this article helpful:

http://msdn2.microsoft.com/en-gb/library/ms752334.aspx

Thanks, Stefan Wick






Re: Notebook, Tablet PC, and UMPC Development InkCanvas selection adorner

borice

Stefan,

Thanks for your answer.
Do you happen to have anything that would get me started on (b)

If I understand this correctly, I would need to create my own "selection" EditingMode (let's call it MySelectionEditingMode) that I will use in place of the default selection editing mode, like so:

whenever selection behavior is needed, instead of setting InkCanvas.EditingMode = InkCanvasEditingMode.Select I would set InkCanvas.EditingMode = (InkCanvasEditingMode)MySelectionEditingMode, where MySelectionEditingMode would be a constant with a value different from any found in the default InkCanvasEditingMode. [something tells me that's not going to work... ]

Then I will probably need to override OnStylusDown, OnStylusUp, OnStylusMove (and similarly for mouse events) and take care of the rendering of the lasso, the logic behind figuring out what has been selected based on the lasso, and finally drawing the selection adorner and custom handling everything regarding selection move, resize, etc... and their respective visual feedbacks.

I'm still not sure if this will work because if I then use the default implementation of InkCanvas.Select(...), wouldn't that mess things up

Is my analysis correct or have I understood this wrong

As I only have about 1 month experience with WPF (but enough experience with C# on .NET 2.0, and Tablet PC SDK), I guess I'm a little worried that going this deep in having to manually deal with lasso drawing and other such things might pose some challenges for me as I'm uncertain about what the best way to do this is in WPF.

Thank you very much for your assistance.

Regards,
Boris Capitanu




Re: Notebook, Tablet PC, and UMPC Development InkCanvas selection adorner

Stefan Wick - MSFT

Hi Boris,

it is actually easier than that. You can re-use the existing lasso functionality of the InkCanvasEditingMode.Select mode. Then, in the SelectionChanged event, you can get a reference to the selected strokes (and/or elements). Now clear the selection (to get rid of the standard adorner) and then bring up your custom adorner.

I have put together a sample app that demonstrates this with a simple, custom adorner that allows rotation of selected ink. I will put it up on http://wpf.netfx3.com/ once I have the permission to post there.

I'll post again with the actual link to the sample.

Thanks, Stefan Wick






Re: Notebook, Tablet PC, and UMPC Development InkCanvas selection adorner

borice

Stefan - thank you very much for your help. It's funny that as I was at lunch today thinking about what you said I also considered doing exactly what you said above... I'm happy that you confirmed my thoughts. Thanks again!

Boris





Re: Notebook, Tablet PC, and UMPC Development InkCanvas selection adorner

Stefan Wick - MSFT

I have posted the sample code here:

http://www.gotdotnet.com/Community/UserSamples/Details.aspx SampleGuid=9f509be2-b3e9-4bce-aaba-273ace83de2a

Thanks, Stefan Wick