Exemple #1
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;
        }
Exemple #2
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;
        }