From ffb2e892cf180771903b85aa9461c8b853e3e31b Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 2 May 2012 10:23:00 +0000 Subject: [PATCH] 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 --- .../ConfluenceDestination.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/GreenshotConfluencePlugin/ConfluenceDestination.cs b/GreenshotConfluencePlugin/ConfluenceDestination.cs index c8fa2de7e..d510d3825 100644 --- a/GreenshotConfluencePlugin/ConfluenceDestination.cs +++ b/GreenshotConfluencePlugin/ConfluenceDestination.cs @@ -129,11 +129,20 @@ namespace GreenshotConfluencePlugin { } if (selectedPage != null) { using (Image image = surface.GetImageForExport()) { - bool uploaded = upload(image, selectedPage, filename, openPage); + string errorMessage; + bool uploaded = upload(image, selectedPage, filename, out errorMessage); 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; return true; + } else { + surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetString("confluence", LangKey.upload_failure) + " " + errorMessage); } } } @@ -141,7 +150,7 @@ namespace GreenshotConfluencePlugin { 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); byte[] buffer; using (MemoryStream stream = new MemoryStream()) { @@ -149,6 +158,7 @@ namespace GreenshotConfluencePlugin { // COPY buffer to array buffer = stream.ToArray(); } + errorMessage = null; try { ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, buffer); 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; } catch(Exception e) { - System.Windows.MessageBox.Show(Language.GetString("confluence", LangKey.upload_failure) + " " + e.Message); + errorMessage = e.Message; } return false; }