Removed the MessageBox from the ConfluenceDestination, replaced it with a notify like all the other destinations.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1822 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-05-02 10:23:00 +00:00
commit ffb2e892cf

View file

@ -129,11 +129,20 @@ namespace GreenshotConfluencePlugin {
} }
if (selectedPage != null) { if (selectedPage != null) {
using (Image image = surface.GetImageForExport()) { using (Image image = surface.GetImageForExport()) {
bool uploaded = upload(image, selectedPage, filename, openPage); string errorMessage;
bool uploaded = upload(image, selectedPage, filename, out errorMessage);
if (uploaded) { if (uploaded) {
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString("exported_to", Description)); if (openPage) {
try {
Process.Start(page.Url);
} catch { }
}
surface.UploadURL = page.Url;
surface.SendMessageEvent(this, SurfaceMessageTyp.UploadedUrl, Language.GetFormattedString("exported_to", Description));
surface.Modified = false; surface.Modified = false;
return true; return true;
} else {
surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetString("confluence", LangKey.upload_failure) + " " + errorMessage);
} }
} }
} }
@ -141,7 +150,7 @@ namespace GreenshotConfluencePlugin {
return false; return false;
} }
private bool upload(Image image, Page page, string filename, bool openPage) { private bool upload(Image image, Page page, string filename, out string errorMessage) {
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors); OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
byte[] buffer; byte[] buffer;
using (MemoryStream stream = new MemoryStream()) { using (MemoryStream stream = new MemoryStream()) {
@ -149,6 +158,7 @@ namespace GreenshotConfluencePlugin {
// COPY buffer to array // COPY buffer to array
buffer = stream.ToArray(); buffer = stream.ToArray();
} }
errorMessage = null;
try { try {
ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, buffer); ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, buffer);
LOG.Debug("Uploaded to Confluence."); LOG.Debug("Uploaded to Confluence.");
@ -169,16 +179,9 @@ namespace GreenshotConfluencePlugin {
} }
} }
} }
if (openPage) {
try {
Process.Start(page.Url);
} catch {}
} else {
System.Windows.MessageBox.Show(Language.GetString("confluence", LangKey.upload_success));
}
return true; return true;
} catch(Exception e) { } catch(Exception e) {
System.Windows.MessageBox.Show(Language.GetString("confluence", LangKey.upload_failure) + " " + e.Message); errorMessage = e.Message;
} }
return false; return false;
} }