Hello,
Welcome to our Microsoft Q&A platform!
Are you referring to shape recognition in InkAnalyzer
? Currently, InkAnalyzer
does not provide operations such as undo, because it does not need to keep history. If you need to do it yourself.
This is a simple idea for a step back operation (based on windows-universal-samples InkAnalysis)
//create history record
private List RemovedStorkes = new List();
private Shape LastShape = null;
//Add Stroke to history list before removing Stroke
private void ConvertShapes()
{
....
RemovedStorkes.Clear();
// Select the strokes that were recognized, so we can delete them.
// The effect is that the shape added to the canvas replaces the strokes.
foreach (var strokeId in shape.GetStrokeIds())
{
InkStroke stroke = inkPresenter.StrokeContainer.GetStrokeById(strokeId);
stroke.Selected = true;
RemovedStorkes.Add(stroke);
}
....
}
// Add history while doing shape conversion
private void AddPolygonToCanvas(InkAnalysisInkDrawing shape)
{
...
LastShape = polygon;
}
//Undo
private void UndoButton_Click(object sender, RoutedEventArgs e)
{
inkPresenter.StrokeContainer.AddStrokes(RemovedStorkes.Select(p=>p.Clone()));
RemovedStorkes.Clear();
canvas.Children.Remove(LastShape);
LastShape = null;
}
This is a history implementation, if you need more effects, please implement it yourself.
Thanks