示例#1
0
        protected override void initialize(DataGridViewRow row, object value)
        {
            field = (Template.Field.OcrCharBoxs)row.Tag;
            if (field == null)
            {
                field = new Template.Field.OcrCharBoxs();
            }

            List <string> fieldNames = template.Fields.Where(a => a.ColumnOfTable == null).Select(a => a.Name).Distinct().ToList();

            fieldNames.Remove(field.Name);
            fieldNames.Insert(0, "");
            ColumnOfTable.DataSource = fieldNames;

            ColumnOfTable.SelectedItem = field.ColumnOfTable;

            SpecialOcrSettings.Checked        = field.AdjustLineBorders != null || field.SingleFieldFromFieldImage != null || field.ColumnCellFromCellImage != null || field.TesseractPageSegMode != null;
            AdjustLineBorders.Checked         = field.AdjustLineBorders ?? template.AdjustLineBorders;
            SingleFieldFromFieldImage.Checked = field.SingleFieldFromFieldImage ?? template.SingleFieldFromFieldImage;
            ColumnCellFromCellImage.Checked   = field.ColumnCellFromCellImage ?? template.ColumnCellFromCellImage;
            TesseractPageSegMode.SelectedItem = field.TesseractPageSegMode ?? template.TesseractPageSegMode;

            if (value != null)
            {
                List <Page.Line <Ocr.CharBox> > cbss = Page.GetLines((List <Ocr.CharBox>)value, template.TextAutoInsertSpace, field.CharFilter == null ? template.CharFilter : field.CharFilter);
                List <string> ls = new List <string>();
                foreach (var cbs in cbss)
                {
                    ls.Add(Serialization.Json.Serialize(cbs.CharBoxs));
                }
                Value.Text = string.Join("\r\n", ls);
            }
        }
示例#2
0
 override protected object getObject()
 {
     if (field == null)
     {
         field = new Template.Field.OcrCharBoxs();
     }
     field.ColumnOfTable = (string)ColumnOfTable.SelectedItem;
     if (SpecialOcrSettings.Checked)
     {
         field.AdjustLineBorders         = AdjustLineBorders.Checked;
         field.SingleFieldFromFieldImage = SingleFieldFromFieldImage.Checked;
         field.ColumnCellFromCellImage   = ColumnCellFromCellImage.Checked;
         field.TesseractPageSegMode      = (Tesseract.PageSegMode)TesseractPageSegMode.SelectedItem;
     }
     else
     {
         field.AdjustLineBorders         = null;
         field.SingleFieldFromFieldImage = null;
         field.ColumnCellFromCellImage   = null;
         field.TesseractPageSegMode      = null;
     }
     return(field);
 }