예제 #1
0
        private void EditImage(Image image)
        {
            var editor  = new SnapshotEditor(image);
            var changed = editor.ShowDialog(this);

            if (changed == DialogResult.OK)
            {
                image = editor.GetImage();
                Helper.SetSizedImage(selectedPicture, image);
            }
        }
예제 #2
0
        private void pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && selecting && selection.Size != new Size())
            {
                pictureBoxSnapshot.Cursor = Cursors.Default;
                cropping  = false;
                selecting = false;

                // Redraw the picturebox:
                pictureBoxSnapshot.Refresh();

                var zone = selection;
                if (zone.Width < 0)
                {
                    zone = new Rectangle(zone.X + zone.Width, zone.Y, Math.Abs(zone.Width), zone.Height);
                }
                if (zone.Height < 0)
                {
                    zone = new Rectangle(zone.X, zone.Y + zone.Height, zone.Width, Math.Abs(zone.Height));
                }

                zone = new Rectangle((int)((double)zone.X * scale) + 1, (int)((double)zone.Y * scale) + 1, (int)((double)zone.Width * scale), (int)((double)zone.Height * scale));

                // Create cropped image:
                Image img = pictureBoxSnapshot.Tag as Image;
                if (img != null)
                {
                    img = img.Crop(zone);

                    // preview to accept:
                    var preview = new SnapshotEditor(img, true);
                    var accept  = preview.ShowDialog(this);
                    if (accept == DialogResult.OK)
                    {
                        // Fit image to the picturebox:
                        scale         = Helper.SetSizedImage(pictureBoxSnapshot, img);
                        originalImage = img;
                        DisplayOriginalSize();
                    }
                }
            }
            else
            {
                selecting = false;
            }
        }