internal static OCRWIPForm Show1() { OCRWIPForm form = new OCRWIPForm(); form.Show(); form.Update(); return form; }
private CRRes TryCR(Bitmap picSrc, String fp, int z, CRContext crc, OCRWIPForm wipper, bool rotate4, String formSel) { String baseDir = Path.GetDirectoryName(fpxml); Program.appTrace.TraceEvent(TraceEventType.Information, 0, "認識対象=" + fp); if (formSel == null) formSel = ""; bool fSelForm = formSel != ""; for (int rot = 0; rot < (rotate4 ? 4 : 1); rot++) { wipper.HintRot(rot); Bitmap pic = PiUt.Rotate(picSrc, rot); foreach (KeyValuePair<string, OCRSettei> kvs in crc.dictSet) { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "フォーム=" + kvs.Key); bool forceThis = false; if (fSelForm) { if (String.Compare(formSel, Path.GetFileNameWithoutExtension(kvs.Key), true) != 0) continue; forceThis = true; } wipper.HintTempl(Path.GetFileNameWithoutExtension(kvs.Key), false); bool fail = false, any = false; { DataRow[] rows = kvs.Value.DCR.Blk.Select("IfTest"); for (int x = 0; x < rows.Length; x++) { DCR.BlkRow row = (DCR.BlkRow)rows[x]; wipper.HintForm(x, rows.Length * 2); Object res = RUt.Recognize2(pic, row); if (res != null && UtKwt.PartMatch2(Convert.ToString(res), row.TestKeyword, row.SkipWs)) { any = true; } else { fail = true; } } } Program.appTrace.TraceEvent(TraceEventType.Information, 0, "fail=" + fail + ", " + "any=" + any); if (fail) { if (forceThis) { } else { continue; } } else { if (!any) continue; } Program.appTrace.TraceEvent(TraceEventType.Information, 0, "通過"); bool needVerify = kvs.Value.DCR.Blk.Select("NeedVerify").Length != 0; wipper.HintTempl(Path.GetFileNameWithoutExtension(kvs.Key), true); if (kvs.Value.PWay == "S1" && z == 0) { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "種類=表紙付きモード"); if (fail) { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "検出:失敗"); } else { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "検出:成功"); // 表紙付き(フォーム検出成功) crc.StartTemplPage(); crc.AddTempl("TEMPLATE", Path.GetFileNameWithoutExtension(kvs.Key)); DataRow[] rows = kvs.Value.DCR.Blk.Select("IfImport"); for (int x = 0; x < rows.Length; x++) { DCR.BlkRow row = (DCR.BlkRow)rows[x]; wipper.HintForm(rows.Length + x, 2 * rows.Length); Object res = RUt.Recognize2(pic, row); crc.AddTempl(row.FieldName, res ?? ""); } crc.NewRecord(); crc.AddFrmTempl(); crc.SetValue("OCR", 1); if (needVerify) { using (ConfirmForm form = new ConfirmForm(kvs.Value, pic)) { form.Read(crc, kvs.Value.DCR.Blk); switch (form.ShowDialog()) { case DialogResult.OK: form.SaveTo(crc); break; case DialogResult.No: continue; default: throw new ApplicationException("中止しました。"); } } } crc.CommitRecord(); crc.TemplAvail = true; return CRRes.SaveAll; } } else if (kvs.Value.PWay == "S") { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "種類=区切り/代表ページ"); if (fail) { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "検出:失敗"); } else { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "検出:成功"); // 区切り(フォーム検出成功) crc.StartTemplPage(); crc.AddTempl("TEMPLATE", Path.GetFileNameWithoutExtension(kvs.Key)); DataRow[] rows = kvs.Value.DCR.Blk.Select("IfImport"); for (int x = 0; x < rows.Length; x++) { DCR.BlkRow row = (DCR.BlkRow)rows[x]; wipper.HintForm(rows.Length + x, 2 * rows.Length); Object res = RUt.Recognize2(pic, row); crc.AddTempl(row.FieldName, res ?? ""); } crc.TemplAvail = true; return CRRes.Sepa; } } else if (kvs.Value.PWay == "") { Program.appTrace.TraceEvent(TraceEventType.Information, 0, "種類=通常フォーム認識"); // 通常(フォーム検出成功) crc.ClearTempl(); crc.NewRecord(); crc.SetValue("OCR", 1); crc.SetValue("FORM", Path.GetFileNameWithoutExtension(kvs.Key)); DataRow[] rows = kvs.Value.DCR.Blk.Select("IfImport"); for (int x = 0; x < rows.Length; x++) { DCR.BlkRow row = (DCR.BlkRow)rows[x]; wipper.HintForm(rows.Length + x, 2 * rows.Length); Object res = RUt.Recognize2(pic, row); crc.SetValue(row.FieldName, res ?? ""); } if (needVerify) { using (ConfirmForm form = new ConfirmForm(kvs.Value, pic)) { form.Read(crc, kvs.Value.DCR.Blk); switch (form.ShowDialog()) { case DialogResult.OK: form.SaveTo(crc); break; case DialogResult.No: continue; default: throw new ApplicationException("中止しました。"); } } } crc.CommitRecord(); crc.TemplAvail = false; return CRRes.Avail; } Program.appTrace.TraceEvent(TraceEventType.Information, 0, "終了"); } } Program.appTrace.TraceEvent(TraceEventType.Information, 0, "crc.TemplAvail=" + crc.TemplAvail); if (crc.TemplAvail) { // 区切り従属 crc.NewRecord(); crc.AddFrmTempl(); crc.SetValue("OCR", 1); crc.CommitRecord(); return CRRes.Avail; } return CRRes.Fail; }
private void bAbout_Click(object sender, EventArgs e) { using (OCRWIPForm form = new OCRWIPForm(Application.ProductName + " " + Application.ProductVersion + " について")) form.ShowDialog(this); }