private void catchToolStripMenuItem_Click(object sender, EventArgs e) { try { var bitmap = pictureEditFile.Image as Bitmap; var pattern = pictureEditPattern.Image as Bitmap; if (bitmap == null || pattern == null) { throw new Exception("Нет изображения"); } using (var builder = new CatchBuilder(pattern, WithColor, FastMode)) { var matrix = builder.Catch(bitmap); int x, y; double value; CatchBuilder.Max(matrix, out x, out y, out value); propertyGrid1.SelectedObject = new Info { X = x, Y = y, Value = value }; using (var graphics = Graphics.FromImage(bitmap)) { var pen = new Pen(Color.Red); graphics.DrawRectangle(pen, x, y, pattern.Width, pattern.Height); pictureEditFile.Image = bitmap; } } } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void catch_ItemClick(object sender, ItemClickEventArgs e) { try { var bitmap = pictureEditFile.Image as Bitmap; var pattern = pictureEditPattern.Image as Bitmap; if (bitmap == null || pattern == null) { return; } using (var builder = new CatchBuilder(pattern)) { Matrix <double> matrix = builder.Catch(bitmap); int x, y; double value; builder.Max(matrix, out x, out y, out value); propertyGridControl1.SelectedObject = new Info { X = x, Y = y, Value = value }; using (Graphics graphics = Graphics.FromImage(bitmap)) { var pen = new Pen(Color.Red); graphics.DrawRectangle(pen, x, y, pattern.Width, pattern.Height); } } } catch (Exception exception) { XtraMessageBox.Show(exception.Message); } }