How to remove the InkStroke when using the ActiveCustomDrying in uwp?

纵然是瞬间 提交于 2019-12-11 16:48:52

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/48436425/how-to-remove-the-inkstroke-when-using-the-activecustomdrying-in-uwp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!