private async void MySymbolCorrectnessPlayButton_Click(object sender, RoutedEventArgs e)
        {
            //
            //EnableStructureButtons(false);
            MyImage.Visibility = Visibility.Collapsed;

            // get the model and input strokes
            Sketch model = SketchTools.Clone(myTemplates[MyCurrentIndex]);
            Sketch input = Sketch.CreateStroke("", new List <InkStroke>(MyInkStrokes.GetStrokes()), myTimeCollection, 0, 0, BorderLength, BorderLength);

            // store and remove the original strokes from the ink canvas
            List <InkStroke> originalStrokes = SketchTools.Clone(new List <InkStroke>(MyInkStrokes.GetStrokes()));

            foreach (InkStroke stroke in MyInkStrokes.GetStrokes())
            {
                stroke.Selected = true;
            }
            MyInkStrokes.DeleteSelected();

            // set the animation colors
            SolidColorBrush modelBrush = new SolidColorBrush(Colors.Green)
            {
                Opacity = 1.0
            };
            SolidColorBrush inputBrush = new SolidColorBrush(Colors.Red)
            {
                Opacity = 1.0
            };

            // get the animations
            List <Storyboard> modelStoryboards = Helper.DisplaySymbol(MyCanvas, model.Strokes, modelBrush, SMALL_DOT_SIZE, STROKE_DURATION);
            List <Storyboard> inputStoryboards = Helper.DisplaySymbol(MyCanvas, input.Strokes, inputBrush, StrokeVisuals.Size.Width, STROKE_DURATION);

            // animate the feedback
            foreach (Storyboard storyboard in modelStoryboards)
            {
                storyboard.Begin();
            }
            foreach (Storyboard storyboard in inputStoryboards)
            {
                storyboard.Begin();
            }

            // re-add the original strokes to the ink canvas and re-enable return button
            int delay = STROKE_DURATION;
            await InteractionTools.Delay(delay);

            MyInkStrokes.AddStrokes(originalStrokes);

            //
            //EnableStructureButtons(true);
            MyImage.Visibility = Visibility.Visible;
        }
        private async void MyLoadFileButton_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker();

            picker.SuggestedStartLocation = PickerLocationId.Desktop;
            picker.ViewMode = PickerViewMode.List;
            picker.FileTypeFilter.Add("*");

            StorageFile file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }

            mySketch = await SketchTools.XmlToSketch(file, PEN_VISUALS);

            MyInkStrokes.Clear();
            MyInkStrokes.AddStrokes(mySketch.Strokes);
        }
        private async void MyStrokeOrderPlayButton_Click(object sender, RoutedEventArgs e)
        {
            // do not show feedback if canvas has no strokes
            if (MyInkStrokes.GetStrokes().Count <= 0)
            {
                return;
            }
            if (!myTechniqueRecognizer.StrokeCountResult)
            {
                return;
            }

            //
            EnableTechniqueButtons(false);

            // get the model and input strokes
            Sketch model = myTemplates[MyCurrentIndex];

            model = SketchTools.Clone(model);
            Sketch input = Sketch.CreateStroke("", new List <InkStroke>(MyInkStrokes.GetStrokes()), myTimeCollection, 0, 0, BorderLength, BorderLength);

            input = SketchTools.Clone(input);
            input = SketchTransformation.Resample(input, 128);

            // store and remove the original strokes from the ink canvas
            List <InkStroke> originalStrokes = SketchTools.Clone(new List <InkStroke>(MyInkStrokes.GetStrokes()));

            foreach (InkStroke stroke in MyInkStrokes.GetStrokes())
            {
                stroke.Selected = true;
            }
            MyInkStrokes.DeleteSelected();

            // set the animation colors
            SolidColorBrush modelBrush = new SolidColorBrush(Colors.Green)
            {
                Opacity = 1.0
            };
            SolidColorBrush inputBrush = new SolidColorBrush(Colors.Red)
            {
                Opacity = 1.0
            };

            // get the animations
            List <Storyboard> modelStoryboards = InteractionTools.DisplayPaths(MyCanvas, model.Strokes, modelBrush, LARGE_STROKE_SIZE, STROKE_DURATION);
            List <Storyboard> inputStoryboards = InteractionTools.DisplayPaths(MyCanvas, input.Strokes, inputBrush, SMALL_STROKE_SIZE, STROKE_DURATION);

            // animate the feedback
            foreach (Storyboard storyboard in modelStoryboards)
            {
                storyboard.Begin();
            }
            foreach (Storyboard storyboard in inputStoryboards)
            {
                storyboard.Begin();
            }

            // re-add the original strokes to the ink canvas and re-enable return button
            int delay = STROKE_DURATION * model.Strokes.Count;
            await InteractionTools.Delay(delay);

            MyInkStrokes.AddStrokes(originalStrokes);

            //
            EnableTechniqueButtons(true);
        }
        private void MyTransformDataButton_Click(object sender, RoutedEventArgs e)
        {
            if (mySketch == null || MyInkStrokes.GetStrokes().Count == 0)
            {
                return;
            }

            Sketch sketch = null;

            MyInkStrokes.Clear();
            sketch = SketchTools.Clone(mySketch);

            if (!MyResampleToggle.IsOn && !MyScaleToggle.IsOn && !MyTranslateToggle.IsOn && !MyFrameToggle.IsOn)
            {
                MyInkStrokes.AddStrokes(sketch.Strokes);
                return;
            }

            if (MyResampleToggle.IsOn)
            {
                int n = int.Parse(MyResampleCountTextBox.Text);

                sketch = SketchTransformation.Resample(sketch, n);
            }

            if (MyScaleToggle.IsOn)
            {
                double size = double.Parse(MyScaleSizeTextBox.Text);

                if (MyScaleSquareRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.ScaleSquare(sketch, size);
                }
                else if (MyScaleProportionalRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.ScaleProportional(sketch, size);
                }
                else if (MyScaleFrameRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.ScaleFrame(sketch, size);
                }
            }

            if (MyTranslateToggle.IsOn)
            {
                Point k = new Point(MyInkCanvas.ActualWidth / 2, MyInkCanvas.ActualHeight / 2);

                if (MyTranslateCentroidRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.TranslateCentroid(sketch, k);
                }
                else if (MyTranslateMedianRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.TranslateMedian(sketch, k);
                }
                else if (MyTranslateFrameRadio.IsChecked.Value)
                {
                    sketch = SketchTransformation.TranslateFrame(sketch, k);
                }
            }

            if (MyFrameToggle.IsOn)
            {
                List <InkStroke> frameStrokes = GetFrameStrokes(sketch);
                sketch.Strokes.AddRange(frameStrokes);
            }

            MyInkStrokes.AddStrokes(sketch.Strokes);
        }