question

Jramos avatar image
Jramos asked ·

Form Recognition Remove Undo Button

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

windows-uwpwindows-uwp-xaml
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichardZhang-MSFT avatar image
RichardZhang-MSFT answered ·

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

6 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello: the problem is that I'm using WTS so Undo I have a clase.cs


0 Votes 0 · ·

I see. Can you post your shape recognition code? Where do they conflict with the existing Undo Service?

0 Votes 0 · ·

I Have this: I am using Window Template studio


private void Undo_Click(object sender, RoutedEventArgs e) { ClearSelection(); undoRedoService?.Undo();

      }


0 Votes 0 · ·

I created a same project using Windows Template Studio. There is no code for shape recognition in this project. May you add this function by self. So I want to ask what conflict there is between UndoService and your shape recognition code, how your shape recognition code was written, and whether it can be post here. This helps us reproduce your problem and find a solution.

0 Votes 0 · ·

Hi, Sorry to bother you, did you solve this problem, and is there anything else I can help you with?

0 Votes 0 · ·

I'm sorry to bother you. Is there any new development in your question?

0 Votes 0 · ·