Exemple #1
0
        public void Prerecognize()
        {
            try
               {
               _canvas = new Canvas((Bitmap)_image.Clone(), 8.0d);
               _canvas.RecognizeImage();

               testsparam t = _ge.testsparams.First(tp => tp.idt == _testid);

               t.answersparams.Load();
               IEnumerable<answersparam> answers = t.answersparams.Where(a => a.idt == t.idt);
               foreach (answersparam a in answers)
               {
                   Distances _distances = new Distances();
                   _distances.Add(_canvas.TopLeftMarker, (double)a.toplx, (double)a.toply);
                   _distances.Add(_canvas.TopRightMarker, (double)a.toprx, (double)a.topry);
                   _distances.Add(_canvas.BottomLeftMarker, (double)a.blx, (double)a.bly);
                   _distances.Add(_canvas.BottomRightMarker, (double)a.brx, (double)a.bry);

                   Answer _answer = new Answer(_canvas.CorrectedImage, (int)a.num, (int)a.cellscount, _distances, (int)a.intercellswidth, (int)a.cellswidth, (int)a.cellshight);

                   IEnumerable<cellsparam> cells = a.cellsparams.Where(c => c.ida == a.ida);
                   a.cellsparams.Load();
                   int i = 0;
                   foreach (cellsparam cp in cells)
                   {
                       _answer.Cells[i].ContentDescription = cp.description.Trim();
                       i++;
                   }

                   _canvas.Answers.Add(_answer);
               }
               OnRecItem();
               }
               catch (Exception ex) { throw ex; }
        }
Exemple #2
0
        private void cmd_addtest_Click(object sender, EventArgs e)
        {
            this.lst_answ.Items.Clear();
            _canvas = new Canvas((Bitmap)this.pb_img.Image,8d);
            _canvas.RecognizeImage();
            this.pb_img.Image = _canvas.CorrectedImage;

               //KetelData td = new KetelData();
            pBaseEntities pb = new pBaseEntities();

               // modulData md = new modulData();
               // testsparam tst =  testsparam.Createtestsparam(0, "ОПРОСНИК МОДУЛЬ", 200, true);
               // for (int a = 0; a < tst.answerscount; a++)
               // {
               //     answersparam ap = answersparam.Createanswersparam(0, tst.idt, "Вопрос № " + (a + 1), 2);
               //     ap.num = a + 1;
               //     ap.buttondescription = md.answers[a].text;
               //     ap.intercellswidth = 27;
               //     ap.cellshight = 25;
               //     ap.cellswidth = 25;
               //     ap.toplx = 0;
               //     ap.toply = 0;
               //     ap.toprx = 0;
               //     ap.topry = 0;
               //     ap.blx = 0;
               //     ap.bly = 0;
               //     ap.brx = 0;
               //     ap.bry = 0;

               //     cellsparam cp = cellsparam.Createcellsparam(0, ap.ida);
               //     cp.description = "Да";
               //     cp.buttonsescription = "Да";
               //     cp.mark = md.answers[a].isYes?md.answers[a].mark:0;
               //     cellsparam cp1 = cellsparam.Createcellsparam(0, ap.ida);
               //     cp1.description = "Нет";
               //     cp1.buttonsescription = "Нет";
               //     cp1.mark = md.answers[a].isYes ? 0 : md.answers[a].mark;

               //     ap.cellsparams.Add(cp);
               //     ap.cellsparams.Add(cp1);

               //     tst.answersparams.Add(ap);

               // }

               //pb.testsparams.AddObject(tst);
               // pb.SaveChanges();

            testsparam t = pb.testsparams.First(tp => tp.idt == (int)EnumPTests.NPNA);
            t.answersparams.Load();
            IEnumerable<answersparam> answers = t.answersparams;

            foreach (answersparam ap in answers)
            {
                ListViewItem it = new ListViewItem(ap.num.ToString());
                it.SubItems.Add(ap.ida.ToString());
                it.SubItems.Add(ap.description.ToString());
                it.SubItems.Add(ap.intercellswidth.ToString());
                it.SubItems.Add(ap.cellswidth.ToString());
                it.SubItems.Add(ap.cellshight.ToString());
                it.SubItems.Add(ap.toplx.ToString());
                it.SubItems.Add(ap.toply.ToString());
                this.lst_answ.Items.Add(it);
                //добавляем вопросы на грид
                //создаем коллекцию дистанций для каждого ответа

                Distances _distances = new Distances();
                _distances.Add(_canvas.TopLeftMarker, (double)ap.toplx, (double)ap.toply);
                _distances.Add(_canvas.TopRightMarker, (double)ap.toprx, (double)ap.topry);
                _distances.Add(_canvas.BottomLeftMarker, (double)ap.blx, (double)ap.bly);
                _distances.Add(_canvas.BottomRightMarker, (double)ap.brx, (double)ap.bry);

                //_distances.Add(_canvas.TopLeftMarker, 100, 100);
                //_distances.Add(_canvas.TopRightMarker, 100, 100);
                //_distances.Add(_canvas.BottomLeftMarker, 100, 100);
                //_distances.Add(_canvas.BottomRightMarker, 100, 100);

                //создаем ответы
                Answer _answer = new Answer(_canvas.CorrectedImage, (int)ap.ida, (int)ap.cellscount, _distances, (int)ap.intercellswidth, (int)ap.cellswidth, (int)ap.cellshight);
                _answer.Select();
                _canvas.Answers.Add(_answer);

            }
        }