Refactoring which replaces the Image in the ImageOutput for an ISurface, this makes it possible to save the Surface to any possible file format and even make it possible to pass some additional information in the OutputSettings. (Except reducing the colors, there are no other settings yet)

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2376 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-11 14:36:20 +00:00
commit 5541e2e1c7
27 changed files with 191 additions and 290 deletions

View file

@ -99,25 +99,24 @@ namespace GreenshotJiraPlugin {
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surfaceToUpload, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
if (jira != null) {
using (Image image = surface.GetImageForExport()) {
try {
// Run upload in the background
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
delegate() {
jiraPlugin.JiraConnector.addAttachment(jira.Key, filename, new ImageContainer(image, outputSettings, filename));
}
);
LOG.Debug("Uploaded to Jira.");
exportInformation.ExportMade = true;
exportInformation.Uri = surface.UploadURL;
} catch (Exception e) {
MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
}
try {
// Run upload in the background
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
delegate() {
jiraPlugin.JiraConnector.addAttachment(jira.Key, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
}
);
LOG.Debug("Uploaded to Jira.");
exportInformation.ExportMade = true;
// TODO: This can't work:
exportInformation.Uri = surfaceToUpload.UploadURL;
} catch (Exception e) {
MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
}
} else {
JiraForm jiraForm = new JiraForm(jiraPlugin.JiraConnector);
@ -126,24 +125,23 @@ namespace GreenshotJiraPlugin {
DialogResult result = jiraForm.ShowDialog();
if (result == DialogResult.OK) {
try {
using (Image image = surface.GetImageForExport()) {
// Run upload in the background
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
delegate() {
jiraForm.upload(new ImageContainer(image, outputSettings, filename));
}
);
}
// Run upload in the background
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
delegate() {
jiraForm.upload(new SurfaceContainer(surfaceToUpload, outputSettings, filename));
}
);
LOG.Debug("Uploaded to Jira.");
exportInformation.ExportMade = true;
exportInformation.Uri = surface.UploadURL;
// TODO: This can't work:
exportInformation.Uri = surfaceToUpload.UploadURL;
} catch(Exception e) {
MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
}
}
}
}
ProcessExport(exportInformation, surface);
ProcessExport(exportInformation, surfaceToUpload);
return exportInformation;
}
}