private void picShow_MouseUp(object sender, MouseEventArgs e) { if (isDrag == true) { isDrag = false; int x1, y1, x2, y2; Image source = Image.FromFile(xmlInfo.ImgFile.FullName); ImageProcess.InOrder(startPoint, e.Location, out x1, out y1, out x2, out y2, source); var p1 = new Point(x1, y1); var p2 = new Point(x2, y2); if (ImageProcess.isRectangle(p1, p2)) { p1 = ImageProcess.ResizedToSource(startPoint, source.Size, picShow.Image.Size); p2 = ImageProcess.ResizedToSource(e.Location, source.Size, picShow.Image.Size); FormClass formClass = new FormClass(ImageProcess.CropRectangle(p1, p2, source), Control.MousePosition); formClass.ShowDialog(); if (formClass.result != -1) { ImageProcess.InOrder(p1, p2, out x1, out y1, out x2, out y2, source); MyObject myObject = new MyObject(formClass.result, x1, y1, x2, y2); xmlInfo.AddObject(myObject); tempBitmap = ImageProcess.DrawRectangle(startPoint, e.Location, tempBitmap, true, 2, myObject.Color); UpdateObjectList(); } } picShow.Image = tempBitmap; GC.Collect(); } }
private void lvwObject_DoubleClick(object sender, EventArgs e) { Image source = Image.FromFile(xmlInfo.ImgFile.FullName); MyObject selected = (MyObject)lvwObject.SelectedItems[0].Tag; FormClass formClass = new FormClass(ImageProcess.CropRectangle(selected.Min, selected.Max, source), Control.MousePosition); formClass.ShowDialog(); if (formClass.result == -1) { xmlInfo.DelObject(selected); } else { xmlInfo.DelObject(selected); selected.NameID = formClass.result; xmlInfo.AddObject(selected); } showImage(); }