Ejemplo n.º 1
0
        void reco_RWA(object sender, RecognizerContextRecognitionWithAlternatesEventArgs e)
        {
            if (textBox1.InvokeRequired)
            {
                // 当一个控件的InvokeRequired属性值为真时,说明有一个创建它以外的线程想访问它
                Action <string> actionDelegate = (x) => { this.textBox1.Text = x.ToString(); };
                // 或者
                // Action<string> actionDelegate = delegate(string txt) { this.label2.Text = txt; };
                this.textBox1.Invoke(actionDelegate, e.Result.TopString);
            }
            else
            {
                textBox1.Text = e.Result.TopString;
            }

            textBox1.Text = e.Result.TopString;
            // The handler receives a subclassed EventArgs object that
            // exposes the RecognitionResult object through a Result property.
            // The RecognitionResult object has four properties:
            // Strokes, TopAlternate, TopConfidence, and TopString.
            // The TopString property merely returns the ToString() value
            // of the TopAlternate object.  Finally, assign to the previously
            // declared class-level variable the RecognitionResult object
            // passed to the recognition event handler.

            recognitionResult = e.Result;
        }
Ejemplo n.º 2
0
        private void rct_RecognitionWithAlternates(object sender, RecognizerContextRecognitionWithAlternatesEventArgs e)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(DispatcherPriority.Send, new RecognizerContextRecognitionWithAlternatesEventHandler(rct_RecognitionWithAlternates), sender, e);

                return;
            }


            if (RecognitionStatus.NoError == e.RecognitionStatus)
            {
                this.panelChoose.Children.Clear();
                RecognitionAlternates allAlternates = e.Result.GetAlternatesFromSelection();
                // show each of the other alternates
                int    i       = 1;
                double width   = 56;
                double height  = 56;
                bool   isFirst = true;
                foreach (RecognitionAlternate oneAlternate in allAlternates)
                {
                    Label lbl = new Label();
                    lbl.Name     = "lbl" + i;
                    lbl.Tag      = oneAlternate.ToString();
                    lbl.Content  = lbl.Tag.ToString();
                    lbl.Width    = width;
                    lbl.Height   = height;
                    lbl.FontSize = 24F;
                    if (isFirst)
                    {
                        lbl.Width    = 172;
                        lbl.Height   = 172;
                        lbl.FontSize = 35F;
                        isFirst      = false;
                    }
                    lbl.FontFamily                 = new System.Windows.Media.FontFamily("微软雅黑");
                    lbl.BorderThickness            = new Thickness(1);
                    lbl.Margin                     = new Thickness(1, 1, 1, 1);
                    lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                    lbl.VerticalContentAlignment   = VerticalAlignment.Center;
                    lbl.BorderBrush                = border.BorderBrush;// System.Windows.Media.Brushes.Gray;
                    lbl.MouseLeftButtonDown       += new System.Windows.Input.MouseButtonEventHandler(lbl_MouseLeftButtonDown);
                    this.panelChoose.Children.Add(lbl);
                    ++i;
                }
            }
        }
Ejemplo n.º 3
0
        void rct_RecognitionWithAlternates(object sender, RecognizerContextRecognitionWithAlternatesEventArgs e)
        {
            string ResultString = "";
            RecognitionAlternates alts;

            if (e.RecognitionStatus == RecognitionStatus.NoError)
            {
                alts = e.Result.GetAlternatesFromSelection();
                foreach (RecognitionAlternate alt in alts)
                {
                    ResultString = ResultString + alt.ToString() + " ";
                }
            }
            FullCACText = ResultString.Trim();
            Control.CheckForIllegalCrossThreadCalls = false;
            textBox1.Text = FullCACText;
            Control.CheckForIllegalCrossThreadCalls = true;
        }
Ejemplo n.º 4
0
        void rct_RecognitionWithAlternates(object sender, RecognizerContextRecognitionWithAlternatesEventArgs e)
        {
            string ResultString="";
             RecognitionAlternates alts;

            if (e.RecognitionStatus == RecognitionStatus.NoError)
            {
                alts = e.Result.GetAlternatesFromSelection();

              foreach(RecognitionAlternate alt in alts)
              {
                  ResultString = ResultString + alt.ToString()+" ";
              }
            }
            FullCACText = ResultString.Trim();
            Control.CheckForIllegalCrossThreadCalls=false;
            textBox1.Text = FullCACText;
            返回识别字符处理(FullCACText);
            Control.CheckForIllegalCrossThreadCalls =true;
        }
Ejemplo n.º 5
0
 private void context_RecognitionWithAlternates(object sender, RecognizerContextRecognitionWithAlternatesEventArgs e)
 {
     if (_inkOverlay.AttachedControl.InvokeRequired)
     {
         HanziRecognizedEventArgs ev = new HanziRecognizedEventArgs();
         ev.BestResult = e.Result.TopString;
         ev.AlternativeResults = new List<string>();
         RecognitionAlternates alternates = e.Result.GetAlternatesFromSelection(0, e.Result.TopString.Length);
         foreach (RecognitionAlternate alternate in alternates)
             ev.AlternativeResults.Add(alternate.ToString());
         _inkOverlay.AttachedControl.Invoke(new HanziRecognizedHandler(OnThread_RecognitionWithAlternates), new object[] { sender, ev });
     }
 }