Example #1
0
        /// <summary>
        /// Recognize ink data using the default recognizer.
        /// </summary>
        /// <returns>The string containing the top recognition result.</returns>
        protected String RecognizeInkData()
        {
            Debug.Assert(InkEnabled, null, "Client must be ink-enabled");

            // Obtain the ink associated with this control
            Ink ink = inkOverlay.Ink;

            if (ink.Strokes.Count > 0)
            {
                // Attempt to create a recognition context and use it to
                // retrieve the top alternate.
                try
                {
                    RecognizerContext recognizerContext = new RecognizerContext();
                    RecognitionStatus recognitionStatus;
                    recognizerContext.Strokes = ink.Strokes;
                    RecognitionResult recognitionResult = recognizerContext.Recognize(out recognitionStatus);
                    if ((recognitionStatus == RecognitionStatus.NoError) &&
                        (null != recognitionResult))
                    {
                        return(recognitionResult.TopString);
                    }
                }
                catch (Exception)
                {
                    // An exception will occur if the client does not have
                    // any handwriting recognizers installed on their system.
                    // In this case, we default to returning an empty string.
                }
            }

            return(String.Empty);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strokes"></param>
        internal String recognize(Strokes strokes, out RecognitionAlternates alternates)
        {
            RecognizerContext rc = new RecognizerContext();

            rc.Strokes = strokes;

            try {
                RecognitionStatus status;
                RecognitionResult result;
                result = rc.Recognize(out status);
                if (status == RecognitionStatus.NoError)
                {
                    RecognitionAlternates alternatives = result.GetAlternatesFromSelection();
                    alternates = alternatives;
                    return(result.TopString);
                }
                else
                {
                    Console.WriteLine("Error in recognition.");
                }
            }
            catch {
                Console.WriteLine("Exception in recognition.");
            }
            alternates = null;
            return(null);
        }
Example #3
0
        // Recognizes handwriting by using RecognizerContext
        private void buttonClick(object sender, RoutedEventArgs e)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                //theInkCanvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (RecognizerContext context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        context.Strokes = ink.Strokes;
                        RecognitionStatus status;

                        var result = context.Recognize(out status);

                        if (status == RecognitionStatus.NoError)
                        {
                            //textBox1.Text = result.TopString;
                            //else
                            MessageBox.Show("Recognition failed");
                        }
                    }
                    else
                    {
                        MessageBox.Show("No stroke detected");
                    }
                }
            }
        }
Example #4
0
        public string Recognize()
        {
            using (MemoryStream ms = new MemoryStream()) {
                // Build an inkCollector containing the strokes
                canvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (RecognizerContext context = recognizer.CreateRecognizerContext()) {
                    RecognitionStatus status;
                    context.Factoid = Factoid.WordList; // Magic smoke for name recognition
                    context.Strokes = ink.Strokes;

                    // Cannot do if there are no strokes
                    if (ink.Strokes.Count > 0)
                    {
                        var results = context.Recognize(out status);
                        if (status == RecognitionStatus.NoError)
                        {
                            return(results.ToString());
                        }
                    }
                }
            }

            return("");
        }
Example #5
0
        /// <summary>
        /// 文字認識処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            using (var ms = new MemoryStream())
            {
                theInkCanvas.Strokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (var context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        context.Strokes = ink.Strokes;
                        RecognitionStatus status;

                        var result = context.Recognize(out status);

                        if (status == RecognitionStatus.NoError)
                        {
                            textBox1.Text = result.TopString;
                        }
                        else
                        {
                            MessageBox.Show("認識に失敗しました");
                        }
                    }
                    else
                    {
                        MessageBox.Show("文字が検出されませんでした");
                    }
                }
            }
        }
Example #6
0
        private string[] Regconize()         // REM 识别 ptinfos 中的点
        {
            List <System.Drawing.Point> listpts = new List <System.Drawing.Point>();

            foreach (var i in ptinfos)
            {
                listpts.Add(i.ToDrawingPoint());
            }
            // REM 每一笔转换成stroke
            Stroke stroke = ink.CreateStroke(listpts.ToArray());

            // REM 添加到识别器的上下文
            recognizectx.Strokes.Add(stroke);
            RecognitionStatus recognizestatus = new RecognitionStatus();
            RecognitionResult recognizeresult = recognizectx.Recognize(out recognizestatus);
            // REM 识别器的所有选择
            RecognitionAlternates recognizealternates = recognizeresult.GetAlternatesFromSelection();
            // REM 列出识别器所识别出的内容
            List <string> result = new List <string>();

            for (var i = 0; i <= recognizealternates.Count - 1; i++)
            {
                string text = recognizealternates[i].ToString();
                // Console.WriteLine(text)
                result.Add(text);
            }
            return(result.ToArray());
        }
Example #7
0
        // Se produce el reconocimento al dispararse el timer
        private void Timer_Tick(object sender, EventArgs e)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                inkCanvas.Strokes.Save(ms);
                var ink = new Ink();
                ink.Load(ms.ToArray());
                using (RecognizerContext context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        context.Strokes = ink.Strokes;
                        RecognitionStatus status;
                        var result = context.Recognize(out status);

                        if (status == RecognitionStatus.NoError)
                        {
                            if (result == null)
                            {
                                ResetCanvasAndTimer();
                                return;
                            }

                            var resultString = result.TopString;

                            if (!isAcceptedChar(resultString))
                            {
                                ResetCanvasAndTimer();
                                return;
                            }

                            bool isNumeric = int.TryParse(resultString, out int number);

                            if (!isNumeric)
                            {
                                number = 0;
                            }

                            _solicitudCambioNúmero(number);
                            ResetCanvasAndTimer();
                        }
                    }
                }
            }
        }
Example #8
0
        /// <summary>
        /// Recognizes the text a shape forms, and updates the
        /// shape with the recognition results (the text and the
        /// likelihood that the recognition was correct).
        ///
        /// This method does not use the featureSketch argument.
        ///
        /// Postcondition: the shape is of type IO and its Name
        /// property tells what text it was recognized as.
        /// </summary>
        /// <param name="shape">The shape to recognize</param>
        /// <param name="featureSketch">Not used.</param>
        public override void recognize(Sketch.Shape shape, Featurefy.FeatureSketch featureSketch)
        {
            // Prepare the shape for recognition
            SketchOrInkConverter converter = new SketchOrInkConverter();

            _microsoftTextRecognizer.Strokes = converter.convertToInk(shape);

            // Try to recognize the shape
            RecognitionStatus status;
            RecognitionResult result;

            result = _microsoftTextRecognizer.Recognize(out status);

            // Origanize the results
            string shapeName   = "";
            float  probability = 0F;

            if ((result != null) && (status == RecognitionStatus.NoError))
            {
                shapeName = result.TopString;
                switch (result.TopConfidence)
                {
                case RecognitionConfidence.Poor:
                    probability = .1F;
                    break;

                case RecognitionConfidence.Intermediate:
                    probability = .5F;
                    break;

                case RecognitionConfidence.Strong:
                    probability = .9F;
                    break;
                }
            }

            // Update the shape to reflect these results
            if (debug)
            {
                Console.WriteLine("Found input/output label: " + shapeName + " (confidence = " + probability + ")");
            }
            shape.setRecognitionResults(LogicDomain.TEXT, probability, shapeName);
        }
Example #9
0
        /// <summary>
        /// Read a shape as text
        /// </summary>
        /// <param name="shape">the shape to recognize</param>
        /// <param name="confidence">how confident the reading is</param>
        /// <returns>the text string</returns>
        public string read(Sketch.Shape shape, out double confidence)
        {
            // Prepare the shape for recognition
            SketchOrInkConverter converter = new SketchOrInkConverter();

            _microsoftTextRecognizer.Strokes = converter.convertToInk(shape);

            // Try to recognize the shape
            RecognitionStatus status;
            RecognitionResult result;

            lock (_microsoftTextRecognizer)
            {
                result = _microsoftTextRecognizer.Recognize(out status);
            }

            // Origanize the results
            string shapeName = "";

            confidence = 0;
            if ((result != null) && (status == RecognitionStatus.NoError))
            {
                shapeName = result.TopString;
                switch (result.TopConfidence)
                {
                case RecognitionConfidence.Poor:
                    confidence = .1;
                    break;

                case RecognitionConfidence.Intermediate:
                    confidence = .5;
                    break;

                case RecognitionConfidence.Strong:
                    confidence = .9;
                    break;
                }
            }

            return(shapeName);
        }
        private void Timer_Tick(object sender, EventArgs e)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                calculatorCanvas.Strokes.Save(ms);
                var ink = new Ink();
                ink.Load(ms.ToArray());
                using (RecognizerContext context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        // Se borra la expresión del text box si se va a evaluar una nueva expresión
                        if (expressionDone)
                        {
                            resultBox.Text = "";
                            expressionDone = false;
                        }

                        context.Strokes = ink.Strokes;
                        RecognitionStatus status;
                        var result = context.Recognize(out status);
                        if (status == RecognitionStatus.NoError)
                        {
                            if (RB_Mode1.IsChecked == true)
                            {
                                HandleMode1(result);
                            }
                            else
                            {
                                HandleMode2(result);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Recognition failed");
                        }
                    }
                }
            }
        }
Example #11
0
        /// <summary>
        /// Event Handle recognize button click event
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void btnRecognize_Click(object sender, System.EventArgs e)
        {
            // Check to ensure that the user has at least one recognizer installed
            // Note that this is a preventive check - otherwise, an exception will
            // occur during recognition.
            if (0 == myRecognizers.Count)
            {
                MessageBox.Show("There are no handwriting recognizers installed.  You need to have at least one in order to recognize ink.");
            }
            else
            {
                // Note that the Strokes' ToString() method is a
                // shortcut  for retrieving the best match using the
                // default recognizer.  The same result can also be
                // obtained using the RecognizerContext.  For an
                // example, uncomment the following lines of code:
                //
                RecognizerContext myRecoContext = new RecognizerContext();
                myRecoContext.Factoid = "(0|1|X)";
                RecognitionStatus status;
                RecognitionResult recoResult;
                //
                myRecoContext.Strokes   = myInkCollector.Ink.Strokes;
                recoResult              = myRecoContext.Recognize(out status);
                txtResults.SelectedText = recoResult.TopString;

                //txtResults.SelectedText = myInkCollector.Ink.Strokes.ToString();

                // If the mouse is pressed, do not perform the deletion -
                // this prevents deleting a stroke that is still being drawn
                if (!myInkCollector.CollectingInk)
                {
                    // Once the strokes have been recognized, delete them
                    myInkCollector.Ink.DeleteStrokes();

                    // Repaint the drawing area
                    gbInkArea.Refresh();
                }
            }
        }
Example #12
0
        /// <summary>
        /// 笔记识别
        /// </summary>
        /// <param name="strokes"></param>
        /// <returns></returns>
        public List <string> Recognize(StrokeCollection strokes)
        {
            List <string> lstr = new List <string>();

            using (MemoryStream ms = new MemoryStream())
            {
                strokes.Save(ms);
                var ink = new Ink();
                ink.Load(ms.ToArray());
                using (RecognizerContext context = new RecognizerContext())
                {
                    if (ink.Strokes.Count > 0)
                    {
                        context.Strokes = ink.Strokes;
                        RecognitionStatus status;

                        var result = context.Recognize(out status);

                        if (status == RecognitionStatus.NoError)
                        {
                            //lstr.Add(result.TopString);//最可能的识别

                            //获取所有备选词
                            RecognitionAlternates alternates = result.GetAlternatesFromSelection(0, result.TopString.Length, 10);
                            foreach (RecognitionAlternate alternate in alternates)
                            {
                                lstr.Add(alternate.ToString());
                            }
                        }
                        //else
                        //    lstr.Add("识别失败");
                    }
                    //else
                    //    lstr.Add("没有侦测到签名");
                }
                return(lstr);
            }
        }
Example #13
0
        //Attempt to recognize an edge weight
        private void RecognizeWeight()
        {
            edgeTimer.Stop();
            //If there are no strokes in the recognizer or no edge hit, return
            if (myRecognizer.Strokes.Count <= 0 || prevEdgeHit == null)
            {
                return;
            }
            RecognitionStatus status;
            //Recognize the contents of the recognizer
            string s = myRecognizer.Recognize(out status).TopString;

            //Replace all letters that look like numbers with their appropriate numbers
            s = s.Replace("l", "1");
            s = s.Replace("I", "1");
            s = s.Replace("|", "1");
            s = s.Replace("\\", "1");
            s = s.Replace("/", "1");
            s = s.Replace("s", "5");
            s = s.Replace("S", "5");
            s = s.Replace("o", "0");
            s = s.Replace("O", "0");
            //Attempt to parse into a number
            try
            {
                weight             = Int32.Parse(s);
                prevEdgeHit.Weight = weight;
            }
            catch
            {
                Console.WriteLine("Sorry, " + s + " isn't a number.");
                weight = -1;
            }
            prevEdgeHit = null;
            weight      = -1;
            myRecognizer.Strokes.Ink.DeleteStrokes(myRecognizer.Strokes);
            myRecognizer.Strokes.Clear();
        }
Example #14
0
        /// <summary>
        /// Performs stroke-to-text recognition on all strokes added with
        /// <see cref="AddStroke(TouchStroke)"/>. An empty list is returned
        /// if no matches were found. You may modify the returned list.
        /// </summary>
        /// <param name="maxResults">Maximum number of results to return.</param>
        /// <exception cref="InvalidOperationException">
        /// Thrown if no recognizer implementation has been set.
        /// </exception>
        /// <exception cref="StrokeRecognitionException">
        /// Thrown if stroke recognition failed.
        /// </exception>
        public List <string> Recognize(int maxResults = 10)
        {
            EnsureNotDisposed();
            if (_recognizerContext == null)
            {
                throw new InvalidOperationException("Recognizer not set");
            }
            if (_strokes.Count == 0)
            {
                return(new List <string>());
            }
            _recognizerContext.Strokes = _strokes;
            RecognitionStatus status;
            RecognitionResult recognizeResult = _recognizerContext.Recognize(out status);

            if (status != RecognitionStatus.NoError)
            {
                throw new StrokeRecognitionException("Recognition status: " + status);
            }
            RecognitionAlternates alternates;

            try
            {
                alternates = recognizeResult.GetAlternatesFromSelection(0, -1, maxResults);
            }
            catch (Exception ex)
            {
                throw new StrokeRecognitionException("Failed to get alternates", ex);
            }
            List <string> results = new List <string>(alternates.Count);

            foreach (RecognitionAlternate alternate in alternates)
            {
                results.Add(alternate.ToString());
            }
            return(results);
        }
        private void InkCanvas_SelectionChanged(object sender, EventArgs e)
        {
            var selectedStrokes = InkCanvas.GetSelectedStrokes();

            using (MemoryStream ms = new MemoryStream())
            {
                selectedStrokes.Save(ms);
                var myInkCollector = new InkCollector();
                var ink            = new Ink();
                ink.Load(ms.ToArray());

                using (RecognizerContext myRecoContext = new RecognizerContext())
                {
                    RecognitionStatus status = RecognitionStatus.ProcessFailed;
                    myRecoContext.Strokes = ink.Strokes;
                    try
                    {
                        var recoResult = myRecoContext.Recognize(out status);

                        if (status == RecognitionStatus.NoError)
                        {
                            textBlock.Text = recoResult.TopString;
                            //InkCanvas.Strokes.Clear();
                        }
                        else
                        {
                            MessageBox.Show("ERROR: " + status.ToString());
                        }
                    }
                    catch (Exception)
                    {
                        //MessageBox.Show("ERROR: " + status.ToString());
                    }
                }
            }
        }
 /// <summary>
 /// obtains and returns alternative recognition results
 /// </summary>
 /// <param name="strokes">the strokes to be recognized</param>
 /// <returns>list of alternative</returns>
 private RecognitionAlternates getAlternative(Strokes strokes)
 {
     try
     {
         RecognizerContext context = new RecognizerContext();
         context.Strokes = strokes;
         RecognitionStatus     status;
         RecognitionResult     result = context.Recognize(out status);
         RecognitionAlternates ra;
         if (RecognitionStatus.NoError == status)
         {
             ra = result.GetAlternatesFromSelection();
         }
         else
         {
             ra = null;
         }
         return(ra);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strokes"></param>
        internal String recognize(Strokes strokes, out RecognitionAlternates alternates)
        {
            RecognizerContext rc = new RecognizerContext();
            rc.Strokes = strokes;

            try {
                RecognitionStatus status;
                RecognitionResult result;
                result = rc.Recognize(out status);
                if (status == RecognitionStatus.NoError) {
                    RecognitionAlternates alternatives = result.GetAlternatesFromSelection();
                    alternates = alternatives;
                    return result.TopString;
                }
                else {
                    Console.WriteLine("Error in recognition.");
                }
            }
            catch {
                Console.WriteLine("Exception in recognition.");
            }
            alternates = null;
            return null;
        }
Example #18
0
        //Checks if it's correct or not
        private void recogBtn_Click(object sender, EventArgs e)
        {
            context.Strokes = this.inkOverlay.Ink.Strokes;

            try
            {
                RecognitionStatus status;
                RecognitionResult result = context.Recognize(out status);

                if (result.TopString == levelStr)
                {
                    MessageBox.Show("Correct");
                    DialogResult diagRes = MessageBox.Show("Do you want to proceed or try again?", "important", MessageBoxButtons.YesNo);

                    //Change theme, if colorblind and progress to new level
                    if (diagRes == DialogResult.Yes)
                    {
                        this.Hide();
                        //Create a method that says "solved" after each level on the button
                        //xxxxxxxx

                        if (isColorBlind == true)
                        {
                            updateLevelProgress();
                            newLevel(isColorBlind);
                            saveLevelProgress(levelStr);
                        }
                        else
                        {
                            updateLevelProgress();
                            newLevel(isColorBlind);
                            saveLevelProgress(levelStr);
                        }
                    }
                    //Otherwise, repeat the level
                    else if (diagRes == DialogResult.No)
                    {
                        if (isColorBlind == true)
                        {
                            repeatLevel(isColorBlind);
                        }
                        else
                        {
                            repeatLevel(isColorBlind);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Wrong");
                }
            }
            catch (Exception)
            {
                //For the lulz -- just change it later lol !
                MessageBox.Show("No input has been detected!");
                //MessageBox.Show(ex.ToString());
            }
            //MessageBox.Show(result.TopString);
            //context.Dispose();
        }
        //Recognizes the stroke
        private void recogClick(object sender, EventArgs e)
        {
            if (inkCanvas.Strokes.Count > 0)
            {
                StrokeCollection strokeList = inkCanvas.Strokes;
                //save the strokes
                MemoryStream ms = new MemoryStream();

                inkCanvas.Strokes.Save(ms);

                InkCollector collector = new InkCollector();
                Ink ink = new Ink();
                ink.Load(ms.ToArray());

                try
                {
                    context = new RecognizerContext();
                    RecognitionStatus status;
                    RecognitionResult result;
                    context.Strokes = ink.Strokes;
                    result = context.Recognize(out status);
                    if (result.TopString == levelStr)
                    {
                        resultStr = "WON";
                        resultSplash = new ResultSplashScreen();
                        resultSplash.Show();
                        Thread.Sleep(1000);
                        resultSplash.Close();

                        MessageBoxResult diagRes = MessageBox.Show("Do you want to proceed?\nYes to Proceed\nNo to Try Again", "important", MessageBoxButton.YesNo, MessageBoxImage.Question);

                        //Change theme, if colorblind and progress to new level
                        if (diagRes == MessageBoxResult.Yes)
                        {
                            write.Hide();
                            //Create a method that says "solved" after each level on the button
                            //xxxxxxxx

                            if (isColorBlind == true)
                            {
                                write.updateLevelProgress();
                                write.newLevel(isColorBlind);
                                write.saveLevelProgress(levelStr);
                            }
                            else
                            {
                                write.updateLevelProgress();
                                write.newLevel(isColorBlind);
                                write.saveLevelProgress(levelStr);
                            }
                        }
                        //Otherwise, repeat the level
                        else if (diagRes == MessageBoxResult.No)
                        {
                            if (isColorBlind == true)
                            {
                                write.repeatLevel(isColorBlind);
                            }
                            else
                            {
                                write.repeatLevel(isColorBlind);
                            }
                        }
                    }
                    else
                    {
                        resultStr = "LOSE";
                        resultSplash = new ResultSplashScreen();
                        resultSplash.Show();
                        Thread.Sleep(1000);
                        resultSplash.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                //Clear strokes after every try
                inkCanvas.Strokes.Clear();
            }
            else
            {
                MessageBox.Show("Nothing");
            }
        }
        private void BodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            using (var frame = e.FrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    frame.GetAndRefreshBodyData(_bodies);

                    Body body = _bodies.Where(b => b.IsTracked).FirstOrDefault();

                    if (body != null)
                    {
                        Joint handRight = body.Joints[JointType.HandRight];

                        if (handRight.TrackingState != TrackingState.NotTracked)
                        {
                            CameraSpacePoint handRightPosition = handRight.Position;
                            ColorSpacePoint  handRightPoint    = _sensor.CoordinateMapper.MapCameraPointToColorSpace(handRightPosition);

                            float x = handRightPoint.X;
                            float y = handRightPoint.Y;

                            if (!float.IsInfinity(x) && !float.IsInfinity(y))
                            {
                                if (body.HandRightState == HandState.Lasso)
                                {
                                    KinectMouseMethods.SendMouseInput((int)x, (int)y, (int)trail.Width, (int)trail.Height, true);
                                }
                                if (body.HandRightState == HandState.Open)
                                {
                                    KinectMouseMethods.SendMouseInput((int)x, (int)y, (int)trail.Width, (int)trail.Height, false);
                                }
                                if (body.HandRightState == HandState.Closed)
                                {
                                    KinectMouseMethods.SendMouseInput((int)x, (int)y, (int)trail.Width, (int)trail.Height, false);
                                    using (MemoryStream ms = new MemoryStream())
                                    {
                                        trail.Strokes.Save(ms);
                                        var myInkCollector = new InkCollector();
                                        var ink            = new Ink();
                                        ink.Load(ms.ToArray());

                                        using (RecognizerContext context = new RecognizerContext())
                                        {
                                            if (ink.Strokes.Count > 0)
                                            {
                                                context.Strokes = ink.Strokes;
                                                RecognitionStatus status;
                                                var result = context.Recognize(out status);
                                                if (status == RecognitionStatus.NoError)
                                                {
                                                    if (result.TopString == "&" || result.TopString == "&")
                                                    {
                                                        textBox.Text += " ";
                                                    }
                                                    else if (result.TopString == "|" && textBox.Text != "")
                                                    {
                                                        textBox.Text = textBox.Text.Remove(textBox.Text.Length - 1);
                                                    }
                                                    else
                                                    {
                                                        textBox.Text += result.TopString;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    trail.Strokes.Clear();
                                }
                            }
                        }
                    }
                }
            }
        }
        //Recognizes the stroke
        private void recogClick(object sender, EventArgs e)
        {
            if (inkCanvas.Strokes.Count > 0)
            {
                StrokeCollection strokeList = inkCanvas.Strokes;
                //save the strokes
                MemoryStream ms = new MemoryStream();

                inkCanvas.Strokes.Save(ms);

                InkCollector collector = new InkCollector();
                Ink          ink       = new Ink();
                ink.Load(ms.ToArray());

                try
                {
                    context = new RecognizerContext();
                    RecognitionStatus status;
                    RecognitionResult result;
                    context.Strokes = ink.Strokes;
                    result          = context.Recognize(out status);
                    if (result.TopString == levelStr)
                    {
                        resultStr    = "WON";
                        resultSplash = new ResultSplashScreen();
                        resultSplash.Show();
                        Thread.Sleep(1000);
                        resultSplash.Close();

                        MessageBoxResult diagRes = MessageBox.Show("Do you want to proceed?\nYes to Proceed\nNo to Try Again", "important", MessageBoxButton.YesNo, MessageBoxImage.Question);

                        //Change theme, if colorblind and progress to new level
                        if (diagRes == MessageBoxResult.Yes)
                        {
                            write.Hide();
                            //Create a method that says "solved" after each level on the button
                            //xxxxxxxx

                            if (isColorBlind == true)
                            {
                                write.updateLevelProgress();
                                write.newLevel(isColorBlind);
                                write.saveLevelProgress(levelStr);
                            }
                            else
                            {
                                write.updateLevelProgress();
                                write.newLevel(isColorBlind);
                                write.saveLevelProgress(levelStr);
                            }
                        }
                        //Otherwise, repeat the level
                        else if (diagRes == MessageBoxResult.No)
                        {
                            if (isColorBlind == true)
                            {
                                write.repeatLevel(isColorBlind);
                            }
                            else
                            {
                                write.repeatLevel(isColorBlind);
                            }
                        }
                    }
                    else
                    {
                        resultStr    = "LOSE";
                        resultSplash = new ResultSplashScreen();
                        resultSplash.Show();
                        Thread.Sleep(1000);
                        resultSplash.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                //Clear strokes after every try
                inkCanvas.Strokes.Clear();
            }
            else
            {
                MessageBox.Show("Nothing");
            }
        }