예제 #1
0
 public MathResult(Bitmap problem, Bitmap solved, MathAnswers answerSet, TimeSpan span)
 {
     problemScreenshot = problem;
     answerScreenshot  = solved;
     answers           = answerSet;
     executeTime       = span;
     log         = "";
     executeTime = new TimeSpan(0, 0, 0);
 }
예제 #2
0
        public static MathResult solveProblem(Bitmap problem)
        {
            DateTime callTime   = DateTime.Now;
            Bitmap   answerShot = new Bitmap(problem);

            List <MathCharacter> mathList = decipherMathFromArea(getBitmapFromRectangle(problem, QUESTION_DISPLAY));

            /*
             * result.appendLog("Problem mathList: ", newline: false);
             * foreach (MathCharacter character in mathList)
             *  result.appendLog(character.number, newline: false);
             * result.appendLog("");
             */

            int answer = calculateMathFromList(mathList);
            //result.appendLog("Answered successfully retrieved: " + answer);

            MathAnswers answerSet = decipherMathAnswers(problem, answer);

            //result.setAnswer(answerSet);

            using (Graphics g = Graphics.FromImage(answerShot))
            {
                g.DrawImage(problem, 0, 0);
                g.DrawString(answerSet.answer.ToString(), new Font("Arial", 48), new SolidBrush(Color.Aqua), new PointF(505, 600));
                Point curvePoint    = new Point(answerSet.answerPoint.X - 270, answerSet.answerPoint.Y - 30);
                Size  rectangleSize = new Size(540, 60);

                Pen pen;
                if (!answerSet.answerFound)                         //Red circle if guess
                {
                    pen = new Pen(Color.Red, 10.0f);
                }
                else                                                //Green circle if correct
                {
                    pen = new Pen(Color.Green, 10.0f);
                }

                g.DrawEllipse(pen, new Rectangle(curvePoint, rectangleSize));
            }

            MathResult result = new MathResult(problem, answerShot, answerSet, DateTime.Now - callTime);

            return(result);
        }