public OmrFieldDialog(OmrField omrField, RasterImage fieldImage) { InitializeComponent(); this.fieldImage = fieldImage; imageViewer = new ImageViewer(); imageViewer.Dock = DockStyle.Fill; imageViewer.ItemChanged += ImageViewer_ItemChanged; pnlImg.Controls.Add(imageViewer); this.omrField = omrField; this.localOptions = this.omrField.Options; DataToControls(); }
private bool ControlsToData() { omrField.Name = _txtFieldName.Text; OmrFieldOptions options = omrField.Options; // orientation if (rdbtnOrRows.Checked) { options.FieldOrientation = OmrFieldOrientation.RowWise; } else if (rdbtnOrCols.Checked) { options.FieldOrientation = OmrFieldOrientation.ColumnWise; } else if (rdbtnOrFreeflow.Checked) { options.FieldOrientation = OmrFieldOrientation.FreeFlow; } // grading options.GradeThisField = _cbGrade.Checked; options.CorrectGrade = Convert.ToDouble(_numCorrect.Value); options.IncorrectGrade = Convert.ToDouble(_numIncorrect.Value); options.NoResponseGrade = Convert.ToDouble(_numNoResponse.Value); // formatting options.TextFormat = rdbtnFormatCSV.Checked ? OmrTextFormat.CSV : OmrTextFormat.Aggregated; // rtl options.ColumnsReportOrder = _cbRightToLeft.Checked ? ColumnsReportOrder.RightToLeft : ColumnsReportOrder.LeftToRight; // sensitivity (advanced tab) if (rdbtnSensLowest.Checked) { options.OmrSensitivity = Leadtools.Ocr.OcrOmrSensitivity.Lowest; } else if (rdbtnSensLow.Checked) { options.OmrSensitivity = Leadtools.Ocr.OcrOmrSensitivity.Low; } else if (rdbtnSensHigh.Checked) { options.OmrSensitivity = Leadtools.Ocr.OcrOmrSensitivity.High; } else if (rdbtnSensHighest.Checked) { options.OmrSensitivity = Leadtools.Ocr.OcrOmrSensitivity.Highest; } try { omrField.Options = options; } catch (Exception) { MessageBox.Show("The options for this field are invalid."); return(false); } if (omrField.Options.FieldOrientation == OmrFieldOrientation.FreeFlow) { for (int i = 0; i < omrField.Fields.Count; i++) { string name = omrField.Fields[i].Name; omrField.Fields[i].Name = string.IsNullOrEmpty(name) ? string.Format("Freeflow {0}", i + 1) : name; } } // values if (omrField.FieldBubbleLayoutType == OmrFieldBubbleLayoutType.BubbleWithLabel) { try { omrField.SetValues(labels.ConvertAll <string>(delegate(OmrBubbleLabel bub) { return(bub.Value); })); } catch (Exception) { MessageBox.Show("The field count does not match the label count."); return(false); } } else { omrField.SetValues(_values[lstValues.SelectedIndex]); } return(true); }