Ejemplo n.º 1
0
 private void MainInkCanvas_StylusLeave(object sender, StylusEventArgs e)
 {
     if (continuousAnalyze)
     {
         inkAnalyzer.BackgroundAnalyze();
     }
 }
Ejemplo n.º 2
0
        void _inkCanvas_StrokeCollected_StrokeToImage(object sender, InkCanvasStrokeCollectedEventArgs e)
        {
            InkCanvas inkCanvas = (InkCanvas)sender;

            if (analyze.RootNode.Strokes.IndexOf(inkCanvas.Strokes[inkCanvas.Strokes.Count - 1]) == -1)
            {
                analyze.AddStroke(inkCanvas.Strokes[inkCanvas.Strokes.Count - 1]);
            }
            analyze.BackgroundAnalyze();
            string analyzeStr = analyze.GetRecognizedString();
            //Stream streamOpen = new FileStream("pack://siteoforigin:,,,/xml/StrokeToImage.xml", FileMode.Open);//提示“不支持指定格式”
            Stream streamOpen = new FileStream(GlobalValues.FilesPath + "/WPFInk/WPFInk/bin/Debug/xml/StrokeToImage.xml", FileMode.Open);

            using (System.IO.StreamReader streamReader = new System.IO.StreamReader(streamOpen))
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                XmlReader         Reader   = XmlReader.Create(streamReader, settings);
                while (Reader.Read())
                {
                    if (Reader.NodeType == XmlNodeType.Element)
                    {
                        if (Reader.Name == "Image")
                        {
                            Reader.MoveToAttribute("stroke");
                            string strokeStr = Reader.Value;
                            Reader.MoveToAttribute("imageName");
                            searchStrokes(strokeStr, Reader.Value, inkCanvas);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void fireoff()
 {
     running = true;
     if (!inkAnalyzer.BackgroundAnalyze())
     {
         InkAnalyzer_ResultsUpdated(null, null);
     }
 }
 private void DispatcherTimer_Tick(object sender, EventArgs e)
 {
     m_analyzer.BackgroundAnalyze();
     dispatcherTimer.Stop();
     if (recognizer.CompletedOperation)
     {
         textResult   = "";
         textBox.Text = textResult;
     }
 }
Ejemplo n.º 5
0
    /// <summary>
    /// InkCanvas.StrokeCollected event handler.  Begins
    /// ink analysis and starts the timer to clear the strokes.
    /// If five seconds pass without a Stroke being added,
    /// the strokes on the InkCanvas will be cleared.
    /// </summary>
    /// <par    am name="sender">InkCanvas that raises the
    /// StrokeCollected event.</param>
    /// <param name="args">Contains the event data.</param>
    private void RestartAnalysis(object sender,
                                 InkCanvasStrokeCollectedEventArgs args)
    {
        // If strokeRemovalTimer is enabled, stop it.
        if (strokeRemovalTimer != null && strokeRemovalTimer.IsEnabled)
        {
            strokeRemovalTimer.Stop();
        }

        // Restart the timer to clear the strokes in five seconds
        strokeRemovalTimer = new DispatcherTimer(
            TimeSpan.FromSeconds(CLEAR_STROKES_DELAY),
            DispatcherPriority.Normal,
            ClearCanvas,
            Dispatcher.CurrentDispatcher);

        // Add the new stroke to the InkAnalyzer and
        // begin background analysis.
        analyzer.AddStroke(args.Stroke);
        analyzer.BackgroundAnalyze();
    }
Ejemplo n.º 6
0
        public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            InkCanvas inkCanvas  = (InkCanvas)sender;
            Stroke    lastStroke = inkCanvas.Strokes[inkCanvas.Strokes.Count - 1];

            if (analyze.RootNode.Strokes.IndexOf(lastStroke) == -1)
            {
                analyze.AddStroke(inkCanvas.Strokes[inkCanvas.Strokes.Count - 1]);
            }
            analyze.BackgroundAnalyze();
            string    analyzeStr = analyze.GetRecognizedString();
            MyGraphic MyGraphicContrainStroke = _inkCollector.Sketch.getMyGraphicContrainStroke(lastStroke);

            if (MyGraphicContrainStroke != null)
            {
                if (MyGraphicContrainStroke.textStrokeCollection.IndexOf(lastStroke) == -1)
                {
                    MyGraphicContrainStroke.addTextStroke(lastStroke);
                    MyGraphicContrainStroke.Text = analyzeStr;
                    //Console.WriteLine("analyzeStr:" + analyzeStr);
                }
            }
        }
Ejemplo n.º 7
0
 private void DispatcherTimer_Tick(object sender, EventArgs e)
 {
     Console.WriteLine("STOP");
     m_analyzer.BackgroundAnalyze();
     dispatcherTimer.Stop();
 }