//protected override void OnFormClosing(FormClosingEventArgs e) //{ // base.OnFormClosing(e); // MainWindow.Instance.OnSelectPhoto -= ShowPreview; //} private void DetailSelected(object sender, EventArgs e) { var dlg = new TextInputMessage() { Text = "Enter a name for the new detail area" }; if (dlg.ShowDialog(this) == DialogResult.OK) { var name = dlg.InputText; Photo.Project.DetailAreas.Add(new DetailArea() { Crop = pictureBox1.Crop, Name = name }); Fill(); } // labelCropSize.Text = pictureBox1.Crop.Width + " x " + pictureBox1.Crop.Height; }
private void AddRubberbandControl(RubberbandControl p) { pictureBox1.Controls.Add(p); // move new detail control to front so that it appears on top (z-order) pictureBox1.Controls.SetChildIndex(p, 0); // update image coordinates after move/resize operation p.RubberbandMoved += UpdateRubberbandCoordinatesMove; p.RubberbandSizeChanged += UpdateRubberbandCoordinates; // show current detail in editor bar p.MouseClick += SelectDetailArea; p.SizeChanged += SelectDetailArea; p.RubberbandMoved += SelectDetailArea; p.RubberbandSizeChanged += SelectDetailArea; // set coordinate translation methods p.Transform = _pbt; _detailControls.Add(p); // context menu var deleteCommand = new ToolStripMenuItem("Delete"); var renameCommand = new ToolStripMenuItem("Rename ..."); var previewCommand = new ToolStripMenuItem("Preview 1:1"); var contextMenu = new ContextMenuStrip(); contextMenu.Items.Add(deleteCommand); contextMenu.Items.Add(renameCommand); contextMenu.Items.Add(previewCommand); // delete DetailArea from project and dispose the rubberband control deleteCommand.Click += (s, ev) => DeleteDetail(p); // open rename dialog renameCommand.Click += (s, ev) => { var dlg = new TextInputMessage() { InputText = p.DetailArea.Name, Text = "Detail Area Name" }; if (dlg.ShowDialog(this) == DialogResult.OK) { p.DetailArea.Name = dlg.InputText; toolTip.SetToolTip(p, p.DetailArea.Name); } }; // create 100% preview of this area previewCommand.Click += (s, ev) => { var pimg = pictureBox1.Image; var img = ImageConverter.Crop(pimg, p.DetailArea.Crop); new ImagePreview(img).Show(this); }; p.ContextMenuStrip = contextMenu; // tool tip toolTip.SetToolTip(p, p.DetailArea.Name); }