none
InkCanvas selection adorner RRS feed

  • Question

  • 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.

     

    Friday, December 22, 2006 7:11 AM

Answers

  • 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

     

    Wednesday, January 10, 2007 4:14 PM
  • 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

    Sunday, January 7, 2007 1:18 PM

All replies

  • 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

    Sunday, January 7, 2007 1:18 PM
  • 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
    Wednesday, January 10, 2007 9:21 AM
  • 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

     

    Wednesday, January 10, 2007 4:14 PM
  • 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

    Wednesday, January 10, 2007 4:32 PM
  • Hi Stefan,

    Do you have an updated link to your sample? It seems that GotDotNet.com has been shutdown.

    Cheers,

    Nilu
    Wednesday, January 6, 2010 3:42 AM
  • Ditto

    Would like to check it out as well
    Tuesday, March 9, 2010 9:27 PM
  • Hi Stefan,

    Do you have an updated link to your sample? It seems that GotDotNet.com has been shutdown.

    Cheers,

    Nilu
    +1
    Tuesday, July 13, 2010 8:26 PM
  • hi stefen,

     

    The site is http://wpf.netfx3.com/ not working and even this link

    is not working

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

    could u please give me this sample, I would be very grateful to you, its urgent pls

     

    thanks a lot in advance

    waasim

    Sunday, June 12, 2011 1:53 PM
  • http://archive.msdn.microsoft.com/InkCanvasRotationAdo/Release/ProjectReleases.aspx?ReleaseId=327
    • Proposed as answer by croonox Friday, December 16, 2011 9:53 AM
    Friday, December 16, 2011 9:52 AM
  • Hi @croonox &@stefan,

    Above links are not working, can you please help ?

    Thanks .

    Wednesday, August 22, 2018 11:46 AM