private void MarkCell() { Bitmap currentImage = new Bitmap(originalImage); Graphics g = Graphics.FromImage(currentImage); currentTable.ForEach(table => { table.DrawTable(g, new Pen(Color.Red, 2)); Brush fillBrush = new SolidBrush(Color.FromArgb(50, Color.Blue)); if (cell1.HasValue) { table.GetCellContour(cell1.Value.X, cell1.Value.Y).ForEach(cellContour => g.FillPath(fillBrush, cellContour)); } }); g.Dispose(); registerPV.SetImageKeepZoom(currentImage); }
public RegisterViewForm() { InitializeComponent(); registerPV = PictureView.InsertIntoPanel(registerPanel); this.Shown += new EventHandler(delegate { ProcessNextImage(); }); this.nextRegisterButton.Click += new EventHandler(delegate { MoveImageToDone(currentFileName); ProcessNextImage(); }); Point?selectionStart = null; this.registerPV.AddDoubleClickListener((pt, e) => { Util.NewThread(() => { currentTable.ForEach(table => { if (e.Button == MouseButtons.Left) { table.GetCellAtPoint(pt.X, pt.Y).ForEach(cell => { nextImageIndex = null; ProcessTableCell(cell.X, cell.Y); // color processed cell with green table.GetCellContour(cell.X, cell.Y).ForEach(cellPath => { Graphics g = Graphics.FromImage(currentImage); g.FillPath(new SolidBrush(Color.FromArgb(100, Color.Green)), cellPath); g.Dispose(); }); registerPV.SetImageKeepZoom(currentImage); }); } else if (e.Button == MouseButtons.Right) { table.GetCellAtPoint(pt.X, pt.Y).ForEach(cell => { if (selectionStart.HasValue) { Graphics g = Graphics.FromImage(currentImage); int minX = Math.Min(selectionStart.Value.X, cell.X); int maxX = Math.Max(selectionStart.Value.X, cell.X); int minY = Math.Min(selectionStart.Value.Y, cell.Y); int maxY = Math.Max(selectionStart.Value.Y, cell.Y); nextImageIndex = null; ProgressDialogs.WithProgress((maxX - minX + 1) * (maxY - minY + 1), pd => { for (int y = minY; y <= maxY; y++) { for (int x = minX; x <= maxX; x++) { ProcessTableCell(x, y); table.GetCellContour(x, y).ForEach(cellPath => { g.FillPath(new SolidBrush(Color.FromArgb(100, Color.Green)), cellPath); }); pd.Increment(); } } }); // color processed cells with green g.Dispose(); registerPV.SetImageKeepZoom(currentImage); selectionStart = null; } else { selectionStart = new Point(cell.X, cell.Y); } }); } }); }); }); this.debugOcrButton.Click += new EventHandler(delegate { (new TableRecognitionDebugView(origImage)).ShowDialog(); }); }