BUG-2056: Make sure the external command doesn't use the default format if .greenshot is selected.

This commit is contained in:
Robin 2017-01-13 16:24:23 +01:00
commit 19802d54c8

View file

@ -43,32 +43,26 @@ namespace ExternalCommand {
_presetCommand = commando; _presetCommand = commando;
} }
public override string Designation { public override string Designation => "External " + _presetCommand.Replace(',','_');
get {
return "External " + _presetCommand.Replace(',','_');
}
}
public override string Description { public override string Description => _presetCommand;
get {
return _presetCommand;
}
}
public override IEnumerable<IDestination> DynamicDestinations() { public override IEnumerable<IDestination> DynamicDestinations() {
yield break; yield break;
} }
public override Image DisplayIcon { public override Image DisplayIcon => IconCache.IconForCommand(_presetCommand);
get {
return IconCache.IconForCommand(_presetCommand);
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(Designation, Description); ExportInformation exportInformation = new ExportInformation(Designation, Description);
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(); SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();
// BUG-2056 reported a logical issue, using greenshot format as the default causes issues with the external commands.
// If OutputFormat is Greenshot, use PNG instead.
if (outputSettings.Format == OutputFormat.greenshot)
{
outputSettings.Format = OutputFormat.png;
}
if (_presetCommand != null) { if (_presetCommand != null) {
if (!config.RunInbackground.ContainsKey(_presetCommand)) { if (!config.RunInbackground.ContainsKey(_presetCommand)) {
@ -154,12 +148,12 @@ namespace ExternalCommand {
private int CallExternalCommand(string commando, string fullPath, out string output, out string error) { private int CallExternalCommand(string commando, string fullPath, out string output, out string error) {
try { try {
return CallExternalCommand(commando, fullPath, null, out output, out error); return CallExternalCommand(commando, fullPath, null, out output, out error);
} catch (Win32Exception w32ex) { } catch (Win32Exception w32Ex) {
try { try {
return CallExternalCommand(commando, fullPath, "runas", out output, out error); return CallExternalCommand(commando, fullPath, "runas", out output, out error);
} catch { } catch {
w32ex.Data.Add("commandline", config.Commandline[_presetCommand]); w32Ex.Data.Add("commandline", config.Commandline[_presetCommand]);
w32ex.Data.Add("arguments", config.Argument[_presetCommand]); w32Ex.Data.Add("arguments", config.Argument[_presetCommand]);
throw; throw;
} }
} catch (Exception ex) { } catch (Exception ex) {