Пример #1
0
        private bool DoPageSetup(DataGridViewCell cell, bool stayOnPage)
        {
            object ff = cell.Tag;

            int newPage = 0;

            if (ff is OmrCollection)
            {
                OmrCollection    oc = ff as OmrCollection;
                ReviewParameters rp = (ReviewParameters)oc.Tag;
                newPage = rp.PageNumber;
            }
            else if (ff is Field)
            {
                Field f = ff as Field;
                newPage = f.PageNumber;
            }
            else if (ff == null)
            {
                return(false);
            }

            if (masterSheet != null && !stayOnPage)
            {
                AdvanceToNextPage(newPage - currentPage);
            }

            return(newPage == currentPage);
        }
Пример #2
0
        private void AdvanceToNextZone(int dir)
        {
            int tempColumnIndex = columnIndex;

            tempColumnIndex += dir;

            int min = dgv.Columns[0].Tag == null ? 1 : 0;
            int max = dgv.Columns.Count;// + (dgv.Columns[0].Tag == null ? 0 : 1);

            bool found = true;

            while (found)
            {
                while (tempColumnIndex >= min && tempColumnIndex < max)
                {
                    DataGridViewCell cell = dgv[tempColumnIndex, rowIndex];
                    if (rdbtnAllFields.Checked && ((cell.Tag is Field && !chkSkipNonOMR.Checked) || (cell.Tag is Field == false)))
                    {
                        columnIndex          = tempColumnIndex;
                        cbZones.SelectedItem = dgv.Columns[columnIndex];
                        return;
                    }

                    if (cell.Tag is OmrCollection)
                    {
                        OmrCollection    oc = (OmrCollection)cell.Tag;
                        ReviewParameters rp = (ReviewParameters)oc.Tag;

                        VerificationParameters errorParams = rp.ErroredParameters;

                        if (workspace.VerificationParameters.IsAtLeastOneTrue(errorParams))
                        {
                            columnIndex          = tempColumnIndex;
                            cbZones.SelectedItem = dgv.Columns[columnIndex];
                            return;
                        }
                    }
                    else if (cell.Tag != null && chkSkipNonOMR.Checked == false)
                    {
                        columnIndex          = tempColumnIndex;
                        cbZones.SelectedItem = dgv.Columns[columnIndex];
                        return;
                    }

                    tempColumnIndex += dir;
                }

                tempColumnIndex = dir == 1 ? min : max - 1;
                found           = AdvanceToNextWorkSheet(dir, tempColumnIndex);
            }

            MessageBox.Show("No other matches found for the specified criteria.");
        }
Пример #3
0
        public OmrCollectionDialog(OmrCollection f, bool isGraded)
        {
            InitializeComponent();

            this.f = f;

            txtName.Text = f.Name;
            txtNote.Text = f.Note;

            _numCorrect.Value    = (decimal)f.CorrectGrade;
            _numIncorrect.Value  = (decimal)f.IncorrectGrade;
            _numNoResponse.Value = (decimal)f.NoResponseGrade;

            grpGradingOptions.Enabled = isGraded;
        }
Пример #4
0
        private bool DoZoneSetup(DataGridViewCell cell, bool stayOnPage)
        {
            bool zoneIsOnCurrentPage = DoPageSetup(cell, stayOnPage);

            UpdateNavigationEnables();

            if (!zoneIsOnCurrentPage)
            {
                return(false);
            }

            object ff = cell.Tag;

            if (annotationField != null)
            {
                annotationField.IsVisible = true;
            }

            dgv.CurrentCell = cell;

            string header = cell.OwningColumn.HeaderText;

            this.Text = "Review: " + header;

            LeadRect bounds       = LeadRect.Empty;
            LeadRect answerBounds = LeadRect.Empty;
            string   color        = "Green";

            if (ff is OmrCollection)
            {
                OmrCollection sff = (OmrCollection)ff;

                RasterImage target = GetCroppedImage(masterSheet, sff.Bounds);

                sfp.Visible = true;
                trp.Visible = false;
                sfp.Populate(sff, target, cell);
                bounds = sff.Bounds;
                color  = "Green";

                ReviewParameters       rp = sff.Tag as ReviewParameters;
                VerificationParameters p  = rp.ErroredParameters;
                p.IsReviewed         = true;
                p.UseValueChanged    = sff.Value != sff.OriginalValue;
                rp.ErroredParameters = p;
            }
            else if (ff is OmrField)
            {
                OmrField       omr = (OmrField)ff;
                OmrFieldResult ofr = (OmrFieldResult)omr.Result;

                RasterImage target = GetCroppedImage(masterSheet, omr.Bounds);

                sfp.Visible = false;
                trp.Visible = true;

                trp.Populate(target, cell, ofr.Text);
                bounds = omr.Bounds;
                color  = "Green";
            }
            else if (ff is BarcodeField)
            {
                BarcodeField       bcf  = (BarcodeField)ff;
                BarcodeFieldResult bcfr = (BarcodeFieldResult)bcf.Result;

                RasterImage target = GetCroppedImage(masterSheet, bcf.Bounds);

                sfp.Visible = false;
                trp.Visible = true;

                string value = "";

                if (bcfr != null && bcfr.BarcodeData != null && bcfr.BarcodeData.Count > 0)
                {
                    value = bcfr.BarcodeData[0].Value;
                }

                trp.Populate(target, cell, value);
                bounds = bcf.Bounds;
                color  = "Blue";
            }
            else if (ff is OcrField)
            {
                OcrField       ocf    = (OcrField)ff;
                OcrFieldResult ofr    = (OcrFieldResult)ocf.Result;
                RasterImage    target = GetCroppedImage(masterSheet, ocf.Bounds);

                sfp.Visible = false;
                trp.Visible = true;

                string text       = ofr != null ? ofr.Text : "";
                int    confidence = ofr != null ? ofr.Confidence : -1;

                trp.Populate(target, cell, text, confidence);
                bounds = ocf.Bounds;
                color  = "Red";
            }
            else if (ff is ImageField)
            {
                ImageField       imf  = (ImageField)ff;
                ImageFieldResult imfr = (ImageFieldResult)imf.Result;

                sfp.Visible = false;
                trp.Visible = true;

                if (imfr == null)
                {
                    RasterImage target = GetCroppedImage(masterSheet, imf.Bounds);
                    trp.Populate(target, cell, imf.Name);
                }
                else
                {
                    trp.Populate(imfr.Image, cell, imf.Name);
                }

                bounds = imf.Bounds;
                color  = "Yellow";
            }

            DoAnswerFieldSetup(cell);
            AddHighlight(bounds, color);

            return(true);
        }
Пример #5
0
        public void Populate(OmrCollection omr, RasterImage image)
        {
            if (omr.Tag == null)
            {
                return;
            }

            ReviewParameters data = (ReviewParameters)omr.Tag;

            this.omrCollection = omr;

            txtConfidence.Text = omr.Confidence.ToString();
            txtExpected.Text   = omr.Value;

            List <string> values = data.OmrFieldValues;

            lstErrors.Items.Clear();
            lstErrors.Items.AddRange(data.Errors.ToArray());

            lstSelection.Items.Clear();
            lstSelection.Items.AddRange(values.ToArray());
            lstSelection.Items.Add(BLANK);

            if (omr.Value != null)
            {
                string[] selectedValues = omr.Value.Split('|');
                lstSelection.SelectionMode = selectedValues.Length <= 1 ? SelectionMode.One : SelectionMode.MultiSimple;

                for (int i = 0; i < selectedValues.Length; i++)
                {
                    int index = lstSelection.Items.IndexOf(selectedValues[i]);

                    if (index >= 0 && index < lstSelection.Items.Count)
                    {
                        lstSelection.SetSelected(index, true);
                    }
                }
                lstSelection.Focus();

                txtSelection.Text = omr.Value;
            }


            if (lstSelection.SelectedIndex == -1)
            {
                lstSelection.SetSelected(lstSelection.Items.IndexOf(BLANK), true);
            }

            if (data.AnswerVals != null)
            {
                string[] selectedAnsVals = data.AnswerVals.Split('|');
                lstSelection.SelectionMode = selectedAnsVals.Length <= 1 ? SelectionMode.One : SelectionMode.MultiSimple;
            }

            if (image != null)
            {
                resultRiv.Image = image;
                resultRiv.Zoom(ControlSizeMode.FitAlways, 1, LeadPoint.Empty);
            }

            this.Invalidate();
        }
Пример #6
0
 internal void Populate(OmrCollection sff, RasterImage target, DataGridViewCell cell)
 {
     this.cell = cell;
     Populate(sff, target);
 }
Пример #7
0
 public SingleFieldPanel(DataGridViewCell cell, OmrCollection sff, RasterImage image) : this()
 {
     this.cell = cell;
     Populate(sff, image);
 }
Пример #8
0
        public static ReviewCounter GetManualReviewCollection(IRecognitionForm recognizeForm, VerificationParameters parameters, IRecognitionForm answers = null, bool[][][] reviewed = null)
        {
            ReviewCounter reviewCounter = new ReviewCounter();

            for (int i = 0; i < recognizeForm.Pages.Count; i++)
            {
                Page page = recognizeForm.Pages[i];
                for (int j = 0; j < page.Fields.Count; j++)
                {
                    Field field = page.Fields[j];

                    if (field == null)
                    {
                        continue;
                    }

                    field.PageNumber = page.PageNumber;

                    OmrField omrField = field as OmrField;

                    if (omrField != null)
                    {
                        for (int k = 0; k < omrField.Fields.Count; k++)
                        {
                            OmrCollection omr = omrField.Fields[k];
                            reviewCounter.TotalCounts++;

                            //string errors = "The field confidence value is below the required confidence value, the field does not have exactly one bubble filled in, the field has the same value as the answer key, the field has a different value from the answer key, ";

                            List <string>          errors        = new List <string>();
                            VerificationParameters erroredParams = new VerificationParameters(false, false, false, false, parameters.Threshold, false, false);

                            ReviewParameters rp = null;
                            if (omr.Tag != null)
                            {
                                rp            = (ReviewParameters)omr.Tag;
                                erroredParams = rp.ErroredParameters;
                            }


                            string answerVals = null;
                            erroredParams.Threshold = omr.Confidence;

                            if (/* parameters.UseThreshold && */ omr.Confidence < parameters.Threshold)
                            {
                                errors.Add("OMR confidence value too low");
                                erroredParams.UseThreshold = true;
                                reviewCounter.BelowThreshold++;
                            }

                            //                        if (parameters.UseExactlyOneBubble)
                            {
                                int selectedCells = omr.Fields.Count <OmrBubble>(delegate(OmrBubble bub) { return(bub.IsChecked); });
                                if (selectedCells != 1)
                                {
                                    errors.Add("Does not have exactly one bubble filled in");
                                    erroredParams.UseExactlyOneBubble = true;
                                    reviewCounter.NotExactlyOneBubble++;
                                }
                            }
                            erroredParams.UseValueChanged = omr.Value != omr.OriginalValue;

                            if (answers != null && answers.Pages.Count > 0)
                            {
                                OmrField ansField = answers.Pages[i].Fields[j] as OmrField;

                                OmrFieldResult ofr = (OmrFieldResult)ansField.Result;

                                string value = ansField.Fields[k].Value;
                                answerVals = value;

                                if (/* parameters.UseAgreeWithKey && */ omr.Value == value)
                                {
                                    errors.Add("Same value as answer key");
                                    erroredParams.UseAgreeWithKey = true;
                                    reviewCounter.AgreeWithKey++;
                                }
                                if (/* parameters.UseDisagreeWithKey && */ omr.Value != value)
                                {
                                    errors.Add("Different value from answer key");
                                    erroredParams.UseDisagreeWithKey = true;
                                    reviewCounter.DisagreeWithKey++;
                                }
                            }

                            //page.Image.Page = omrField.PageNumber + 1;
                            if (rp != null)
                            {
                                rp.ErroredParameters = erroredParams;
                                omr.Tag = rp;
                            }
                            else
                            {
                                omr.Tag = new ReviewParameters(omrField.GetValues(), errors, answerVals, recognizeForm.Id, erroredParams, page.PageNumber);
                            }

                            if (errors.Count > 0)
                            {
                                if (reviewed != null)
                                {
                                    bool             flag = reviewed[i][j][k];
                                    ReviewParameters rps  = (ReviewParameters)omr.Tag;
                                    rps.ReviewRequired = flag;

                                    VerificationParameters vp = rps.ErroredParameters;
                                    vp.IsReviewed         = !flag;
                                    rps.ErroredParameters = vp;
                                }
                            }
                        }
                    }
                }
            }

            return(reviewCounter);
        }