public static Image AnnotateImage(Image img) { if (!Greenshot.IniFile.IniConfig.isInitialized) { Greenshot.IniFile.IniConfig.AllowSave = !Program.IsSandbox; Greenshot.IniFile.IniConfig.Init(Program.PersonalPath); } using (Image cloneImage = (Image)img.Clone()) using (Greenshot.Plugin.ICapture capture = new GreenshotPlugin.Core.Capture() { Image = cloneImage }) using (Greenshot.Drawing.Surface surface = new Greenshot.Drawing.Surface(capture)) using (Greenshot.ImageEditorForm editor = new Greenshot.ImageEditorForm(surface, true)) { editor.ClipboardCopyRequested += editor_ClipboardCopyRequested; editor.ImageUploadRequested += editor_ImageUploadRequested; if (editor.ShowDialog() == DialogResult.OK) { return editor.GetImageForExport(); } } return img; }
/// <summary> /// Perform Actions after capturing image/text/file objects /// </summary> public void PerformActions() { foreach (Software app in Engine.ConfigUI.ConfigActions.ActionsApps) { if (app.Enabled) { if (IsValidActionImage(app) && app.Name == Engine.zImageAnnotator) { try { // Compatibility fixes string LANGUAGE_PATH = Path.Combine(Application.StartupPath, @"Languages"); if (!Directory.Exists(LANGUAGE_PATH)) Directory.CreateDirectory(LANGUAGE_PATH); if (Greenshot.MainForm.instance == null) Greenshot.MainForm.Start(new string[0]); CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>(); coreConfiguration.OutputFileFilenamePattern = "${title}"; coreConfiguration.OutputFilePath = Engine.ImagesDir; ICapture capture = new GreenshotPlugin.Core.Capture(); capture.Image = TempImage; capture.CaptureDetails.Filename = Info.LocalFilePath; capture.CaptureDetails.Title = Path.GetFileNameWithoutExtension(capture.CaptureDetails.Filename); capture.CaptureDetails.AddMetaData("file", capture.CaptureDetails.Filename); capture.CaptureDetails.AddMetaData("source", "file"); var surface = new Greenshot.Drawing.Surface(capture); var editor = new Greenshot.ImageEditorForm(surface, WorkflowConfig.DestConfig.Outputs.Contains( OutputEnum.LocalDisk)) { Icon = Resources.zss_tray }; editor.SetImagePath(Info.LocalFilePath); editor.Visible = false; editor.ShowDialog(); TempImage = editor.GetImageForExport(); } catch (Exception ex) { DebugHelper.WriteException(ex, "ImageEdit"); } } else if (IsValidActionImage(app) && app.Name == Engine.zImageEffects) { var effects = new ImageEffects.ImageEffectsGUI(TempImage); effects.ShowDialog(); TempImage = effects.GetImageForExport(); } else if (File.Exists(app.Path)) { if (IsValidActionOCR(app)) { app.OpenFile(OCRFilePath); OCRText = File.ReadAllText(OCRFilePath); } else if (IsValidActionText(app)) { app.OpenFile(Info.LocalFilePath); TempText = File.ReadAllText(TempText); } else if (IsValidActionImage(app)) { WriteImage(TempImage); app.OpenFile(Info.LocalFilePath); } else if (IsValidActionFile(app)) { app.OpenFile(Info.LocalFilePath); } } DebugHelper.WriteLine(string.Format("Performed Actions using {0}.", app.Name)); } } }