diff --git a/Greenshot-OCR-Plugin/OCRPlugin.cs b/Greenshot-OCR-Plugin/OCRPlugin.cs
index f5f10eae5..33d69e817 100644
--- a/Greenshot-OCR-Plugin/OCRPlugin.cs
+++ b/Greenshot-OCR-Plugin/OCRPlugin.cs
@@ -164,10 +164,10 @@ namespace GreenshotOCR {
graphics.Clear(Color.White);
graphics.DrawImage(capturedImage, Point.Empty);
}
- filePath = host.SaveToTmpFile(tmpImage, outputSettings);
+ filePath = host.SaveToTmpFile(tmpImage, outputSettings, null);
}
} else {
- filePath = host.SaveToTmpFile(capturedImage, outputSettings);
+ filePath = host.SaveToTmpFile(capturedImage, outputSettings, null);
}
}
diff --git a/Greenshot/Helpers/ClipboardHelper.cs b/Greenshot/Helpers/ClipboardHelper.cs
index 831800187..2d91e1aa0 100644
--- a/Greenshot/Helpers/ClipboardHelper.cs
+++ b/Greenshot/Helpers/ClipboardHelper.cs
@@ -381,7 +381,7 @@ EndSelection:<<<<<<<4
// Set the HTML
if (config.ClipboardFormats.Contains(ClipboardFormat.HTML)) {
- string tmpFile = ImageOutput.SaveToTmpFile(image, new OutputSettings(OutputFormat.png));
+ string tmpFile = ImageOutput.SaveToTmpFile(image, new OutputSettings(OutputFormat.png), null);
string html = getHTMLString(image, tmpFile);
ido.SetText(html, TextDataFormat.Html);
} else if (config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) {
diff --git a/Greenshot/Helpers/ImageOutput.cs b/Greenshot/Helpers/ImageOutput.cs
index 2a573e806..279c9d312 100644
--- a/Greenshot/Helpers/ImageOutput.cs
+++ b/Greenshot/Helpers/ImageOutput.cs
@@ -350,11 +350,14 @@ namespace Greenshot.Helpers {
///
///
///
- public static string SaveToTmpFile(Image image, OutputSettings outputSettings) {
+ public static string SaveToTmpFile(Image image, OutputSettings outputSettings, string destinationPath) {
string tmpFile = Path.GetRandomFileName() + "." + outputSettings.Format.ToString();
// Prevent problems with "other characters", which could cause problems
tmpFile = Regex.Replace(tmpFile, @"[^\d\w\.]", "");
- string tmpPath = Path.Combine(Path.GetTempPath(), tmpFile);
+ if (destinationPath == null) {
+ destinationPath = Path.GetTempPath();
+ }
+ string tmpPath = Path.Combine(destinationPath, tmpFile);
LOG.Debug("Creating TMP File : " + tmpPath);
try {
diff --git a/Greenshot/Helpers/PluginHelper.cs b/Greenshot/Helpers/PluginHelper.cs
index e438928dc..945130d0d 100644
--- a/Greenshot/Helpers/PluginHelper.cs
+++ b/Greenshot/Helpers/PluginHelper.cs
@@ -99,8 +99,8 @@ namespace Greenshot.Helpers {
ImageOutput.SaveToStream(img, stream, outputSettings);
}
- public string SaveToTmpFile(Image img, OutputSettings outputSettings) {
- return ImageOutput.SaveToTmpFile(img, outputSettings);
+ public string SaveToTmpFile(Image img, OutputSettings outputSettings, string destinationPath) {
+ return ImageOutput.SaveToTmpFile(img, outputSettings, destinationPath);
}
public string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputSettings outputSettings) {
diff --git a/GreenshotPlugin/Core/AbstractDestination.cs b/GreenshotPlugin/Core/AbstractDestination.cs
index 6a12a0ce9..dc6c714cd 100644
--- a/GreenshotPlugin/Core/AbstractDestination.cs
+++ b/GreenshotPlugin/Core/AbstractDestination.cs
@@ -35,7 +35,7 @@ namespace GreenshotPlugin.Core {
///
/// Description of AbstractDestination.
///
- public abstract class AbstractDestination : IDestination {
+ public abstract class AbstractDestination : IDestination {
private const string PATH_KEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AbstractDestination));
private static CoreConfiguration configuration = IniConfig.GetIniSection();
@@ -124,26 +124,37 @@ namespace GreenshotPlugin.Core {
basisMenuItem.DropDownOpening += delegate (object source, EventArgs eventArgs) {
if (basisMenuItem.DropDownItems.Count == 0) {
List subDestinations = new List();
- // Fixing Bug #3536968 by catching the COMException (every exception) and not displaying the "subDestinations"
- try {
- subDestinations.AddRange(DynamicDestinations());
- } catch(Exception ex) {
- LOG.ErrorFormat("Skipping {0}, due to the following error: {1}", Description, ex.Message);
- }
+ // Fixing Bug #3536968 by catching the COMException (every exception) and not displaying the "subDestinations"
+ try {
+ subDestinations.AddRange(DynamicDestinations());
+ } catch(Exception ex) {
+ LOG.ErrorFormat("Skipping {0}, due to the following error: {1}", Description, ex.Message);
+ }
if (subDestinations.Count > 0) {
subDestinations.Sort();
- ToolStripMenuItem destinationMenuItem = new ToolStripMenuItem(Description);
- destinationMenuItem.Tag = this;
- destinationMenuItem.Image = DisplayIcon;
- destinationMenuItem.Click += destinationClickHandler;
- basisMenuItem.DropDownItems.Add(destinationMenuItem);
- foreach(IDestination subDestination in subDestinations) {
- destinationMenuItem = new ToolStripMenuItem(subDestination.Description);
- destinationMenuItem.Tag = subDestination;
- destinationMenuItem.Image = subDestination.DisplayIcon;
+
+ ToolStripMenuItem destinationMenuItem = null;
+ if (!useDynamicsOnly) {
+ destinationMenuItem = new ToolStripMenuItem(Description);
+ destinationMenuItem.Tag = this;
+ destinationMenuItem.Image = DisplayIcon;
destinationMenuItem.Click += destinationClickHandler;
basisMenuItem.DropDownItems.Add(destinationMenuItem);
}
+ if (useDynamicsOnly && subDestinations.Count == 1) {
+ basisMenuItem.Tag = subDestinations[0];
+ basisMenuItem.Text = subDestinations[0].Description;
+ basisMenuItem.Click -= destinationClickHandler;
+ basisMenuItem.Click += destinationClickHandler;
+ } else {
+ foreach (IDestination subDestination in subDestinations) {
+ destinationMenuItem = new ToolStripMenuItem(subDestination.Description);
+ destinationMenuItem.Tag = subDestination;
+ destinationMenuItem.Image = subDestination.DisplayIcon;
+ destinationMenuItem.Click += destinationClickHandler;
+ basisMenuItem.DropDownItems.Add(destinationMenuItem);
+ }
+ }
} else {
// Setting base "click" only if there are no sub-destinations
@@ -173,6 +184,12 @@ namespace GreenshotPlugin.Core {
}
}
+ public virtual bool useDynamicsOnly {
+ get {
+ return false;
+ }
+ }
+
public virtual bool isLinkable {
get {
return false;
diff --git a/GreenshotPlugin/Interfaces/IDestination.cs b/GreenshotPlugin/Interfaces/IDestination.cs
index cd54392ac..2c005e129 100644
--- a/GreenshotPlugin/Interfaces/IDestination.cs
+++ b/GreenshotPlugin/Interfaces/IDestination.cs
@@ -159,6 +159,13 @@ namespace Greenshot.Plugin {
get;
}
+ ///
+ /// Returns if the destination is active
+ ///
+ bool useDynamicsOnly {
+ get;
+ }
+
///
/// Returns true if this destination returns a link
///
diff --git a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs
index 49f2f3240..ef4ffb617 100644
--- a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs
+++ b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs
@@ -142,7 +142,8 @@ namespace Greenshot.Plugin {
///
/// The Image to save
/// OutputSettings
- string SaveToTmpFile(Image image, OutputSettings outputSettings);
+ /// destination path, can be empty
+ string SaveToTmpFile(Image image, OutputSettings outputSettings, string destinationPath);
///
/// Saves the image to a temp file, but the name is build with the capture details & pattern