Exemple #1
0
        public Form2(int subImageId, SubImage subImage)
            : this()
        {
            this.Text       = $"Sub Image - {subImageId}";
            this.subImageId = subImageId;
            this.subImage   = subImage;

            this.imageEditForm = new ImageEditForm(
                this.subImageId,
                (attr) =>
            {
                this.imageAttributes = attr;
                imageBox.Invalidate();
            },
                () => {
                int width  = subImage.MaxPos.X - subImage.MinPos.X;
                int height = subImage.MaxPos.Y - subImage.MinPos.Y;
                if (rotation % 4 == 1 || rotation % 4 == 3)
                {
                    int swap = width;
                    width    = height;
                    height   = swap;
                }

                Bitmap bitmap = new Bitmap(width, height);
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    DrawPartialImage(g, width, height);
                }

                this.subImage.Saved = true;
                return(bitmap);
            },
                (increment) =>
            {
                this.rotation += increment;
                this.Width     = this.GetWidth();
                this.Height    = this.GetHeight();

                imageBox.Invalidate();
            },
                () => this.Hide());

            this.Width  = this.GetWidth();
            this.Height = this.GetHeight();
            this.Show();

            this.imageEditForm.StartPosition = FormStartPosition.Manual;
            this.imageEditForm.Left          = this.Location.X + this.Width;
            this.imageEditForm.Top           = this.Location.Y;
            this.imageEditForm.Show();
        }
Exemple #2
0
        private void imageBox_MouseUp(object sender, MouseEventArgs e)
        {
            if (lastMousePos.X - lastClickedPos.X < MinSubImageSize || lastMousePos.Y - lastClickedPos.Y < MinSubImageSize)
            {
                // Cancel the operation
                return;
            }
            else
            {
                SubImage subImage = new SubImage(GetImagePosition(lastClickedPos), GetImagePosition(lastMousePos), (Image)imageBox.Image.Clone(), lastClickedPos, lastMousePos);
                subImages.Add(subImage);

                Form2 form = new Form2(this.subImages.Count, subImage);
                form.Show();
                forms.Add(form);
            }

            inSelectMode = false;
        }