Code reuse and cleanup.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2126 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-10-08 15:32:14 +00:00
commit 448f82f6c3
16 changed files with 119 additions and 107 deletions

View file

@ -30,6 +30,7 @@ using Confluence;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
using GreenshotPlugin.Controls;
namespace GreenshotConfluencePlugin {
/// <summary>
@ -158,15 +159,13 @@ namespace GreenshotConfluencePlugin {
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()) {
ImageOutput.SaveToStream(image, stream, outputSettings);
// COPY buffer to array
buffer = stream.ToArray();
}
errorMessage = null;
try {
ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, buffer);
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("confluence", LangKey.communication_wait),
delegate() {
ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, new ImageContainer(image, outputSettings, filename));
}
);
LOG.Debug("Uploaded to Confluence.");
if (config.CopyWikiMarkupForImageToClipboard) {
int retryCount = 2;