Form Recognition Remove Undo Button

Javier R 211 Reputation points
2019-12-12T16:49:03.577+00:00

When I do the shape recognition I want to go back with the Undo button does not produce such action and including the delete button to erase what is done with the shape recognition.

ultimaizing WTS

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Richard Zhang-MSFT 6,936 Reputation points
    2019-12-13T02:28:01.68+00:00

    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