0

I used the ActiveCustomDrying to customize the ink, now I want to remove them InkStrokes. StrokeContainer is null because of active the CustomDrying, so I am unable to remove the InkStrokes by using the DeleteSelected method. Can anyone suggest me how to remove the InkStrokes when using the CustomDrying.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
Santhiya
  • 191
  • 2
  • 14

1 Answers1

0

During the custom drying, you will store the strokes in a custom List<InkStrokeContainer> collection:

private void InkPresenter_StrokesCollected(InkPresenter sender, InkStrokesCollectedEventArgs args)
{
    var strokes = _inkSynchronizer.BeginDry();

    var container = new InkStrokeContainer(); 
    container.AddStrokes(from item in strokes
        select item.Clone()); 
    _strokes.Add(container);

    _inkSynchronizer.EndDry();
}

Now you can manipulate the InkStrokeContainer instances manually (including calls to DeleteSelected).

The documentation also states that when using ActiveCustomDrying, erasing with InkToolbar does not work automatically and you need to handle the pointer events manually

If your app overrides the default ink rendering behavior of the InkPresenter with a custom drying implementation, the rendered ink strokes are no longer available to the InkToolbar and the built-in erase commands of the InkToolbar do not work as expected. To provide erase functionality, you must handle all pointer events, perform hit-testing on each stroke, and override the built-in "Erase all ink" command.

If you want to implement the commands, you will need to observe the Checked and Unchecked events of the toolbar buttons and then handle the pointer events yourself. A complete tutorial how to do this is available on MSDN.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • Yearly unclosed answer review - @Santhiya, if this heped, please consider accepting the answer as solution so that the question is closed. – Martin Zikmund Dec 06 '18 at 15:50