mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
Added some fixes for the IDestination code, allowing a Destination to supply dynamics without base. Also made the savetmpfile able to store in a supplied path.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2037 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c037b99d6e
commit
203a34ee6f
7 changed files with 52 additions and 24 deletions
|
@ -164,10 +164,10 @@ namespace GreenshotOCR {
|
||||||
graphics.Clear(Color.White);
|
graphics.Clear(Color.White);
|
||||||
graphics.DrawImage(capturedImage, Point.Empty);
|
graphics.DrawImage(capturedImage, Point.Empty);
|
||||||
}
|
}
|
||||||
filePath = host.SaveToTmpFile(tmpImage, outputSettings);
|
filePath = host.SaveToTmpFile(tmpImage, outputSettings, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filePath = host.SaveToTmpFile(capturedImage, outputSettings);
|
filePath = host.SaveToTmpFile(capturedImage, outputSettings, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,7 @@ EndSelection:<<<<<<<4
|
||||||
|
|
||||||
// Set the HTML
|
// Set the HTML
|
||||||
if (config.ClipboardFormats.Contains(ClipboardFormat.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);
|
string html = getHTMLString(image, tmpFile);
|
||||||
ido.SetText(html, TextDataFormat.Html);
|
ido.SetText(html, TextDataFormat.Html);
|
||||||
} else if (config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) {
|
} else if (config.ClipboardFormats.Contains(ClipboardFormat.HTMLDATAURL)) {
|
||||||
|
|
|
@ -350,11 +350,14 @@ namespace Greenshot.Helpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="image"></param>
|
/// <param name="image"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
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();
|
string tmpFile = Path.GetRandomFileName() + "." + outputSettings.Format.ToString();
|
||||||
// Prevent problems with "other characters", which could cause problems
|
// Prevent problems with "other characters", which could cause problems
|
||||||
tmpFile = Regex.Replace(tmpFile, @"[^\d\w\.]", "");
|
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);
|
LOG.Debug("Creating TMP File : " + tmpPath);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -99,8 +99,8 @@ namespace Greenshot.Helpers {
|
||||||
ImageOutput.SaveToStream(img, stream, outputSettings);
|
ImageOutput.SaveToStream(img, stream, outputSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SaveToTmpFile(Image img, OutputSettings outputSettings) {
|
public string SaveToTmpFile(Image img, OutputSettings outputSettings, string destinationPath) {
|
||||||
return ImageOutput.SaveToTmpFile(img, outputSettings);
|
return ImageOutput.SaveToTmpFile(img, outputSettings, destinationPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputSettings outputSettings) {
|
public string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputSettings outputSettings) {
|
||||||
|
|
|
@ -132,18 +132,29 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
if (subDestinations.Count > 0) {
|
if (subDestinations.Count > 0) {
|
||||||
subDestinations.Sort();
|
subDestinations.Sort();
|
||||||
ToolStripMenuItem destinationMenuItem = new ToolStripMenuItem(Description);
|
|
||||||
|
ToolStripMenuItem destinationMenuItem = null;
|
||||||
|
if (!useDynamicsOnly) {
|
||||||
|
destinationMenuItem = new ToolStripMenuItem(Description);
|
||||||
destinationMenuItem.Tag = this;
|
destinationMenuItem.Tag = this;
|
||||||
destinationMenuItem.Image = DisplayIcon;
|
destinationMenuItem.Image = DisplayIcon;
|
||||||
destinationMenuItem.Click += destinationClickHandler;
|
destinationMenuItem.Click += destinationClickHandler;
|
||||||
basisMenuItem.DropDownItems.Add(destinationMenuItem);
|
basisMenuItem.DropDownItems.Add(destinationMenuItem);
|
||||||
foreach(IDestination subDestination in subDestinations) {
|
}
|
||||||
|
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 = new ToolStripMenuItem(subDestination.Description);
|
||||||
destinationMenuItem.Tag = subDestination;
|
destinationMenuItem.Tag = subDestination;
|
||||||
destinationMenuItem.Image = subDestination.DisplayIcon;
|
destinationMenuItem.Image = subDestination.DisplayIcon;
|
||||||
destinationMenuItem.Click += destinationClickHandler;
|
destinationMenuItem.Click += destinationClickHandler;
|
||||||
basisMenuItem.DropDownItems.Add(destinationMenuItem);
|
basisMenuItem.DropDownItems.Add(destinationMenuItem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Setting base "click" only if there are no sub-destinations
|
// 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 {
|
public virtual bool isLinkable {
|
||||||
get {
|
get {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -159,6 +159,13 @@ namespace Greenshot.Plugin {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns if the destination is active
|
||||||
|
/// </summary>
|
||||||
|
bool useDynamicsOnly {
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if this destination returns a link
|
/// Returns true if this destination returns a link
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -142,7 +142,8 @@ namespace Greenshot.Plugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="image">The Image to save</param>
|
/// <param name="image">The Image to save</param>
|
||||||
/// <param name="outputSettings">OutputSettings</param>
|
/// <param name="outputSettings">OutputSettings</param>
|
||||||
string SaveToTmpFile(Image image, OutputSettings outputSettings);
|
/// <param name="destinationPath">destination path, can be empty</param>
|
||||||
|
string SaveToTmpFile(Image image, OutputSettings outputSettings, string destinationPath);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the image to a temp file, but the name is build with the capture details & pattern
|
/// Saves the image to a temp file, but the name is build with the capture details & pattern
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue