Ejemplo n.º 1
0
 private void btnClipboardCopy_Click(object sender, EventArgs e)
 {
     if (Result != null)
     {
         ClipboardHelpers.CopyImage(Result);
     }
 }
Ejemplo n.º 2
0
 private void tsmiCopy_Click(object sender, EventArgs e)
 {
     if (pbQRCode.Image != null)
     {
         ClipboardHelpers.CopyImage(pbQRCode.Image);
     }
 }
Ejemplo n.º 3
0
        private void PinToScreenForm_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Escape:
                Close();
                break;

            case Keys.Control | Keys.C:
                ClipboardHelpers.CopyImage(Image);
                break;

            case Keys.Oemplus:
            case Keys.Add:
                ImageScale += ScaleStep;
                break;

            case Keys.OemMinus:
            case Keys.Subtract:
                ImageScale -= ScaleStep;
                break;

            case Keys.Control | Keys.Oemplus:
            case Keys.Control | Keys.Add:
                ImageOpacity += OpacityStep;
                break;

            case Keys.Control | Keys.OemMinus:
            case Keys.Control | Keys.Subtract:
                ImageOpacity -= OpacityStep;
                break;
            }
        }
Ejemplo n.º 4
0
 public static Image AnnotateImage(Image img, string imgPath)
 {
     return(ImageHelpers.AnnotateImage(img, imgPath, !Program.IsSandbox, Program.PersonalPath,
                                       x => Program.MainForm.InvokeSafe(() => ClipboardHelpers.CopyImage(x)),
                                       x => Program.MainForm.InvokeSafe(() => UploadManager.UploadImage(x)),
                                       (x, filePath) => Program.MainForm.InvokeSafe(() => ImageHelpers.SaveImage(x, filePath)),
                                       (x, filePath) =>
     {
         string newFilePath = null;
         Program.MainForm.InvokeSafe(() => newFilePath = ImageHelpers.SaveImageFileDialog(x, filePath));
         return newFilePath;
     }));
 }
Ejemplo n.º 5
0
        private void tsmiCopy_Click(object sender, EventArgs e)
        {
            GraphicsRenderer gRender = new GraphicsRenderer(new FixedModuleSize(20, QuietZoneModules.Two));
            BitMatrix        matrix  = qrMain.GetQrMatrix();

            using (MemoryStream stream = new MemoryStream())
            {
                gRender.WriteToStream(matrix, ImageFormat.Png, stream);

                using (Image img = Image.FromStream(stream))
                {
                    ClipboardHelpers.CopyImage(img);
                }
            }
        }
Ejemplo n.º 6
0
        private void copyMergedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_image != null && _transformed != null)
            {
                int iw;
                int ih;
                int x2;
                int y2;
                int fw;
                int fh;

                fw = _image.Width;
                fh = _image.Height;

                if (horizontalSplitToolStripMenuItem.Checked)
                {
                    iw = fw;
                    ih = fh * 2;
                    x2 = 0;
                    y2 = fh;
                }
                else
                {
                    iw = fw * 2;
                    ih = fh;
                    x2 = fw;
                    y2 = 0;
                }

                using (Bitmap image = new Bitmap(iw, ih, PixelFormat.Format32bppArgb))
                {
                    using (Graphics g = Graphics.FromImage(image))
                    {
                        g.DrawImage(_image, new Rectangle(0, 0, fw, fh), new Rectangle(0, 0, fw, fh), GraphicsUnit.Pixel);
                        g.DrawImage(_transformed, new Rectangle(x2, y2, fw, fh), new Rectangle(0, 0, fw, fh), GraphicsUnit.Pixel);
                    }

                    ClipboardHelpers.CopyImage(image);
                }
            }
            else
            {
                MessageBox.Show("Both the source and transformed images must exist to make a merged copy.", "Copy Image", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 7
0
        public static void OpenWebpageCapture(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            WebpageCaptureForm webpageCaptureForm = new WebpageCaptureForm();

            webpageCaptureForm.OnImageUploadRequested += img => UploadManager.RunImageTask(img, taskSettings);
            webpageCaptureForm.OnImageCopyRequested   += img =>
            {
                using (img)
                {
                    ClipboardHelpers.CopyImage(img);
                }
            };
            webpageCaptureForm.Show();
        }
Ejemplo n.º 8
0
        public static void AnnotateImageUsingShareX(Image img, string filePath, TaskSettings taskSettings = null)
        {
            if (img == null && File.Exists(filePath))
            {
                img = ImageHelpers.LoadImage(filePath);
            }

            if (img != null)
            {
                using (img)
                {
                    RegionCaptureTasks.AnnotateImage(img, filePath, taskSettings.CaptureSettingsReference.SurfaceOptions,
                                                     x => UploadManager.RunImageTask(x, taskSettings),
                                                     (x, newFilePath) => ImageHelpers.SaveImage(x, newFilePath),
                                                     (x, newFilePath) => ImageHelpers.SaveImageFileDialog(x, newFilePath),
                                                     x => ClipboardHelpers.CopyImage(x),
                                                     x => UploadManager.UploadImage(x),
                                                     x => PrintImage(x));
                }
            }
        }
Ejemplo n.º 9
0
        private void DoAfterCaptureJobs()
        {
            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects))
            {
                tempImage = TaskHelpers.AddImageEffects(tempImage, Info.TaskSettings);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddWatermark) && Info.TaskSettings.ImageSettings.WatermarkConfig != null)
            {
                Info.TaskSettings.ImageSettings.WatermarkConfig.Apply(tempImage);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage))
            {
                tempImage = TaskHelpers.AnnotateImage(tempImage);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyImageToClipboard))
            {
                ClipboardHelpers.CopyImage(tempImage);
                DebugHelper.WriteLine("CopyImageToClipboard");
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SendImageToPrinter))
            {
                if (Program.Settings.DontShowPrintSettingsDialog)
                {
                    using (PrintHelper printHelper = new PrintHelper(tempImage))
                    {
                        printHelper.Settings = Program.Settings.PrintSettings;
                        printHelper.Print();
                    }
                }
                else
                {
                    using (PrintForm printForm = new PrintForm(tempImage, Program.Settings.PrintSettings))
                    {
                        printForm.ShowDialog();
                    }
                }
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlagAny(AfterCaptureTasks.SaveImageToFile, AfterCaptureTasks.SaveImageToFileWithDialog,
                                                             AfterCaptureTasks.UploadImageToHost))
            {
                using (tempImage)
                {
                    ImageData imageData = TaskHelpers.PrepareImage(tempImage, Info.TaskSettings);
                    Data          = imageData.ImageStream;
                    Info.FileName = Path.ChangeExtension(Info.FileName, imageData.ImageFormat.GetDescription());

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFile))
                    {
                        string filePath = TaskHelpers.CheckFilePath(Info.TaskSettings.CaptureFolder, Info.FileName, Info.TaskSettings);

                        if (!string.IsNullOrEmpty(filePath))
                        {
                            Info.FilePath = filePath;
                            imageData.Write(Info.FilePath);
                            DebugHelper.WriteLine("SaveImageToFile: " + Info.FilePath);
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
                    {
                        using (SaveFileDialog sfd = new SaveFileDialog())
                        {
                            if (string.IsNullOrEmpty(lastSaveAsFolder) || !Directory.Exists(lastSaveAsFolder))
                            {
                                lastSaveAsFolder = Info.TaskSettings.CaptureFolder;
                            }

                            sfd.InitialDirectory = lastSaveAsFolder;
                            sfd.FileName         = Info.FileName;
                            sfd.DefaultExt       = Path.GetExtension(Info.FileName).Substring(1);
                            sfd.Filter           = string.Format("*{0}|*{0}|All files (*.*)|*.*", Path.GetExtension(Info.FileName));
                            sfd.Title            = "Choose a folder to save " + Path.GetFileName(Info.FileName);

                            if (sfd.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(sfd.FileName))
                            {
                                Info.FilePath    = sfd.FileName;
                                lastSaveAsFolder = Path.GetDirectoryName(Info.FilePath);
                                imageData.Write(Info.FilePath);
                                DebugHelper.WriteLine("SaveImageToFileWithDialog: " + Info.FilePath);
                            }
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile))
                    {
                        string thumbnailFilename, thumbnailFolder;

                        if (!string.IsNullOrEmpty(Info.FilePath))
                        {
                            thumbnailFilename = Path.GetFileName(Info.FilePath);
                            thumbnailFolder   = Path.GetDirectoryName(Info.FilePath);
                        }
                        else
                        {
                            thumbnailFilename = Info.FileName;
                            thumbnailFolder   = Info.TaskSettings.CaptureFolder;
                        }

                        Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail(tempImage, thumbnailFolder, thumbnailFilename, Info.TaskSettings);

                        if (!string.IsNullOrEmpty(Info.ThumbnailFilePath))
                        {
                            DebugHelper.WriteLine("SaveThumbnailImageToFile: " + Info.ThumbnailFilePath);
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyFileToClipboard) && !string.IsNullOrEmpty(Info.FilePath) &&
                        File.Exists(Info.FilePath))
                    {
                        ClipboardHelpers.CopyFile(Info.FilePath);
                    }
                    else if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyFilePathToClipboard) && !string.IsNullOrEmpty(Info.FilePath))
                    {
                        ClipboardHelpers.CopyText(Info.FilePath);
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.PerformActions) && Info.TaskSettings.ExternalPrograms != null &&
                        !string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath))
                    {
                        var actions = Info.TaskSettings.ExternalPrograms.Where(x => x.IsActive);

                        if (actions.Count() > 0)
                        {
                            if (Data != null)
                            {
                                Data.Dispose();
                            }

                            foreach (ExternalProgram fileAction in actions)
                            {
                                fileAction.Run(Info.FilePath);
                            }

                            Data = new FileStream(Info.FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private bool DoAfterCaptureJobs()
        {
            if (tempImage == null)
            {
                return(true);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects))
            {
                tempImage = TaskHelpers.AddImageEffects(tempImage, Info.TaskSettings);

                if (tempImage == null)
                {
                    DebugHelper.WriteLine("Error: Applying image effects resulted empty image.");
                    return(false);
                }
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage))
            {
                tempImage = TaskHelpers.AnnotateImageForTask(tempImage, Info.FileName, Info.TaskSettings);

                if (tempImage == null)
                {
                    return(false);
                }
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyImageToClipboard))
            {
                ClipboardHelpers.CopyImage(tempImage);
                DebugHelper.WriteLine("Image copied to clipboard.");
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SendImageToPrinter))
            {
                TaskHelpers.PrintImage(tempImage);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlagAny(AfterCaptureTasks.SaveImageToFile, AfterCaptureTasks.SaveImageToFileWithDialog, AfterCaptureTasks.DoOCR,
                                                             AfterCaptureTasks.UploadImageToHost))
            {
                using (tempImage)
                {
                    ImageData imageData = TaskHelpers.PrepareImage(tempImage, Info.TaskSettings);
                    Data          = imageData.ImageStream;
                    Info.FileName = Path.ChangeExtension(Info.FileName, imageData.ImageFormat.GetDescription());

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFile))
                    {
                        string filePath = TaskHelpers.CheckFilePath(Info.TaskSettings.CaptureFolder, Info.FileName, Info.TaskSettings);

                        if (!string.IsNullOrEmpty(filePath))
                        {
                            Info.FilePath = filePath;
                            imageData.Write(Info.FilePath);
                            DebugHelper.WriteLine("Image saved to file: " + Info.FilePath);
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
                    {
                        using (SaveFileDialog sfd = new SaveFileDialog())
                        {
                            bool imageSaved;

                            do
                            {
                                if (string.IsNullOrEmpty(lastSaveAsFolder) || !Directory.Exists(lastSaveAsFolder))
                                {
                                    lastSaveAsFolder = Info.TaskSettings.CaptureFolder;
                                }

                                sfd.InitialDirectory = lastSaveAsFolder;
                                sfd.FileName         = Info.FileName;
                                sfd.DefaultExt       = Path.GetExtension(Info.FileName).Substring(1);
                                sfd.Filter           = string.Format("*{0}|*{0}|All files (*.*)|*.*", Path.GetExtension(Info.FileName));
                                sfd.Title            = Resources.UploadTask_DoAfterCaptureJobs_Choose_a_folder_to_save + " " + Path.GetFileName(Info.FileName);

                                if (sfd.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(sfd.FileName))
                                {
                                    Info.FilePath    = sfd.FileName;
                                    lastSaveAsFolder = Path.GetDirectoryName(Info.FilePath);
                                    imageSaved       = imageData.Write(Info.FilePath);

                                    if (imageSaved)
                                    {
                                        DebugHelper.WriteLine("Image saved to file with dialog: " + Info.FilePath);
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            } while (!imageSaved);
                        }
                    }

                    if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile))
                    {
                        string thumbnailFilename, thumbnailFolder;

                        if (!string.IsNullOrEmpty(Info.FilePath))
                        {
                            thumbnailFilename = Path.GetFileName(Info.FilePath);
                            thumbnailFolder   = Path.GetDirectoryName(Info.FilePath);
                        }
                        else
                        {
                            thumbnailFilename = Info.FileName;
                            thumbnailFolder   = Info.TaskSettings.CaptureFolder;
                        }

                        Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail(tempImage, thumbnailFolder, thumbnailFilename, Info.TaskSettings);

                        if (!string.IsNullOrEmpty(Info.ThumbnailFilePath))
                        {
                            DebugHelper.WriteLine("Thumbnail saved to file: " + Info.ThumbnailFilePath);
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 11
0
 public static Image AnnotateImage(Image img)
 {
     return(ImageHelpers.AnnotateImage(img, !Program.IsSandbox, Program.PersonalPath,
                                       x => Program.MainForm.InvokeSafe(() => ClipboardHelpers.CopyImage(x)),
                                       x => Program.MainForm.InvokeSafe(() => UploadManager.RunImageTask(x))));
 }
Ejemplo n.º 12
0
        private bool DoAfterCaptureJobs()
        {
            if (Image == null)
            {
                return(true);
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AddImageEffects))
            {
                Image = TaskHelpers.ApplyImageEffects(Image, Info.TaskSettings.ImageSettingsReference);

                if (Image == null)
                {
                    DebugHelper.WriteLine("Error: Applying image effects resulted empty image.");
                    return(false);
                }
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.AnnotateImage))
            {
                Image = TaskHelpers.AnnotateImage(Image, null, Info.TaskSettings, true);

                if (Image == null)
                {
                    return(false);
                }
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyImageToClipboard))
            {
                ClipboardHelpers.CopyImage(Image, Info.FileName);
                DebugHelper.WriteLine("Image copied to clipboard.");
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.PinToScreen))
            {
                Image imageCopy = Image.CloneSafe();
                threadWorker.InvokeAsync(() => TaskHelpers.PinToScreen(imageCopy));
            }

            if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SendImageToPrinter))
            {
                TaskHelpers.PrintImage(Image);
            }

            Info.Metadata.Image = Image;

            if (Info.TaskSettings.AfterCaptureJob.HasFlagAny(AfterCaptureTasks.SaveImageToFile, AfterCaptureTasks.SaveImageToFileWithDialog, AfterCaptureTasks.DoOCR,
                                                             AfterCaptureTasks.UploadImageToHost))
            {
                ImageData imageData = TaskHelpers.PrepareImage(Image, Info.TaskSettings);
                Data          = imageData.ImageStream;
                Info.FileName = Path.ChangeExtension(Info.FileName, imageData.ImageFormat.GetDescription());

                if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFile))
                {
                    string screenshotsFolder = TaskHelpers.GetScreenshotsFolder(Info.TaskSettings, Info.Metadata);
                    string filePath          = TaskHelpers.HandleExistsFile(screenshotsFolder, Info.FileName, Info.TaskSettings);

                    if (!string.IsNullOrEmpty(filePath))
                    {
                        Info.FilePath = filePath;
                        imageData.Write(Info.FilePath);
                        DebugHelper.WriteLine("Image saved to file: " + Info.FilePath);
                    }
                }

                if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
                {
                    using (SaveFileDialog sfd = new SaveFileDialog())
                    {
                        string initialDirectory = null;

                        if (!string.IsNullOrEmpty(HelpersOptions.LastSaveDirectory) && Directory.Exists(HelpersOptions.LastSaveDirectory))
                        {
                            initialDirectory = HelpersOptions.LastSaveDirectory;
                        }
                        else
                        {
                            initialDirectory = TaskHelpers.GetScreenshotsFolder(Info.TaskSettings, Info.Metadata);
                        }

                        bool imageSaved;

                        do
                        {
                            sfd.InitialDirectory = initialDirectory;
                            sfd.FileName         = Info.FileName;
                            sfd.DefaultExt       = Path.GetExtension(Info.FileName).Substring(1);
                            sfd.Filter           = string.Format("*{0}|*{0}|All files (*.*)|*.*", Path.GetExtension(Info.FileName));
                            sfd.Title            = Resources.UploadTask_DoAfterCaptureJobs_Choose_a_folder_to_save + " " + Path.GetFileName(Info.FileName);

                            if (sfd.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(sfd.FileName))
                            {
                                Info.FilePath = sfd.FileName;
                                HelpersOptions.LastSaveDirectory = Path.GetDirectoryName(Info.FilePath);
                                imageSaved = imageData.Write(Info.FilePath);

                                if (imageSaved)
                                {
                                    DebugHelper.WriteLine("Image saved to file with dialog: " + Info.FilePath);
                                }
                            }
                            else
                            {
                                break;
                            }
                        } while (!imageSaved);
                    }
                }

                if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile))
                {
                    string thumbnailFileName, thumbnailFolder;

                    if (!string.IsNullOrEmpty(Info.FilePath))
                    {
                        thumbnailFileName = Path.GetFileName(Info.FilePath);
                        thumbnailFolder   = Path.GetDirectoryName(Info.FilePath);
                    }
                    else
                    {
                        thumbnailFileName = Info.FileName;
                        thumbnailFolder   = TaskHelpers.GetScreenshotsFolder(Info.TaskSettings, Info.Metadata);
                    }

                    Info.ThumbnailFilePath = TaskHelpers.CreateThumbnail(Image, thumbnailFolder, thumbnailFileName, Info.TaskSettings);

                    if (!string.IsNullOrEmpty(Info.ThumbnailFilePath))
                    {
                        DebugHelper.WriteLine("Thumbnail saved to file: " + Info.ThumbnailFilePath);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 13
0
 private void copyTransformedToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ClipboardHelpers.CopyImage(_transformed);
 }
Ejemplo n.º 14
0
 private void copySourceToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ClipboardHelpers.CopyImage(_image);
 }
Ejemplo n.º 15
0
        public static Bitmap AnnotateImage(Bitmap bmp, string filePath, TaskSettings taskSettings, bool taskMode = false)
        {
            if (bmp != null)
            {
                using (bmp)
                {
                    RegionCaptureMode    mode    = taskMode ? RegionCaptureMode.TaskEditor : RegionCaptureMode.Editor;
                    RegionCaptureOptions options = taskSettings.CaptureSettingsReference.SurfaceOptions;

                    using (RegionCaptureForm form = new RegionCaptureForm(mode, options, bmp))
                    {
                        form.ImageFilePath = filePath;

                        form.SaveImageRequested += (output, newFilePath) =>
                        {
                            using (output)
                            {
                                if (string.IsNullOrEmpty(newFilePath))
                                {
                                    string fileName = GetFilename(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output);
                                    newFilePath = Path.Combine(taskSettings.GetScreenshotsFolder(), fileName);
                                }

                                ImageHelpers.SaveImage(output, newFilePath);
                            }

                            return(newFilePath);
                        };

                        form.SaveImageAsRequested += (output, newFilePath) =>
                        {
                            using (output)
                            {
                                if (string.IsNullOrEmpty(newFilePath))
                                {
                                    string fileName = GetFilename(taskSettings, taskSettings.ImageSettings.ImageFormat.GetDescription(), output);
                                    newFilePath = Path.Combine(taskSettings.GetScreenshotsFolder(), fileName);
                                }

                                newFilePath = ImageHelpers.SaveImageFileDialog(output, newFilePath);
                            }

                            return(newFilePath);
                        };

                        form.CopyImageRequested += output =>
                        {
                            Option.MainForm.Invoke(() =>
                            {
                                using (output) { ClipboardHelpers.CopyImage(output); }
                            });
                        };

                        form.UploadImageRequested += output =>
                        {
                            Option.MainForm.Invoke(() =>
                            {
                                //UploadManager.UploadImage(output);
                            });
                        };

                        form.PrintImageRequested += output =>
                        {
                            Option.MainForm.Invoke(() =>
                            {
                                using (output) { PrintImage(output); }
                            });
                        };

                        form.ShowDialog();

                        switch (form.Result)
                        {
                        case RegionResult.Close:     // Esc
                        case RegionResult.AnnotateCancelTask:
                            return(null);

                        case RegionResult.Region:     // Enter
                        case RegionResult.AnnotateRunAfterCaptureTasks:
                            return(form.GetResultImage());

                        case RegionResult.Fullscreen:     // Space or right click
                        case RegionResult.AnnotateContinueTask:
                            return((Bitmap)form.Canvas.Clone());
                        }
                    }
                }
            }

            return(null);
        }