using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Ink;
using System.Collections.ObjectModel;

namespace InkCanvas
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            if (inkCanvas.IsGestureRecognizerAvailable)
            {

                inkCanvas.SetEnabledGestures(new ApplicationGesture[] 
                    {ApplicationGesture.AllGestures
                    });
            }


        }
        void inkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e)
        {
            ReadOnlyCollection<GestureRecognitionResult> gestureResults =
                e.GetGestureRecognitionResults();
            if (gestureResults[0].RecognitionConfidence ==
                RecognitionConfidence.Strong)
            {
                textBlock1.Text = gestureResults[0].ApplicationGesture.ToString();
            }
            else
            {
                textBlock1.Text = "";
            }
        }

        private void editingMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (inkCanvas.IsGestureRecognizerAvailable)
            {
                if ((sender as ListBox).SelectedItem.Equals(InkCanvasEditingMode.GestureOnly) ||
                    (sender as ListBox).SelectedItem.Equals(InkCanvasEditingMode.InkAndGesture))
                {
                    inkCanvas.Gesture += new InkCanvasGestureEventHandler(inkCanvas_Gesture);
                }
                else
                {
                    inkCanvas.Gesture -= new InkCanvasGestureEventHandler(inkCanvas_Gesture);
                    textBlock1.Text = "";
                };
            }
        }

    }
}
