void CaptureImage(Image img)
        {
            DoCaptureFeedback();
            this.Hide();
            string fullPath = null;

            ImageOutput.PrepareClipboardObject();
            if ((conf.Output_Destinations & ScreenshotDestinations.FileDefault) == ScreenshotDestinations.FileDefault)
            {
                string filename = FilenameHelper.GetFilenameFromPattern(conf.Output_File_FilenamePattern, conf.Output_File_Format);
                fullPath = Path.Combine(conf.Output_File_Path, filename);
                ImageOutput.Save(img, fullPath);
            }
            if ((conf.Output_Destinations & ScreenshotDestinations.FileWithDialog) == ScreenshotDestinations.FileWithDialog)
            {
                fullPath = ImageOutput.SaveWithDialog(img);
            }
            if ((conf.Output_Destinations & ScreenshotDestinations.Clipboard) == ScreenshotDestinations.Clipboard)
            {
                ImageOutput.CopyToClipboard(img);
            }
            if ((conf.Output_Destinations & ScreenshotDestinations.Printer) == ScreenshotDestinations.Printer)
            {
                new PrintHelper(img).PrintWithDialog();
            }
            if ((conf.Output_Destinations & ScreenshotDestinations.Editor) == ScreenshotDestinations.Editor)
            {
                ImageEditorForm editor = new ImageEditorForm();
                editor.SetImage(img);
                if (fullPath != null)
                {
                    editor.SetImagePath(fullPath);
                }
                editor.Show();
            }
        }
Ejemplo n.º 2
0
        public static Image AnnotateImage(Image img, string imgPath, bool allowSave, string configPath,
            Action<Image> clipboardCopyRequested,
            Action<Image> imageUploadRequested,
            Action<Image, string> imageSaveRequested,
            Func<Image, string, string> imageSaveAsRequested,
            Action<Image> printImageRequested)
        {
            if (!IniConfig.isInitialized)
            {
                IniConfig.AllowSave = allowSave;
                IniConfig.Init(configPath);
            }

            using (Image cloneImage = img != null ? (Image)img.Clone() : LoadImage(imgPath))
            using (ICapture capture = new Capture { Image = cloneImage })
            using (Surface surface = new Surface(capture))
            using (ImageEditorForm editor = new ImageEditorForm(surface, true))
            {
                editor.IsTaskWork = img != null;
                editor.SetImagePath(imgPath);
                editor.ClipboardCopyRequested += clipboardCopyRequested;
                editor.ImageUploadRequested += imageUploadRequested;
                editor.ImageSaveRequested += imageSaveRequested;
                editor.ImageSaveAsRequested += imageSaveAsRequested;
                editor.PrintImageRequested += printImageRequested;

                DialogResult result = editor.ShowDialog();

                if (result == DialogResult.OK && editor.IsTaskWork)
                {
                    using (img)
                    {
                        return editor.GetImageForExport();
                    }
                }

                if (result == DialogResult.Abort)
                {
                    return null;
                }
            }

            return img;
        }
Ejemplo n.º 3
0
        public static Image AnnotateImage(Image img, bool allowSave, string configPath, Action<Image> clipboardCopyRequested, Action<Image> imageUploadRequested)
        {
            if (!IniConfig.isInitialized)
            {
                IniConfig.AllowSave = allowSave;
                IniConfig.Init(configPath);
            }

            using (Image cloneImage = (Image)img.Clone())
            using (ICapture capture = new Capture { Image = cloneImage })
            using (Surface surface = new Surface(capture))
            using (ImageEditorForm editor = new ImageEditorForm(surface, true))
            {
                editor.ClipboardCopyRequested += clipboardCopyRequested;
                editor.ImageUploadRequested += imageUploadRequested;

                if (editor.ShowDialog() == DialogResult.OK)
                {
                    using (img)
                    {
                        return editor.GetImageForExport();
                    }
                }
            }

            return img;
        }