Some small fixes for bugs which showed up while using the current version. In this case there was an issue with the ExportInfomation passing, an export to Outlook wasn't reported as done causing the destination picker to show again after the export.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2060 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-19 12:30:27 +00:00
commit 4be78dddd4
4 changed files with 19 additions and 16 deletions

View file

@ -218,14 +218,16 @@ namespace Greenshot.Destinations {
foreach (string inspectorCaption in inspectorCaptions.Keys) { foreach (string inspectorCaption in inspectorCaptions.Keys) {
destinations.Add(new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption])); destinations.Add(new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
} }
PickerDestination.ShowPickerMenu(false, surface, captureDetails, destinations); // Return the ExportInformation from the picker without processing, as this indirectly comes from us self
return PickerDestination.ShowPickerMenu(false, surface, captureDetails, destinations);
} }
} else {
OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC);
exportInformation.ExportMade = true;
} }
OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC);
} }
} }
ProcessExport(exportInformation, surface);
return exportInformation; return exportInformation;
} }
} }

View file

@ -67,7 +67,9 @@ namespace Greenshot.Destinations {
/// <param name="captureDetails">Details for the surface</param> /// <param name="captureDetails">Details for the surface</param>
/// <param name="destinations">The list of destinations to show</param> /// <param name="destinations">The list of destinations to show</param>
/// <returns></returns> /// <returns></returns>
public static void ShowPickerMenu(bool addDynamics, ISurface surface, ICaptureDetails captureDetails, IEnumerable<IDestination> destinations) { public static ExportInformation ShowPickerMenu(bool addDynamics, ISurface surface, ICaptureDetails captureDetails, IEnumerable<IDestination> destinations) {
// Generate an empty ExportInformation object, for when nothing was selected.
ExportInformation exportInformation = new ExportInformation(DESIGNATION, Language.GetString(LangKey.settings_destination_picker));
ContextMenuStrip menu = new ContextMenuStrip(); ContextMenuStrip menu = new ContextMenuStrip();
menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) { menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) {
LOG.DebugFormat("Close reason: {0}", eventArgs.CloseReason); LOG.DebugFormat("Close reason: {0}", eventArgs.CloseReason);
@ -102,7 +104,7 @@ namespace Greenshot.Destinations {
menu.Hide(); menu.Hide();
// Export // Export
ExportInformation exportInformation = clickedDestination.ExportCapture(true, surface, captureDetails); exportInformation = clickedDestination.ExportCapture(true, surface, captureDetails);
if (exportInformation != null && exportInformation.ExportMade) { if (exportInformation != null && exportInformation.ExportMade) {
LOG.InfoFormat("Export to {0} success, closing menu", exportInformation.DestinationDescription); LOG.InfoFormat("Export to {0} success, closing menu", exportInformation.DestinationDescription);
// close menu if the destination wasn't the editor // close menu if the destination wasn't the editor
@ -138,6 +140,7 @@ namespace Greenshot.Destinations {
menu.Items.Add(closeItem); menu.Items.Add(closeItem);
ShowMenuAtCursor(menu); ShowMenuAtCursor(menu);
return exportInformation;
} }
/// <summary> /// <summary>
@ -180,7 +183,6 @@ namespace Greenshot.Destinations {
/// <param name="captureDetails">Details of the capture</param> /// <param name="captureDetails">Details of the capture</param>
/// <returns>true if export was made</returns> /// <returns>true if export was made</returns>
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
List<IDestination> destinations = new List<IDestination>(); List<IDestination> destinations = new List<IDestination>();
foreach(IDestination destination in DestinationHelper.GetAllDestinations()) { foreach(IDestination destination in DestinationHelper.GetAllDestinations()) {
if ("Picker".Equals(destination.Designation)) { if ("Picker".Equals(destination.Designation)) {
@ -192,10 +194,8 @@ namespace Greenshot.Destinations {
destinations.Add(destination); destinations.Add(destination);
} }
ShowPickerMenu(true, surface, captureDetails, destinations); // No Processing, this is done in the selected destination (if anything was selected)
exportInformation.ExportMade = true; return ShowPickerMenu(true, surface, captureDetails, destinations);
// No Processing! :)
return exportInformation;
} }
} }
} }

View file

@ -133,11 +133,10 @@ namespace Greenshot.Destinations {
foreach (string presentation in presentations) { foreach (string presentation in presentations) {
destinations.Add(new PowerpointDestination(presentation)); destinations.Add(new PowerpointDestination(presentation));
} }
PickerDestination.ShowPickerMenu(false, surface, captureDetails, destinations); // Return the ExportInformation from the picker without processing, as this indirectly comes from us self
exportInformation.ExportMade = true; return PickerDestination.ShowPickerMenu(false, surface, captureDetails, destinations);
} }
} } else if (!exportInformation.ExportMade) {
if (!exportInformation.ExportMade) {
PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title); PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
exportInformation.ExportMade = true; exportInformation.ExportMade = true;
} }

View file

@ -142,13 +142,15 @@ namespace Greenshot.Destinations {
foreach (string document in documents) { foreach (string document in documents) {
destinations.Add(new WordDestination(document)); destinations.Add(new WordDestination(document));
} }
PickerDestination.ShowPickerMenu(false, surface, captureDetails, destinations); // Return the ExportInformation from the picker without processing, as this indirectly comes from us self
return PickerDestination.ShowPickerMenu(false, surface, captureDetails, destinations);
} }
} }
try { try {
WordExporter.InsertIntoNewDocument(tmpFile); WordExporter.InsertIntoNewDocument(tmpFile);
exportInformation.ExportMade = true; exportInformation.ExportMade = true;
} catch(Exception) { } catch(Exception) {
// Retry once, just in case
try { try {
WordExporter.InsertIntoNewDocument(tmpFile); WordExporter.InsertIntoNewDocument(tmpFile);
exportInformation.ExportMade = true; exportInformation.ExportMade = true;