private async void DispatcherTimer_Tick(object sender, object e)
        {
            StopTimer();
            try
            {
                inkRecognizer.ClearStrokes();
                var strokeContainer = inkCanvas.InkPresenter.StrokeContainer;
                foreach (Windows.UI.Input.Inking.InkStroke stroke in strokeContainer.GetStrokes())
                {
                    inkRecognizer.AddStroke(stroke);
                }
                var status = await inkRecognizer.RecognizeAsync();

                if (status == HttpStatusCode.OK)
                {
                    var root = inkRecognizer.GetRecognizerRoot();
                    if (root != null)
                    {
                        output.Text = OutputWriter.Print(root);
                    }
                }
                else
                {
                    output.Text = OutputWriter.PrintError($"Http Status: {status}");
                }
            }
            catch (Exception ex)
            {
                output.Text = OutputWriter.PrintError(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        /*
         * private async void DispatcherTimer_Tick(object sender, object e)
         * {
         *  //StopTimer();
         *
         *  try
         *  {
         *      var status = await inkRecognizer.RecognizeAsync();
         *      if (status == HttpStatusCode.OK)
         *      {
         *          var root = inkRecognizer.GetRecognizerRoot();
         *          if (root != null)
         *          {
         *              output.Text = OutputWriter.Print(root);
         *          }
         *      }
         *  }
         *  catch(Exception ex)
         *  {
         *      output.Text = OutputWriter.PrintError(ex.Message);
         *  }
         * }
         */
        private async void OnClickRecognize(object Sender, RoutedEventArgs e)
        {
            try
            {
                var status = await inkRecognizer.RecognizeAsync();

                if (status == HttpStatusCode.OK)
                {
                    var root = inkRecognizer.GetRecognizerRoot();
                    if (root != null)
                    {
                        //output.Text = OutputWriter.Print(root) + inkRecognizer.json;
                        output.Text = OutputWriter.Print(root);
                        Debug.Write(inkRecognizer.json);
                        StorageFile outputFile = await DownloadsFolder.CreateFileAsync("intermediary.json");

                        if (outputFile != null)
                        {
                            // Store file permissions for future access
                            Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(outputFile);

                            // Convert to Binary Buffer
                            var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(inkRecognizer.json, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);
                            await Windows.Storage.FileIO.WriteBufferAsync(outputFile, buffer);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                output.Text = OutputWriter.PrintError(ex.Message);
            }
        }
        private async void DispatcherTimer_Tick(object sender, object e)
        {
            StopTimer();

            try
            {
                var status = await inkRecognizer.RecognizeAsync();

                if (status == HttpStatusCode.OK)
                {
                    var root = inkRecognizer.GetRecognizerRoot();
                    if (root != null)
                    {
                        output.Text = OutputWriter.Print(root);
                    }
                }
            }
            catch (Exception ex)
            {
                output.Text = OutputWriter.PrintError(ex.Message);
            }
        }