From 4029e0149165ac0059efc0305f7257039a479a1f Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 12 Jan 2017 21:02:07 +0100 Subject: [PATCH 01/39] Improved Jira code with the latest state of Dapplo.Jira [skip ci] --- GreenshotJiraPlugin/AsyncMemoryCache.cs | 2 +- .../GreenshotJiraPlugin.csproj | 27 ++-- GreenshotJiraPlugin/JiraConnector.cs | 23 ++-- GreenshotJiraPlugin/JiraMonitor.cs | 5 +- GreenshotJiraPlugin/JiraPlugin.cs | 2 +- GreenshotJiraPlugin/Log4NetLogger.cs | 2 +- .../SvgBitmapHttpContentConverter.cs | 126 ------------------ GreenshotJiraPlugin/packages.config | 8 +- 8 files changed, 37 insertions(+), 158 deletions(-) delete mode 100644 GreenshotJiraPlugin/SvgBitmapHttpContentConverter.cs diff --git a/GreenshotJiraPlugin/AsyncMemoryCache.cs b/GreenshotJiraPlugin/AsyncMemoryCache.cs index f7d029750..479bbbd20 100644 --- a/GreenshotJiraPlugin/AsyncMemoryCache.cs +++ b/GreenshotJiraPlugin/AsyncMemoryCache.cs @@ -29,7 +29,7 @@ using System; using System.Runtime.Caching; using System.Threading; using System.Threading.Tasks; -using Dapplo.Log.Facade; +using Dapplo.Log; #endregion diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index fe5838095..7defad044 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -34,32 +34,42 @@ - - ..\packages\Dapplo.HttpExtensions.0.5.43\lib\net45\Dapplo.HttpExtensions.dll + + ..\packages\Dapplo.HttpExtensions.0.6.8\lib\net45\Dapplo.HttpExtensions.dll True - - ..\packages\Dapplo.Jira.0.1.65\lib\net45\Dapplo.Jira.dll + + ..\packages\Dapplo.Jira.0.3.1\lib\net45\Dapplo.Jira.dll True - - ..\packages\Dapplo.Log.Facade.0.5.4\lib\net45\Dapplo.Log.Facade.dll + + ..\packages\Dapplo.Log.1.0.22\lib\net45\Dapplo.Log.dll True ..\Greenshot\Lib\log4net.dll - - ..\packages\Svg.2.2.2\lib\net35\Svg.dll + + + + + ..\packages\Svg.2.3.0\lib\net35\Svg.dll True + + + + + + + @@ -94,7 +104,6 @@ - Always diff --git a/GreenshotJiraPlugin/JiraConnector.cs b/GreenshotJiraPlugin/JiraConnector.cs index ee9e98a2f..0aec2884d 100644 --- a/GreenshotJiraPlugin/JiraConnector.cs +++ b/GreenshotJiraPlugin/JiraConnector.cs @@ -24,12 +24,13 @@ using System; using System.Collections.Generic; using System.Drawing; using System.IO; -using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Dapplo.HttpExtensions; +using Dapplo.HttpExtensions.Extensions; using Dapplo.Jira; +using Dapplo.Jira.Converters; using Dapplo.Jira.Entities; using Greenshot.IniFile; using GreenshotPlugin.Core; @@ -49,25 +50,17 @@ namespace GreenshotJiraPlugin { private readonly int _timeout; private JiraApi _jiraApi; private IssueTypeBitmapCache _issueTypeBitmapCache; - private static readonly SvgBitmapHttpContentConverter SvgBitmapHttpContentConverterInstance = new SvgBitmapHttpContentConverter(); /// /// Initialize some basic stuff, in the case the SVG to bitmap converter /// static JiraConnector() { - if (HttpExtensionsGlobals.HttpContentConverters.All(x => x.GetType() != typeof(SvgBitmapHttpContentConverter))) - { - HttpExtensionsGlobals.HttpContentConverters.Add(SvgBitmapHttpContentConverterInstance); - } - SvgBitmapHttpContentConverterInstance.Width = CoreConfig.IconSize.Width; - SvgBitmapHttpContentConverterInstance.Height = CoreConfig.IconSize.Height; CoreConfig.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(CoreConfig.IconSize)) { - SvgBitmapHttpContentConverterInstance.Width = CoreConfig.IconSize.Width; - SvgBitmapHttpContentConverterInstance.Height = CoreConfig.IconSize.Height; + JiraPlugin.Instance.JiraConnector._jiraApi?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height }); } }; @@ -111,6 +104,8 @@ namespace GreenshotJiraPlugin { return false; } _jiraApi = new JiraApi(new Uri(JiraConfig.Url)); + _jiraApi.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height }); + _issueTypeBitmapCache = new IssueTypeBitmapCache(_jiraApi); LoginInfo loginInfo; try @@ -226,7 +221,7 @@ namespace GreenshotJiraPlugin { await CheckCredentialsAsync(); try { - return await _jiraApi.GetIssueAsync(issueKey).ConfigureAwait(false); + return await _jiraApi.Issue.GetAsync(issueKey).ConfigureAwait(false); } catch { @@ -248,7 +243,7 @@ namespace GreenshotJiraPlugin { { content.WriteToStream(memoryStream); memoryStream.Seek(0, SeekOrigin.Begin); - await _jiraApi.AttachAsync(issueKey, memoryStream, content.Filename, content.ContentType, cancellationToken).ConfigureAwait(false); + await _jiraApi.Attachment.AttachAsync(issueKey, memoryStream, content.Filename, content.ContentType, cancellationToken).ConfigureAwait(false); } } @@ -262,7 +257,7 @@ namespace GreenshotJiraPlugin { public async Task AddCommentAsync(string issueKey, string body, string visibility = null, CancellationToken cancellationToken = default(CancellationToken)) { await CheckCredentialsAsync(); - await _jiraApi.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false); + await _jiraApi.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false); } /// @@ -274,7 +269,7 @@ namespace GreenshotJiraPlugin { public async Task> SearchAsync(Filter filter, CancellationToken cancellationToken = default(CancellationToken)) { await CheckCredentialsAsync(); - var searchResult = await _jiraApi.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false); + var searchResult = await _jiraApi.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false); return searchResult.Issues; } diff --git a/GreenshotJiraPlugin/JiraMonitor.cs b/GreenshotJiraPlugin/JiraMonitor.cs index 81605bddf..7bea19b11 100644 --- a/GreenshotJiraPlugin/JiraMonitor.cs +++ b/GreenshotJiraPlugin/JiraMonitor.cs @@ -26,7 +26,7 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Dapplo.Jira; -using Dapplo.Log.Facade; +using Dapplo.Log; using GreenshotJiraPlugin.Hooking; namespace GreenshotJiraPlugin @@ -45,6 +45,7 @@ namespace GreenshotJiraPlugin private readonly IList _jiraInstances = new List(); private readonly IDictionary _projectJiraApiMap = new Dictionary(); private readonly int _maxEntries; + // TODO: Add issues from issueHistory (JQL -> Where.IssueKey.InIssueHistory()) private IDictionary _recentJiras = new Dictionary(); /// @@ -144,7 +145,7 @@ namespace GreenshotJiraPlugin JiraApi jiraApi; if (_projectJiraApiMap.TryGetValue(jiraDetails.ProjectKey, out jiraApi)) { - var issue = await jiraApi.GetIssueAsync(jiraDetails.JiraKey).ConfigureAwait(false); + var issue = await jiraApi.Issue.GetAsync(jiraDetails.JiraKey).ConfigureAwait(false); jiraDetails.JiraIssue = issue; } // Send event diff --git a/GreenshotJiraPlugin/JiraPlugin.cs b/GreenshotJiraPlugin/JiraPlugin.cs index a7240293e..24969d25f 100644 --- a/GreenshotJiraPlugin/JiraPlugin.cs +++ b/GreenshotJiraPlugin/JiraPlugin.cs @@ -24,7 +24,7 @@ using Greenshot.IniFile; using Greenshot.Plugin; using System; using System.Threading.Tasks; -using Dapplo.Log.Facade; +using Dapplo.Log; using GreenshotJiraPlugin.Forms; using GreenshotPlugin.Core; using log4net; diff --git a/GreenshotJiraPlugin/Log4NetLogger.cs b/GreenshotJiraPlugin/Log4NetLogger.cs index 1b7ce2661..3018a8823 100644 --- a/GreenshotJiraPlugin/Log4NetLogger.cs +++ b/GreenshotJiraPlugin/Log4NetLogger.cs @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -using Dapplo.Log.Facade; +using Dapplo.Log; using log4net; namespace GreenshotJiraPlugin diff --git a/GreenshotJiraPlugin/SvgBitmapHttpContentConverter.cs b/GreenshotJiraPlugin/SvgBitmapHttpContentConverter.cs deleted file mode 100644 index 47b3a24d1..000000000 --- a/GreenshotJiraPlugin/SvgBitmapHttpContentConverter.cs +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Greenshot - a free and open source screenshot tool - * Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom - * - * For more information see: http://getgreenshot.org/ - * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using Dapplo.HttpExtensions; -using Dapplo.HttpExtensions.ContentConverter; -using Dapplo.HttpExtensions.Extensions; -using Dapplo.HttpExtensions.Support; -using Dapplo.Log.Facade; -using System.Net.Http; -using System.Net.Http.Headers; - -namespace GreenshotJiraPlugin -{ - /// - /// This adds SVG image support for the Jira Plugin - /// - public class SvgBitmapHttpContentConverter : IHttpContentConverter - { - private static readonly LogSource Log = new LogSource(); - private static readonly IList SupportedContentTypes = new List(); - - static SvgBitmapHttpContentConverter() - { - SupportedContentTypes.Add(MediaTypes.Svg.EnumValueOf()); - } - - /// - public int Order => 0; - - public int Width { get; set; } - - public int Height { get; set; } - - /// - /// This checks if the HttpContent can be converted to a Bitmap and is assignable to the specified Type - /// - /// This should be something we can assign Bitmap to - /// HttpContent to process - /// true if it can convert - public bool CanConvertFromHttpContent(Type typeToConvertTo, HttpContent httpContent) - { - if (typeToConvertTo == typeof(object) || !typeToConvertTo.IsAssignableFrom(typeof(Bitmap))) - { - return false; - } - var httpBehaviour = HttpBehaviour.Current; - return !httpBehaviour.ValidateResponseContentType || SupportedContentTypes.Contains(httpContent.GetContentType()); - } - - /// - public async Task ConvertFromHttpContentAsync(Type resultType, HttpContent httpContent, CancellationToken cancellationToken = default(CancellationToken)) - { - if (!CanConvertFromHttpContent(resultType, httpContent)) - { - var exMessage = "CanConvertFromHttpContent resulted in false, ConvertFromHttpContentAsync is not supposed to be called."; - Log.Error().WriteLine(exMessage); - throw new NotSupportedException(exMessage); - } - using (var memoryStream = (MemoryStream) await StreamHttpContentConverter.Instance.ConvertFromHttpContentAsync(typeof(MemoryStream), httpContent, cancellationToken).ConfigureAwait(false)) - { - Log.Debug().WriteLine("Creating a Bitmap from the SVG."); - var svgImage = new SvgImage(memoryStream) - { - Height = Height, - Width = Width - }; - return svgImage.Image; - } - } - - /// - public bool CanConvertToHttpContent(Type typeToConvert, object content) - { - return false; - } - - /// - public HttpContent ConvertToHttpContent(Type typeToConvert, object content) - { - return null; - } - - /// - public void AddAcceptHeadersForType(Type resultType, HttpRequestMessage httpRequestMessage) - { - if (resultType == null) - { - throw new ArgumentNullException(nameof(resultType)); - } - if (httpRequestMessage == null) - { - throw new ArgumentNullException(nameof(httpRequestMessage)); - } - if (resultType == typeof(object) || !resultType.IsAssignableFrom(typeof(Bitmap))) - { - return; - } - httpRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypes.Svg.EnumValueOf())); - Log.Debug().WriteLine("Modified the header(s) of the HttpRequestMessage: Accept: {0}", httpRequestMessage.Headers.Accept); - } - } -} diff --git a/GreenshotJiraPlugin/packages.config b/GreenshotJiraPlugin/packages.config index fade6b5dd..38a68ba7c 100644 --- a/GreenshotJiraPlugin/packages.config +++ b/GreenshotJiraPlugin/packages.config @@ -1,8 +1,8 @@  - - - + + + - + \ No newline at end of file From 96b92df4954941c343dc0ec28aed2a1996e0e3fc Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 12 Jan 2017 21:26:30 +0100 Subject: [PATCH 02/39] Added the FEATURE-998 also to the open last file context menu. --- Greenshot/Forms/MainForm.cs | 27 +------------- Greenshot/Helpers/CaptureHelper.cs | 18 +++------ GreenshotPlugin/Core/ExplorerHelper.cs | 51 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 38 deletions(-) create mode 100644 GreenshotPlugin/Core/ExplorerHelper.cs diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index b8164fba4..da36ae559 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -1321,30 +1321,7 @@ namespace Greenshot { } } - if (path != null) { - try { - // Check if path is a directory - if (Directory.Exists(path)) - { - using (Process.Start(path)) - { - } - } - // Check if path is a file - else if (File.Exists(path)) - { - // Start the explorer process and select the file - using (var explorer = Process.Start("explorer.exe", $"/select,\"{path}\"")) - { - explorer?.WaitForInputIdle(500); - } - } - } catch (Exception ex) { - // Make sure we show what we tried to open in the exception - ex.Data.Add("path", path); - throw; - } - } + ExplorerHelper.OpenInExplorer(path); break; case ClickActions.OPEN_LAST_IN_EDITOR: if (File.Exists(_conf.OutputFileAsFullpath)) { @@ -1381,7 +1358,7 @@ namespace Greenshot { } LOG.Debug("DoubleClick was called! Starting: " + path); try { - Process.Start(path); + ExplorerHelper.OpenInExplorer(path); } catch (Exception ex) { // Make sure we show what we tried to open in the exception ex.Data.Add("path", path); diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index e62afabe7..9cfc3a665 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -512,22 +512,14 @@ namespace Greenshot.Helpers { string errorMessage = null; var path = Path.GetDirectoryName(surface.LastSaveFullPath); try { - if (path != null) - { - var processStartInfo = new ProcessStartInfo("explorer.exe") - { - Arguments = path, - UseShellExecute = false - }; - using (var process = new Process()) { - process.StartInfo = processStartInfo; - process.Start(); - } - } - } catch (Exception ex) { + ExplorerHelper.OpenInExplorer(path); + } + catch (Exception ex) + { errorMessage = ex.Message; } // Added fallback for when the explorer can't be found + // TODO: Check if this makes sense if (errorMessage != null) { try { string windowsPath = Environment.GetEnvironmentVariable("SYSTEMROOT"); diff --git a/GreenshotPlugin/Core/ExplorerHelper.cs b/GreenshotPlugin/Core/ExplorerHelper.cs new file mode 100644 index 000000000..12bcb1787 --- /dev/null +++ b/GreenshotPlugin/Core/ExplorerHelper.cs @@ -0,0 +1,51 @@ +using System; +using System.Diagnostics; +using System.IO; + +namespace GreenshotPlugin.Core +{ + /// + /// Simple utility for the explorer + /// + public static class ExplorerHelper + { + /// + /// Open the path in the windows explorer. + /// If the path is a directory, it will just open the explorer with that directory. + /// If the path is a file, the explorer is opened with the directory and the file is selected. + /// + /// Path to file or directory + public static void OpenInExplorer(string path) + { + if (path == null) + { + return; + } + try + { + // Check if path is a directory + if (Directory.Exists(path)) + { + using (Process.Start(path)) + { + } + } + // Check if path is a file + else if (File.Exists(path)) + { + // Start the explorer process and select the file + using (var explorer = Process.Start("explorer.exe", $"/select,\"{path}\"")) + { + explorer?.WaitForInputIdle(500); + } + } + } + catch (Exception ex) + { + // Make sure we show what we tried to open in the exception + ex.Data.Add("path", path); + throw; + } + } + } +} From de2e92c7b6c633aed714a293595ee906ca09de59 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 12 Jan 2017 22:50:22 +0100 Subject: [PATCH 03/39] BUG-2097: Rollback of the change BUG-1965, we need to see what we do with this. For now the crop can be configured in the configuration: Win10BorderCrop Also forgot to update the GreenshotPlugin.csproj, as a file was added. --- GreenshotPlugin/Core/CoreConfiguration.cs | 3 +++ GreenshotPlugin/Core/WindowsHelper.cs | 4 ++-- GreenshotPlugin/GreenshotPlugin.csproj | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index c5e1a190f..c61cab2e3 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -263,6 +263,9 @@ namespace GreenshotPlugin.Core { [IniProperty("LastCapturedRegion", Description = "The last used region, for reuse in the capture last region")] public Rectangle LastCapturedRegion { get; set; } + [IniProperty("Win10BorderCrop", Description = "The capture is cropped with these settings, e.g. when you don't want to color around it -1,-1"), DefaultValue("0,0")] + public Size Win10BorderCrop { get; set; } + private Size _iconSize; [IniProperty("IconSize", Description = "Defines the size of the icons (e.g. for the buttons in the editor), default value 16,16 anything bigger will cause scaling", DefaultValue = "16,16")] public Size IconSize { diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs index 1a6db39a1..a33601115 100644 --- a/GreenshotPlugin/Core/WindowsHelper.cs +++ b/GreenshotPlugin/Core/WindowsHelper.cs @@ -770,7 +770,7 @@ namespace GreenshotPlugin.Core { { // Somehow DWM doesn't calculate it corectly, there is a 1 pixel border around the capture // Remove this border, currently it's fixed but TODO: Make it depend on the OS? - windowRect.Inflate(-1, -1); + windowRect.Inflate(Conf.Win10BorderCrop); _previousWindowRectangle = windowRect; _lastWindowRectangleRetrieveTime = now; return windowRect; @@ -1001,7 +1001,7 @@ namespace GreenshotPlugin.Core { // TODO: Also 8.x? if (Environment.OSVersion.IsWindows10()) { - captureRectangle.Inflate(-1, -1); + captureRectangle.Inflate(Conf.Win10BorderCrop); } if (autoMode) { diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj index 1c3ab8ce7..b70cffad7 100644 --- a/GreenshotPlugin/GreenshotPlugin.csproj +++ b/GreenshotPlugin/GreenshotPlugin.csproj @@ -43,6 +43,7 @@ Component + From 8fb430aaed3012e2bed2c169621e96f2767f19ca Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 12:16:25 +0100 Subject: [PATCH 04/39] BUG-2115: This could potentially solve the issue, but there might be a next one as a follow up. --- GreenshotJiraPlugin/Forms/JiraForm.cs | 18 ++++++++++++------ GreenshotJiraPlugin/JiraDestination.cs | 12 ++++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/GreenshotJiraPlugin/Forms/JiraForm.cs b/GreenshotJiraPlugin/Forms/JiraForm.cs index cfd5183e6..f4a47a347 100644 --- a/GreenshotJiraPlugin/Forms/JiraForm.cs +++ b/GreenshotJiraPlugin/Forms/JiraForm.cs @@ -36,7 +36,6 @@ namespace GreenshotJiraPlugin.Forms { private readonly JiraConnector _jiraConnector; private Issue _selectedIssue; private readonly GreenshotColumnSorter _columnSorter; - private static readonly JiraConfiguration JiraConfig = IniConfig.GetIniSection(); private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection(); public JiraForm(JiraConnector jiraConnector) { @@ -161,14 +160,21 @@ namespace GreenshotJiraPlugin.Forms { jiraListView.LargeImageList = imageList; foreach (var issue in issues) { - var issueIcon = await _jiraConnector.GetIssueTypeBitmapAsync(issue); - imageList.Images.Add(issueIcon); - var item = new ListViewItem { - Tag = issue, - ImageIndex = imageList.Images.Count - 1 + Tag = issue }; + try + { + var issueIcon = await _jiraConnector.GetIssueTypeBitmapAsync(issue); + imageList.Images.Add(issueIcon); + item.ImageIndex = imageList.Images.Count - 1; + } + catch (Exception ex) + { + Log.Warn("Problem loading issue type, ignoring", ex); + } + item.SubItems.Add(issue.Key); item.SubItems.Add(issue.Fields.Created.ToString("d", DateTimeFormatInfo.InvariantInfo)); item.SubItems.Add(issue.Fields.Assignee?.DisplayName); diff --git a/GreenshotJiraPlugin/JiraDestination.cs b/GreenshotJiraPlugin/JiraDestination.cs index 1b35e6fde..e6f60cd46 100644 --- a/GreenshotJiraPlugin/JiraDestination.cs +++ b/GreenshotJiraPlugin/JiraDestination.cs @@ -78,9 +78,17 @@ namespace GreenshotJiraPlugin { { if (_jiraIssue != null) { - displayIcon = jiraConnector.GetIssueTypeBitmapAsync(_jiraIssue).Result; + // Try to get the issue type as icon + try + { + displayIcon = jiraConnector.GetIssueTypeBitmapAsync(_jiraIssue).Result; + } + catch (Exception ex) + { + Log.Warn($"Problem loading issue type for {_jiraIssue.Key}, ignoring", ex); + } } - else + if (displayIcon == null) { displayIcon = jiraConnector.FavIcon; } From 8f2b9a24cfe1eb5b061e8654cc452495803accab Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 12:16:46 +0100 Subject: [PATCH 05/39] Changing to a new release branch --- appveyor12.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor12.yml b/appveyor12.yml index fd16f2741..0e7ad7491 100644 --- a/appveyor12.yml +++ b/appveyor12.yml @@ -1,7 +1,7 @@ version: 1.2.9.{build} branches: only: - - release/1.2.9 + - release/1.2.9BF2 skip_tags: true configuration: Release platform: Any CPU From 19802d54c85de12d9e42cdac5ae1d366b621fe42 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 16:24:23 +0100 Subject: [PATCH 06/39] BUG-2056: Make sure the external command doesn't use the default format if .greenshot is selected. --- .../ExternalCommandDestination.cs | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs index 654c2051a..a262bd86e 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs @@ -43,32 +43,26 @@ namespace ExternalCommand { _presetCommand = commando; } - public override string Designation { - get { - return "External " + _presetCommand.Replace(',','_'); - } - } + public override string Designation => "External " + _presetCommand.Replace(',','_'); - public override string Description { - get { - return _presetCommand; - } - } + public override string Description => _presetCommand; public override IEnumerable DynamicDestinations() { yield break; } - public override Image DisplayIcon { - get { - return IconCache.IconForCommand(_presetCommand); - } - } + public override Image DisplayIcon => IconCache.IconForCommand(_presetCommand); public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { ExportInformation exportInformation = new ExportInformation(Designation, Description); 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 (!config.RunInbackground.ContainsKey(_presetCommand)) { @@ -154,12 +148,12 @@ namespace ExternalCommand { private int CallExternalCommand(string commando, string fullPath, out string output, out string error) { try { return CallExternalCommand(commando, fullPath, null, out output, out error); - } catch (Win32Exception w32ex) { + } catch (Win32Exception w32Ex) { try { return CallExternalCommand(commando, fullPath, "runas", out output, out error); } catch { - w32ex.Data.Add("commandline", config.Commandline[_presetCommand]); - w32ex.Data.Add("arguments", config.Argument[_presetCommand]); + w32Ex.Data.Add("commandline", config.Commandline[_presetCommand]); + w32Ex.Data.Add("arguments", config.Argument[_presetCommand]); throw; } } catch (Exception ex) { From 73bdd0f405ac196672ca9174afa05d04ce6f0da1 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 19:15:17 +0100 Subject: [PATCH 07/39] BUG-2108: a change in ToForeground which should fix another issue, involved a key press, which "disables" the context menu in this use-case. --- Greenshot/Helpers/CaptureHelper.cs | 4 ++-- GreenshotPlugin/Core/WindowsHelper.cs | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index 9cfc3a665..3351db1d8 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -844,7 +844,7 @@ namespace Greenshot.Helpers { // Restore the window making sure it's visible! windowToCapture.Restore(); } else { - windowToCapture.ToForeground(); + windowToCapture.ToForeground(false); } tmpCapture = windowToCapture.CaptureGdiWindow(captureForWindow); if (tmpCapture != null) { @@ -946,7 +946,7 @@ namespace Greenshot.Helpers { _capture.CaptureDetails.DpiY = graphics.DpiY; } // Set previouslyActiveWindow as foreground window - previouslyActiveWindow?.ToForeground(); + previouslyActiveWindow?.ToForeground(false); if (_capture.CaptureDetails != null) { ((Bitmap) _capture.Image)?.SetResolution(_capture.CaptureDetails.DpiX, _capture.CaptureDetails.DpiY); } diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs index a33601115..90e6e6767 100644 --- a/GreenshotPlugin/Core/WindowsHelper.cs +++ b/GreenshotPlugin/Core/WindowsHelper.cs @@ -1250,11 +1250,13 @@ namespace GreenshotPlugin.Core { size = result ? new Size((int)windowInfo.cxWindowBorders, (int)windowInfo.cyWindowBorders) : Size.Empty; return result; } - + /// /// Set the window as foreground window /// - public static void ToForeground(IntPtr handle) + /// hWnd of the window to bring to the foreground + /// bool with true to use a trick to really bring the window to the foreground + public static void ToForeground(IntPtr handle, bool workaround = true) { // Do nothing if the window is already in the foreground if (User32.GetForegroundWindow() == handle) @@ -1266,10 +1268,14 @@ namespace GreenshotPlugin.Core { const int EXTENDEDKEY = 0x1; const int KEYUP = 0x2; - // Simulate an "ALT" key press. - User32.keybd_event(ALT, 0x45, EXTENDEDKEY | 0, 0); - // Simulate an "ALT" key release. - User32.keybd_event(ALT, 0x45, EXTENDEDKEY | KEYUP, 0); + // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms633539(v=vs.85).aspx + if (workaround) + { + // Simulate an "ALT" key press. + User32.keybd_event(ALT, 0x45, EXTENDEDKEY | 0, 0); + // Simulate an "ALT" key release. + User32.keybd_event(ALT, 0x45, EXTENDEDKEY | KEYUP, 0); + } // Show window in forground. User32.SetForegroundWindow(handle); @@ -1278,8 +1284,9 @@ namespace GreenshotPlugin.Core { /// /// Set the window as foreground window /// - public void ToForeground() { - ToForeground(Handle); + /// true to use a workaround, otherwise the window might only flash + public void ToForeground(bool workaround = true) { + ToForeground(Handle, workaround); } /// From 0b2cbe1c0b2e3aeec4765bd6e884aedad3ed46f3 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 19:46:54 +0100 Subject: [PATCH 08/39] BUG-2114 & BUG-1992: Hopefully implemented this more stable as it used to be. --- Greenshot/Destinations/FileDestination.cs | 5 ++++ Greenshot/Forms/MainForm.cs | 29 ++++++++++++++++++- .../Controls/SaveImageFileDialog.cs | 12 ++++++-- GreenshotPlugin/Core/CoreConfiguration.cs | 13 +-------- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Greenshot/Destinations/FileDestination.cs b/Greenshot/Destinations/FileDestination.cs index d3f1a2cb4..0c52af596 100644 --- a/Greenshot/Destinations/FileDestination.cs +++ b/Greenshot/Destinations/FileDestination.cs @@ -115,6 +115,11 @@ namespace Greenshot.Destinations { pattern = "greenshot ${capturetime}"; } string filename = FilenameHelper.GetFilenameFromPattern(pattern, CoreConfig.OutputFileFormat, captureDetails); + // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + if (!File.Exists(CoreConfig.OutputFilePath)) + { + CoreConfig.OutputFilePath = CoreConfig.GetDefault(nameof(CoreConfig.OutputFilePath)) as string; + } string filepath = FilenameHelper.FillVariables(CoreConfig.OutputFilePath, false); try { fullPath = Path.Combine(filepath, filename); diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index da36ae559..9509d3458 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -1307,6 +1307,11 @@ namespace Greenshot { private void NotifyIconClick(ClickActions clickAction) { switch (clickAction) { case ClickActions.OPEN_LAST_IN_EXPLORER: + // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + if (!File.Exists(_conf.OutputFileAsFullpath)) + { + _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; + } string path = _conf.OutputFileAsFullpath; if (!File.Exists(path)) { string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); @@ -1315,15 +1320,25 @@ namespace Greenshot { } } if (path == null) { + // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + if (!File.Exists(_conf.OutputFilePath)) + { + _conf.OutputFilePath = _conf.GetDefault(nameof(_conf.OutputFilePath)) as string; + } string configPath = FilenameHelper.FillVariables(_conf.OutputFilePath, false); if (Directory.Exists(configPath)) { path = configPath; } } - ExplorerHelper.OpenInExplorer(path); break; case ClickActions.OPEN_LAST_IN_EDITOR: + // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + if (!File.Exists(_conf.OutputFileAsFullpath)) + { + _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; + } + if (File.Exists(_conf.OutputFileAsFullpath)) { CaptureHelper.CaptureFile(_conf.OutputFileAsFullpath, DestinationHelper.GetDestination(EditorDestination.DESIGNATION)); } @@ -1342,9 +1357,21 @@ namespace Greenshot { /// The Contextmenu_OpenRecent currently opens the last know save location /// private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs) { + // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + if (!File.Exists(_conf.OutputFilePath)) + { + _conf.OutputFilePath = _conf.GetDefault(nameof(_conf.OutputFilePath)) as string; + } + string path = FilenameHelper.FillVariables(_conf.OutputFilePath, false); // Fix for #1470, problems with a drive which is no longer available try { + // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + if (!File.Exists(_conf.OutputFileAsFullpath)) + { + _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; + } + string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); if (lastFilePath != null && Directory.Exists(lastFilePath)) { diff --git a/GreenshotPlugin/Controls/SaveImageFileDialog.cs b/GreenshotPlugin/Controls/SaveImageFileDialog.cs index 10621c323..e79450958 100644 --- a/GreenshotPlugin/Controls/SaveImageFileDialog.cs +++ b/GreenshotPlugin/Controls/SaveImageFileDialog.cs @@ -68,6 +68,12 @@ namespace GreenshotPlugin.Controls { ApplyFilterOptions(); string initialDirectory = null; try { + // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + if (!File.Exists(conf.OutputFileAsFullpath)) + { + conf.OutputFileAsFullpath = conf.GetDefault(nameof(conf.OutputFileAsFullpath)) as string; + } + initialDirectory = Path.GetDirectoryName(conf.OutputFileAsFullpath); } catch { LOG.WarnFormat("OutputFileAsFullpath was set to {0}, ignoring due to problem in path.", conf.OutputFileAsFullpath); @@ -90,12 +96,12 @@ namespace GreenshotPlugin.Controls { PrepareFilterOptions(); string fdf = ""; int preselect = 0; - var outputFileFormatAsString = Enum.GetName(typeof(OutputFormat), conf.OutputFileFormat); + var outputFileFormatAsString = Enum.GetName(typeof(OutputFormat), conf.OutputFileFormat); for(int i=0; i<_filterOptions.Length; i++){ FilterOption fo = _filterOptions[i]; fdf += fo.Label + "|*." + fo.Extension + "|"; - if(outputFileFormatAsString == fo.Extension) - preselect = i; + if(outputFileFormatAsString == fo.Extension) + preselect = i; } fdf = fdf.Substring(0, fdf.Length-1); SaveFileDialog.Filter = fdf; diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index c61cab2e3..a08392109 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -342,9 +342,8 @@ namespace GreenshotPlugin.Core { case "OutputFileAsFullpath": if (IniConfig.IsPortable) { return Path.Combine(Application.StartupPath, @"..\..\Documents\Pictures\Greenshots\dummy.png"); - } else { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"dummy.png"); } + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"dummy.png"); case "OutputFilePath": if (IniConfig.IsPortable) { string pafOutputFilePath = Path.Combine(Application.StartupPath, @"..\..\Documents\Pictures\Greenshots"); @@ -515,16 +514,6 @@ namespace GreenshotPlugin.Core { if (WebRequestReadWriteTimeout < 1) { WebRequestReadWriteTimeout = 100; } - - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!Directory.Exists(OutputFilePath)) - { - OutputFilePath = GetDefault(nameof(OutputFilePath)) as string; - } - if (!File.Exists(OutputFileAsFullpath)) - { - OutputFileAsFullpath = GetDefault(nameof(OutputFileAsFullpath)) as string; - } } } } \ No newline at end of file From 5d50cd8b96c04a43fd37e532fd5243c1adf2d5a5 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 20:17:15 +0100 Subject: [PATCH 09/39] BUG-2109: Fix for NPE --- Greenshot/Drawing/TextContainer.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Greenshot/Drawing/TextContainer.cs b/Greenshot/Drawing/TextContainer.cs index 2761bfe9c..0c72b464b 100644 --- a/Greenshot/Drawing/TextContainer.cs +++ b/Greenshot/Drawing/TextContainer.cs @@ -272,8 +272,11 @@ namespace Greenshot.Drawing _parent.Controls.Add(_textBox); } EnsureTextBoxContrast(); - _textBox.Show(); - _textBox.Focus(); + if (_textBox != null) + { + _textBox.Show(); + _textBox.Focus(); + } } /// @@ -281,6 +284,10 @@ namespace Greenshot.Drawing /// private void EnsureTextBoxContrast() { + if (_textBox == null) + { + return; + } Color lc = GetFieldValueAsColor(FieldType.LINE_COLOR); if (lc.R > 203 && lc.G > 203 && lc.B > 203) { @@ -295,7 +302,7 @@ namespace Greenshot.Drawing private void HideTextBox() { _parent.Focus(); - _textBox.Hide(); + _textBox?.Hide(); _parent.KeysLocked = false; _parent.Controls.Remove(_textBox); } @@ -424,6 +431,10 @@ namespace Greenshot.Drawing /// private void UpdateTextBoxPosition() { + if (_textBox == null) + { + return; + } int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS); int lineWidth = (int)Math.Floor(lineThickness / 2d); From a5cabb2ced922d993fe5116555ff03387beedac2 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 20:54:16 +0100 Subject: [PATCH 10/39] BUG-2093: Fixed check if the Windows GDI blur can be used. --- GreenshotPlugin/UnmanagedHelpers/GDIplus.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs b/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs index f8671f335..05b202105 100644 --- a/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs +++ b/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs @@ -171,11 +171,16 @@ namespace GreenshotPlugin.UnmanagedHelpers { /// /// /// false if blur is not possible - public static bool IsBlurPossible(int radius) { + public static bool IsBlurPossible(int radius) + { if (!_isBlurEnabled) { return false; } - return Environment.OSVersion.Version.Minor < 2 || radius >= 20; + if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor < 2) + { + return true; + } + return Environment.OSVersion.Version.Major > 6 && radius >= 20; } /// From 952e52180568f990ba317c1bb3a2d3e64cd2b48f Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 21:44:20 +0100 Subject: [PATCH 11/39] BUG-2104: Fixed an initialization issue, and a problem with drawing. This should make the Speechbubble more stable! --- Greenshot/Drawing/SpeechbubbleContainer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Greenshot/Drawing/SpeechbubbleContainer.cs b/Greenshot/Drawing/SpeechbubbleContainer.cs index f90643ae9..0cdfb91c1 100644 --- a/Greenshot/Drawing/SpeechbubbleContainer.cs +++ b/Greenshot/Drawing/SpeechbubbleContainer.cs @@ -56,9 +56,10 @@ namespace Greenshot.Drawing /// /// Restore the target gripper /// - /// - protected override void OnDeserialized(StreamingContext context) + /// StreamingContext + protected override void OnDeserialized(StreamingContext streamingContext) { + base.OnDeserialized(streamingContext); InitAdorner(Color.Green, _storedTargetGripperLocation); } #endregion @@ -303,7 +304,6 @@ namespace Greenshot.Drawing tail.Dispose(); // Draw the text - UpdateFormat(); DrawText(graphics, rect, lineThickness, lineColor, shadow, StringFormat, Text, Font); } From b01eae37944f7dbaf75f9b29db4f1fa2beecf3c0 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 22:09:03 +0100 Subject: [PATCH 12/39] BUG-2081: Fixed that only the + and - of the numpad worked for the canvas resizing. --- Greenshot/Forms/ImageEditorForm.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index 24ef53bc7..c5de9937e 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -860,13 +860,15 @@ namespace Greenshot { case Keys.Oemcomma: // Rotate CCW Ctrl + , RotateCcwToolstripButtonClick(sender, e); break; - case Keys.OemPeriod: // Rotate CW Ctrl + . + case Keys.OemPeriod: // Rotate CW Ctrl + . RotateCwToolstripButtonClick(sender, e); break; case Keys.Add: // Ctrl + + + case Keys.Oemplus: // Ctrl + + EnlargeCanvasToolStripMenuItemClick(sender, e); break; case Keys.Subtract: // Ctrl + - + case Keys.OemMinus: // Ctrl + - ShrinkCanvasToolStripMenuItemClick(sender, e); break; } From c4139f4fe22080a222443b77856ee4e08af8f4f0 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 22:25:40 +0100 Subject: [PATCH 13/39] BUG-2111: The where clause selecting the possible images didn't work correctly. --- GreenshotPlugin/Core/ClipboardHelper.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GreenshotPlugin/Core/ClipboardHelper.cs b/GreenshotPlugin/Core/ClipboardHelper.cs index a2462708d..e46821b22 100644 --- a/GreenshotPlugin/Core/ClipboardHelper.cs +++ b/GreenshotPlugin/Core/ClipboardHelper.cs @@ -813,10 +813,10 @@ EndSelection:<<<<<<<4 string[] dropFileNames = (string[]) dataObject.GetData(DataFormats.FileDrop); if (dropFileNames != null && dropFileNames.Length > 0) { - return dropFileNames.Where(filename => !string.IsNullOrEmpty(filename)) + return dropFileNames + .Where(filename => !string.IsNullOrEmpty(filename)) .Where(Path.HasExtension) - .Select(filename => Path.GetExtension(filename).ToLowerInvariant()) - .Where(ext => ImageHelper.StreamConverters.Keys.Contains(ext)); + .Where(filename => ImageHelper.StreamConverters.Keys.Contains(Path.GetExtension(filename).ToLowerInvariant().Substring(1))); } return Enumerable.Empty(); } From 25d9c17bed924e20ea51403459fdd9a246c7bbc8 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 13 Jan 2017 23:03:50 +0100 Subject: [PATCH 14/39] Updated readme.txt with the list of tickets that are in the Spring for BF2 --- .../additional_files/readme.txt.template | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Greenshot/releases/additional_files/readme.txt.template b/Greenshot/releases/additional_files/readme.txt.template index 4c85447db..984044afb 100644 --- a/Greenshot/releases/additional_files/readme.txt.template +++ b/Greenshot/releases/additional_files/readme.txt.template @@ -9,6 +9,36 @@ All details to our tickets can be found here: https://greenshot.atlassian.net @DETAILVERSION@ +This is Greenshot 1.2.9BF2, the second bugfix release for Greenshot 1.2.9 + +The following tickets are on the list for the bugfix release, the current state is not represented in UNSTABLE builds: +* BUG-2051 Scroll-lock button not usable as hotkey +* BUG-2055 Cannot paste Greenshot capture to Skype +* BUG-2056 Cannot export to external command Paint.NET if .greenshot format is used +* BUG-2068 Export to Confluence caused System.NullReferenceException +* BUG-2081 Canvas resize (Ctrl + / Ctrl -) only works via numpad keys +* BUG-2093 Shadow effects not renderingWindows 10 window border frame is not capture correctly on Windows 10 +* BUG-2095 'Save as' doesn't remember last saved directory (after restart) +* BUG-2097 Window border is not captured on Windows 10 +* BUG-2098 Greenshot opens Explorer when clicking tray while notification is still showing +* BUG-2100 ArgumentException when changing the icon size from 16 to 32 +* BUG-2101 Update to version 1.2.9.112 release -> Error 5 Access is denied +* BUG-2102 InvalidOperationException when selecting a color +* BUG-2103 ArgumentException when changing the icon size from 16 to 32 +* BUG-2104 Speechbubble can't be used after copy/paste +* BUG-2105 Window border is not captured on Windows 10 +* BUG-2108 Capture last region doesn't work +* BUG-2109 Double-click on textbox causes NullReferenceException +* BUG-2110 Missing annotations when opening .greenshot files +* BUG-2111 Drag and Drop image file on editor doesn't work +* BUG-2114 Storage location reset to default if not available during start +* BUG-2115 Error while trying to upload screenshot to Jira +* FEATURE-998 The feature "Opening last capture in explorer should select/jump to the file" wasn't available everywhere + + +1.2.9.112-9bc62ac RELEASE + + This is a bugfix release for the Greenshot 1.2.9.104-3721c10 RELEASE Bugs fixed: From c77e77578d15ca0f17becee2e8a4d465fc2d43f4 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 14 Jan 2017 20:18:04 +0100 Subject: [PATCH 15/39] BUG-2095: Improved the validity check of the OutputFileAsFullpath setting, this should prevent a reset if only the file is not available. --- Greenshot/Forms/MainForm.cs | 6 ++++-- GreenshotPlugin/Controls/SaveImageFileDialog.cs | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 9509d3458..8de6e7edb 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -1308,7 +1308,8 @@ namespace Greenshot { switch (clickAction) { case ClickActions.OPEN_LAST_IN_EXPLORER: // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!File.Exists(_conf.OutputFileAsFullpath)) + var outputFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); + if (outputFilePath == null || (!File.Exists(_conf.OutputFileAsFullpath) && !Directory.Exists(Path.GetDirectoryName(outputFilePath)))) { _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; } @@ -1367,7 +1368,8 @@ namespace Greenshot { // Fix for #1470, problems with a drive which is no longer available try { // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!File.Exists(_conf.OutputFileAsFullpath)) + var outputFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); + if (outputFilePath == null || (!File.Exists(_conf.OutputFileAsFullpath) && !Directory.Exists(Path.GetDirectoryName(outputFilePath)))) { _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; } diff --git a/GreenshotPlugin/Controls/SaveImageFileDialog.cs b/GreenshotPlugin/Controls/SaveImageFileDialog.cs index e79450958..7750a1dce 100644 --- a/GreenshotPlugin/Controls/SaveImageFileDialog.cs +++ b/GreenshotPlugin/Controls/SaveImageFileDialog.cs @@ -69,7 +69,8 @@ namespace GreenshotPlugin.Controls { string initialDirectory = null; try { // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!File.Exists(conf.OutputFileAsFullpath)) + var outputFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath); + if (outputFilePath == null || (!File.Exists(conf.OutputFileAsFullpath) && !Directory.Exists(outputFilePath))) { conf.OutputFileAsFullpath = conf.GetDefault(nameof(conf.OutputFileAsFullpath)) as string; } From 89ae9489d23d42d7b4ed85081150081fee5e216b Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 16 Jan 2017 17:06:50 +0100 Subject: [PATCH 16/39] BUG-2056: A better fix for the issue, there was already something build in. [skip ci] --- .../ExternalCommandDestination.cs | 8 +------- GreenshotPlugin/Core/ImageOutput.cs | 2 +- GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs | 11 +++++++++-- GreenshotWin10Plugin/Win10ShareDestination.cs | 9 ++++++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs index a262bd86e..93c0e8096 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs @@ -56,14 +56,8 @@ namespace ExternalCommand { public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { ExportInformation exportInformation = new ExportInformation(Designation, Description); SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(); + outputSettings.PreventGreenshotFormat(); - // 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 (!config.RunInbackground.ContainsKey(_presetCommand)) { config.RunInbackground.Add(_presetCommand, true); diff --git a/GreenshotPlugin/Core/ImageOutput.cs b/GreenshotPlugin/Core/ImageOutput.cs index 7a2e40f37..cbd4cec9b 100644 --- a/GreenshotPlugin/Core/ImageOutput.cs +++ b/GreenshotPlugin/Core/ImageOutput.cs @@ -105,7 +105,7 @@ namespace GreenshotPlugin.Core { bool useMemoryStream = false; MemoryStream memoryStream = null; if (outputSettings.Format == OutputFormat.greenshot && surface == null) { - throw new ArgumentException("Surface needs to be se when using OutputFormat.Greenshot"); + throw new ArgumentException("Surface needs to be set when using OutputFormat.Greenshot"); } try { diff --git a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs index 63ad027cb..4eb8c918d 100644 --- a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs +++ b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs @@ -98,8 +98,15 @@ namespace Greenshot.Plugin { ReduceColors = reduceColors; } - public SurfaceOutputSettings PreventGreenshotFormat() { - if (Format == OutputFormat.greenshot) { + /// + /// BUG-2056 reported a logical issue, using greenshot format as the default causes issues with the external commands. + /// + /// this for fluent API usage + public SurfaceOutputSettings PreventGreenshotFormat() + { + // If OutputFormat is Greenshot, use PNG instead. + if (Format == OutputFormat.greenshot) + { Format = OutputFormat.png; } return this; diff --git a/GreenshotWin10Plugin/Win10ShareDestination.cs b/GreenshotWin10Plugin/Win10ShareDestination.cs index 780f568cd..8933b9b7a 100644 --- a/GreenshotWin10Plugin/Win10ShareDestination.cs +++ b/GreenshotWin10Plugin/Win10ShareDestination.cs @@ -70,8 +70,11 @@ namespace GreenshotWin10Plugin using (var logoStream = new MemoryRandomAccessStream()) using (var thumbnailStream = new MemoryRandomAccessStream()) { + var outputSettings = new SurfaceOutputSettings(); + outputSettings.PreventGreenshotFormat(); + // Create capture for export - ImageOutput.SaveToStream(surface, imageStream, new SurfaceOutputSettings()); + ImageOutput.SaveToStream(surface, imageStream, outputSettings); imageStream.Position = 0; Log.Info("Created RandomAccessStreamReference for the image"); var imageRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(imageStream); @@ -83,7 +86,7 @@ namespace GreenshotWin10Plugin { using (var thumbnail = ImageHelper.CreateThumbnail(tmpImageForThumbnail, 240, 160)) { - ImageOutput.SaveToStream(thumbnail, null, thumbnailStream, new SurfaceOutputSettings()); + ImageOutput.SaveToStream(thumbnail, null, thumbnailStream, outputSettings); thumbnailStream.Position = 0; thumbnailRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(thumbnailStream); Log.Info("Created RandomAccessStreamReference for the thumbnail"); @@ -94,7 +97,7 @@ namespace GreenshotWin10Plugin { using (var logoThumbnail = ImageHelper.CreateThumbnail(logo, 30, 30)) { - ImageOutput.SaveToStream(logoThumbnail, null, logoStream, new SurfaceOutputSettings()); + ImageOutput.SaveToStream(logoThumbnail, null, logoStream, outputSettings); logoStream.Position = 0; logoRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(logoStream); Log.Info("Created RandomAccessStreamReference for the logo"); From e5b2b7a5c3ce123bdfd517cd9ff6b61a604a8960 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 18 Jan 2017 10:50:11 +0100 Subject: [PATCH 17/39] BUG-2051: Made changes to allow Scroll-Lock and Pause to be used as a hotkey. [skip ci] --- GreenshotPlugin/Controls/HotkeyControl.cs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/GreenshotPlugin/Controls/HotkeyControl.cs b/GreenshotPlugin/Controls/HotkeyControl.cs index af12f6d93..590f6090a 100644 --- a/GreenshotPlugin/Controls/HotkeyControl.cs +++ b/GreenshotPlugin/Controls/HotkeyControl.cs @@ -20,7 +20,6 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -48,15 +47,6 @@ namespace GreenshotPlugin.Controls { private static int _hotKeyCounter = 1; private const uint WM_HOTKEY = 0x312; private static IntPtr _hotkeyHwnd; - -// static HotkeyControl() { -// StringBuilder keyName = new StringBuilder(); -// for(uint sc = 0; sc < 500; sc++) { -// if (GetKeyNameText(sc << 16, keyName, 100) != 0) { -// LOG.DebugFormat("SC {0} = {1}", sc, keyName); -// } -// } -// } [SuppressMessage("ReSharper", "InconsistentNaming")] public enum Modifiers : uint { @@ -96,8 +86,8 @@ namespace GreenshotPlugin.Controls { // ArrayLists used to enforce the use of proper modifiers. // Shift+A isn't a valid hotkey, for instance, as it would screw up when the user is typing. - private readonly ArrayList _needNonShiftModifier; - private readonly ArrayList _needNonAltGrModifier; + private readonly IList _needNonShiftModifier = new List(); + private readonly IList _needNonAltGrModifier = new List(); private readonly ContextMenu _dummy = new ContextMenu(); @@ -138,9 +128,6 @@ namespace GreenshotPlugin.Controls { KeyUp += HotkeyControl_KeyUp; KeyDown += HotkeyControl_KeyDown; - // Fill the ArrayLists that contain all invalid hotkey combinations - _needNonShiftModifier = new ArrayList(); - _needNonAltGrModifier = new ArrayList(); PopulateModifierLists(); } @@ -180,8 +167,6 @@ namespace GreenshotPlugin.Controls { _needNonShiftModifier.Add((int)Keys.Return); _needNonShiftModifier.Add((int)Keys.Escape); _needNonShiftModifier.Add((int)Keys.NumLock); - _needNonShiftModifier.Add((int)Keys.Scroll); - _needNonShiftModifier.Add((int)Keys.Pause); // Ctrl+Alt + 0 - 9 for (Keys k = Keys.D0; k <= Keys.D9; k++) { From 9d849d1b589a161ef9e8bd4f9b9f76918bd16bf5 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 18 Jan 2017 12:00:24 +0100 Subject: [PATCH 18/39] BUG-2116: for loop over collection which is modified caused a problem. --- Greenshot/Drawing/Fields/FieldAggregator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Greenshot/Drawing/Fields/FieldAggregator.cs b/Greenshot/Drawing/Fields/FieldAggregator.cs index cbf5377d7..3eb2f8bac 100644 --- a/Greenshot/Drawing/Fields/FieldAggregator.cs +++ b/Greenshot/Drawing/Fields/FieldAggregator.cs @@ -27,6 +27,7 @@ using Greenshot.Plugin.Drawing; using GreenshotPlugin.Interfaces.Drawing; using System.Collections.Generic; using System.ComponentModel; +using System.Linq; namespace Greenshot.Drawing.Fields { @@ -203,7 +204,7 @@ namespace Greenshot.Drawing.Fields { return; } - foreach (var drawableContainer1 in _boundContainers) + foreach (var drawableContainer1 in _boundContainers.ToList()) { var drawableContainer = (DrawableContainer) drawableContainer1; if (!drawableContainer.HasField(field.FieldType)) From 9e9d058fdcb50792cb84c065c0a7f532242c89a8 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 18 Jan 2017 19:45:27 +0100 Subject: [PATCH 19/39] BUG-2114: Fixed totaly f***ed up fix, this should be better. --- Greenshot/Destinations/FileDestination.cs | 6 +---- .../Controls/SaveImageFileDialog.cs | 8 +------ GreenshotPlugin/Core/CoreConfiguration.cs | 24 +++++++++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Greenshot/Destinations/FileDestination.cs b/Greenshot/Destinations/FileDestination.cs index 0c52af596..daada3f41 100644 --- a/Greenshot/Destinations/FileDestination.cs +++ b/Greenshot/Destinations/FileDestination.cs @@ -115,11 +115,7 @@ namespace Greenshot.Destinations { pattern = "greenshot ${capturetime}"; } string filename = FilenameHelper.GetFilenameFromPattern(pattern, CoreConfig.OutputFileFormat, captureDetails); - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!File.Exists(CoreConfig.OutputFilePath)) - { - CoreConfig.OutputFilePath = CoreConfig.GetDefault(nameof(CoreConfig.OutputFilePath)) as string; - } + CoreConfig.ValidateAndCorrectOutputFilePath(); string filepath = FilenameHelper.FillVariables(CoreConfig.OutputFilePath, false); try { fullPath = Path.Combine(filepath, filename); diff --git a/GreenshotPlugin/Controls/SaveImageFileDialog.cs b/GreenshotPlugin/Controls/SaveImageFileDialog.cs index 7750a1dce..c077b4093 100644 --- a/GreenshotPlugin/Controls/SaveImageFileDialog.cs +++ b/GreenshotPlugin/Controls/SaveImageFileDialog.cs @@ -68,13 +68,7 @@ namespace GreenshotPlugin.Controls { ApplyFilterOptions(); string initialDirectory = null; try { - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - var outputFilePath = Path.GetDirectoryName(conf.OutputFileAsFullpath); - if (outputFilePath == null || (!File.Exists(conf.OutputFileAsFullpath) && !Directory.Exists(outputFilePath))) - { - conf.OutputFileAsFullpath = conf.GetDefault(nameof(conf.OutputFileAsFullpath)) as string; - } - + conf.ValidateAndCorrectOutputFileAsFullpath(); initialDirectory = Path.GetDirectoryName(conf.OutputFileAsFullpath); } catch { LOG.WarnFormat("OutputFileAsFullpath was set to {0}, ignoring due to problem in path.", conf.OutputFileAsFullpath); diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index a08392109..4d60bb5aa 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -515,5 +515,29 @@ namespace GreenshotPlugin.Core { WebRequestReadWriteTimeout = 100; } } + + /// + /// Validate the OutputFilePath, and if this is not correct it will be set to the default + /// Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + /// + public void ValidateAndCorrectOutputFilePath() + { + if (!Directory.Exists(OutputFilePath)) + { + OutputFilePath = GetDefault(nameof(OutputFilePath)) as string; + } + } + /// + /// Validate the OutputFileAsFullpath, and if this is not correct it will be set to the default + /// Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) + /// + public void ValidateAndCorrectOutputFileAsFullpath() + { + var outputFilePath = Path.GetDirectoryName(OutputFileAsFullpath); + if (outputFilePath == null || (!File.Exists(OutputFileAsFullpath) && !Directory.Exists(outputFilePath))) + { + OutputFileAsFullpath = GetDefault(nameof(OutputFileAsFullpath)) as string; + } + } } } \ No newline at end of file From 69deb19b1f35c5127a86f90777080f8632f1796b Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 20 Jan 2017 11:13:19 +0100 Subject: [PATCH 20/39] Modifications for the JIRA code needed to upgrade the package. [skip ci] --- .../GreenshotJiraPlugin.csproj | 8 ++-- GreenshotJiraPlugin/JiraConnector.cs | 45 ++++++++++--------- GreenshotJiraPlugin/JiraMonitor.cs | 5 +-- GreenshotJiraPlugin/packages.config | 4 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index 7defad044..b5a3d87f5 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -34,12 +34,12 @@ - - ..\packages\Dapplo.HttpExtensions.0.6.8\lib\net45\Dapplo.HttpExtensions.dll + + ..\packages\Dapplo.HttpExtensions.0.6.10\lib\net45\Dapplo.HttpExtensions.dll True - - ..\packages\Dapplo.Jira.0.3.1\lib\net45\Dapplo.Jira.dll + + ..\packages\Dapplo.Jira.0.3.4\lib\net45\Dapplo.Jira.dll True diff --git a/GreenshotJiraPlugin/JiraConnector.cs b/GreenshotJiraPlugin/JiraConnector.cs index 0aec2884d..1351ce2d3 100644 --- a/GreenshotJiraPlugin/JiraConnector.cs +++ b/GreenshotJiraPlugin/JiraConnector.cs @@ -97,7 +97,7 @@ namespace GreenshotJiraPlugin { /// Internal login which catches the exceptions /// /// true if login was done sucessfully - private async Task DoLoginAsync(string user, string password) + private async Task DoLoginAsync(string user, string password, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password)) { @@ -110,14 +110,14 @@ namespace GreenshotJiraPlugin { LoginInfo loginInfo; try { - loginInfo = await _jiraApi.StartSessionAsync(user, password); + loginInfo = await _jiraApi.Session.StartAsync(user, password, cancellationToken); Monitor = new JiraMonitor(); - await Monitor.AddJiraInstanceAsync(_jiraApi); + await Monitor.AddJiraInstanceAsync(_jiraApi, cancellationToken); var favIconUri = _jiraApi.JiraBaseUri.AppendSegments("favicon.ico"); try { - FavIcon = await _jiraApi.GetUriContentAsync(favIconUri); + FavIcon = await _jiraApi.GetUriContentAsync(favIconUri, cancellationToken); } catch (Exception ex) { @@ -137,8 +137,8 @@ namespace GreenshotJiraPlugin { /// If there are credentials, call the real login. /// /// Task - public async Task LoginAsync() { - await LogoutAsync(); + public async Task LoginAsync(CancellationToken cancellationToken = default(CancellationToken)) { + await LogoutAsync(cancellationToken); try { // Get the system name, so the user knows where to login to var credentialsDialog = new CredentialsDialog(JiraConfig.Url) @@ -146,7 +146,7 @@ namespace GreenshotJiraPlugin { Name = null }; while (credentialsDialog.Show(credentialsDialog.Name) == DialogResult.OK) { - if (await DoLoginAsync(credentialsDialog.Name, credentialsDialog.Password)) { + if (await DoLoginAsync(credentialsDialog.Name, credentialsDialog.Password, cancellationToken)) { if (credentialsDialog.SaveChecked) { credentialsDialog.Confirm(true); } @@ -176,11 +176,11 @@ namespace GreenshotJiraPlugin { /// /// End the session, if there was one /// - public async Task LogoutAsync() { + public async Task LogoutAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (_jiraApi != null && _loggedIn) { Monitor.Dispose(); - await _jiraApi.EndSessionAsync(); + await _jiraApi.Session.EndAsync(cancellationToken); _loggedIn = false; } } @@ -190,14 +190,14 @@ namespace GreenshotJiraPlugin { /// Do not use ConfigureAwait to call this, as it will move await from the UI thread. /// /// - private async Task CheckCredentialsAsync() { + private async Task CheckCredentialsAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (_loggedIn) { if (_loggedInTime.AddMinutes(_timeout-1).CompareTo(DateTime.Now) < 0) { - await LogoutAsync(); - await LoginAsync(); + await LogoutAsync(cancellationToken); + await LoginAsync(cancellationToken); } } else { - await LoginAsync(); + await LoginAsync(cancellationToken); } } @@ -205,23 +205,24 @@ namespace GreenshotJiraPlugin { /// Get the favourite filters /// /// List with filters - public async Task> GetFavoriteFiltersAsync() + public async Task> GetFavoriteFiltersAsync(CancellationToken cancellationToken = default(CancellationToken)) { - await CheckCredentialsAsync(); - return await _jiraApi.GetFavoriteFiltersAsync().ConfigureAwait(false); + await CheckCredentialsAsync(cancellationToken); + return await _jiraApi.Filter.GetFavoritesAsync(cancellationToken).ConfigureAwait(false); } /// /// Get the issue for a key /// /// Jira issue key + /// CancellationToken /// Issue - public async Task GetIssueAsync(string issueKey) + public async Task GetIssueAsync(string issueKey, CancellationToken cancellationToken = default(CancellationToken)) { - await CheckCredentialsAsync(); + await CheckCredentialsAsync(cancellationToken); try { - return await _jiraApi.Issue.GetAsync(issueKey).ConfigureAwait(false); + return await _jiraApi.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false); } catch { @@ -238,7 +239,7 @@ namespace GreenshotJiraPlugin { /// public async Task AttachAsync(string issueKey, IBinaryContainer content, CancellationToken cancellationToken = default(CancellationToken)) { - await CheckCredentialsAsync(); + await CheckCredentialsAsync(cancellationToken); using (var memoryStream = new MemoryStream()) { content.WriteToStream(memoryStream); @@ -256,7 +257,7 @@ namespace GreenshotJiraPlugin { /// CancellationToken public async Task AddCommentAsync(string issueKey, string body, string visibility = null, CancellationToken cancellationToken = default(CancellationToken)) { - await CheckCredentialsAsync(); + await CheckCredentialsAsync(cancellationToken); await _jiraApi.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false); } @@ -268,7 +269,7 @@ namespace GreenshotJiraPlugin { /// public async Task> SearchAsync(Filter filter, CancellationToken cancellationToken = default(CancellationToken)) { - await CheckCredentialsAsync(); + await CheckCredentialsAsync(cancellationToken); var searchResult = await _jiraApi.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false); return searchResult.Issues; } diff --git a/GreenshotJiraPlugin/JiraMonitor.cs b/GreenshotJiraPlugin/JiraMonitor.cs index 7bea19b11..d38cdee5c 100644 --- a/GreenshotJiraPlugin/JiraMonitor.cs +++ b/GreenshotJiraPlugin/JiraMonitor.cs @@ -120,7 +120,7 @@ namespace GreenshotJiraPlugin public async Task AddJiraInstanceAsync(JiraApi jiraInstance, CancellationToken token = default(CancellationToken)) { _jiraInstances.Add(jiraInstance); - var projects = await jiraInstance.GetProjectsAsync(token).ConfigureAwait(false); + var projects = await jiraInstance.Project.GetAllAsync(cancellationToken: token).ConfigureAwait(false); if (projects != null) { foreach (var project in projects) @@ -208,8 +208,7 @@ namespace GreenshotJiraPlugin if (_recentJiras.Count > _maxEntries) { // Add it to the list of recent Jiras - IList clonedList = new List(_recentJiras.Values); - _recentJiras = (from jiraDetails in clonedList + _recentJiras = (from jiraDetails in _recentJiras.Values.ToList() orderby jiraDetails.SeenAt descending select jiraDetails).Take(_maxEntries).ToDictionary(jd => jd.JiraKey, jd => jd); } diff --git a/GreenshotJiraPlugin/packages.config b/GreenshotJiraPlugin/packages.config index 38a68ba7c..d3e269a7c 100644 --- a/GreenshotJiraPlugin/packages.config +++ b/GreenshotJiraPlugin/packages.config @@ -1,7 +1,7 @@  - - + + From 5bdfcd5306c03e598eeb558cec1351374ae371f8 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 20 Jan 2017 12:13:37 +0100 Subject: [PATCH 21/39] BUG-2114 / FEATURE-998 consolidated the logic to make the behavior equal for all entry points. --- Greenshot/Forms/MainForm.cs | 86 +++++++++----------------- GreenshotPlugin/Core/ExplorerHelper.cs | 7 ++- 2 files changed, 35 insertions(+), 58 deletions(-) diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 8de6e7edb..23bb8960f 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -1307,38 +1307,10 @@ namespace Greenshot { private void NotifyIconClick(ClickActions clickAction) { switch (clickAction) { case ClickActions.OPEN_LAST_IN_EXPLORER: - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - var outputFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); - if (outputFilePath == null || (!File.Exists(_conf.OutputFileAsFullpath) && !Directory.Exists(Path.GetDirectoryName(outputFilePath)))) - { - _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; - } - string path = _conf.OutputFileAsFullpath; - if (!File.Exists(path)) { - string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); - if (!string.IsNullOrEmpty(lastFilePath) && Directory.Exists(lastFilePath)) { - path = lastFilePath; - } - } - if (path == null) { - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!File.Exists(_conf.OutputFilePath)) - { - _conf.OutputFilePath = _conf.GetDefault(nameof(_conf.OutputFilePath)) as string; - } - string configPath = FilenameHelper.FillVariables(_conf.OutputFilePath, false); - if (Directory.Exists(configPath)) { - path = configPath; - } - } - ExplorerHelper.OpenInExplorer(path); + Contextmenu_OpenRecent(this, null); break; case ClickActions.OPEN_LAST_IN_EDITOR: - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!File.Exists(_conf.OutputFileAsFullpath)) - { - _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; - } + _conf.ValidateAndCorrectOutputFileAsFullpath(); if (File.Exists(_conf.OutputFileAsFullpath)) { CaptureHelper.CaptureFile(_conf.OutputFileAsFullpath, DestinationHelper.GetDestination(EditorDestination.DESIGNATION)); @@ -1357,38 +1329,40 @@ namespace Greenshot { /// /// The Contextmenu_OpenRecent currently opens the last know save location /// - private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs) { - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - if (!File.Exists(_conf.OutputFilePath)) + private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs) + { + _conf.ValidateAndCorrectOutputFilePath(); + _conf.ValidateAndCorrectOutputFileAsFullpath(); + string path = _conf.OutputFileAsFullpath; + if (!File.Exists(path)) { - _conf.OutputFilePath = _conf.GetDefault(nameof(_conf.OutputFilePath)) as string; - } - - string path = FilenameHelper.FillVariables(_conf.OutputFilePath, false); - // Fix for #1470, problems with a drive which is no longer available - try { - // Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is used on a different PC) - var outputFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); - if (outputFilePath == null || (!File.Exists(_conf.OutputFileAsFullpath) && !Directory.Exists(Path.GetDirectoryName(outputFilePath)))) + path = FilenameHelper.FillVariables(_conf.OutputFilePath, false); + // Fix for #1470, problems with a drive which is no longer available + try { - _conf.OutputFileAsFullpath = _conf.GetDefault(nameof(_conf.OutputFileAsFullpath)) as string; - } + string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); - string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath); - - if (lastFilePath != null && Directory.Exists(lastFilePath)) { - path = lastFilePath; - } else if (!Directory.Exists(path)) { - // What do I open when nothing can be found? Right, nothing... - return; + if (lastFilePath != null && Directory.Exists(lastFilePath)) + { + path = lastFilePath; + } + else if (!Directory.Exists(path)) + { + // What do I open when nothing can be found? Right, nothing... + return; + } + } + catch (Exception ex) + { + LOG.Warn("Couldn't open the path to the last exported file, taking default.", ex); } - } catch (Exception ex) { - LOG.Warn("Couldn't open the path to the last exported file, taking default.", ex); } - LOG.Debug("DoubleClick was called! Starting: " + path); - try { + try + { ExplorerHelper.OpenInExplorer(path); - } catch (Exception ex) { + } + catch (Exception ex) + { // Make sure we show what we tried to open in the exception ex.Data.Add("path", path); LOG.Warn("Couldn't open the path to the last exported file", ex); diff --git a/GreenshotPlugin/Core/ExplorerHelper.cs b/GreenshotPlugin/Core/ExplorerHelper.cs index 12bcb1787..7f65294f4 100644 --- a/GreenshotPlugin/Core/ExplorerHelper.cs +++ b/GreenshotPlugin/Core/ExplorerHelper.cs @@ -15,11 +15,11 @@ namespace GreenshotPlugin.Core /// If the path is a file, the explorer is opened with the directory and the file is selected. /// /// Path to file or directory - public static void OpenInExplorer(string path) + public static bool OpenInExplorer(string path) { if (path == null) { - return; + return false; } try { @@ -28,6 +28,7 @@ namespace GreenshotPlugin.Core { using (Process.Start(path)) { + return true; } } // Check if path is a file @@ -37,6 +38,7 @@ namespace GreenshotPlugin.Core using (var explorer = Process.Start("explorer.exe", $"/select,\"{path}\"")) { explorer?.WaitForInputIdle(500); + return true; } } } @@ -46,6 +48,7 @@ namespace GreenshotPlugin.Core ex.Data.Add("path", path); throw; } + return false; } } } From e08985fd6fb3d27cb1c64955710a3f4dbc17c9f9 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 24 Jan 2017 21:59:53 +0100 Subject: [PATCH 22/39] Updated the jira code, in the hope to solve BUG-2122 --- .../GreenshotJiraPlugin.csproj | 12 +++--- GreenshotJiraPlugin/IssueTypeBitmapCache.cs | 8 ++-- GreenshotJiraPlugin/JiraConnector.cs | 38 +++++++++---------- GreenshotJiraPlugin/JiraMonitor.cs | 26 ++++++------- GreenshotJiraPlugin/packages.config | 6 +-- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index b5a3d87f5..fb1e8108b 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -34,16 +34,16 @@ - - ..\packages\Dapplo.HttpExtensions.0.6.10\lib\net45\Dapplo.HttpExtensions.dll + + ..\packages\Dapplo.HttpExtensions.0.6.17\lib\net45\Dapplo.HttpExtensions.dll True - - ..\packages\Dapplo.Jira.0.3.4\lib\net45\Dapplo.Jira.dll + + ..\packages\Dapplo.Jira.0.5.8\lib\net45\Dapplo.Jira.dll True - - ..\packages\Dapplo.Log.1.0.22\lib\net45\Dapplo.Log.dll + + ..\packages\Dapplo.Log.1.0.23\lib\net45\Dapplo.Log.dll True diff --git a/GreenshotJiraPlugin/IssueTypeBitmapCache.cs b/GreenshotJiraPlugin/IssueTypeBitmapCache.cs index b48173e8f..782d2e9ed 100644 --- a/GreenshotJiraPlugin/IssueTypeBitmapCache.cs +++ b/GreenshotJiraPlugin/IssueTypeBitmapCache.cs @@ -33,11 +33,11 @@ namespace GreenshotJiraPlugin /// public class IssueTypeBitmapCache : AsyncMemoryCache { - private readonly JiraApi _jiraApi; + private readonly IJiraClient _jiraClient; - public IssueTypeBitmapCache(JiraApi jiraApi) + public IssueTypeBitmapCache(IJiraClient jiraClient) { - _jiraApi = jiraApi; + _jiraClient = jiraClient; // Set the expire timeout to an hour ExpireTimeSpan = TimeSpan.FromHours(4); } @@ -49,7 +49,7 @@ namespace GreenshotJiraPlugin protected override async Task CreateAsync(IssueType issueType, CancellationToken cancellationToken = new CancellationToken()) { - return await _jiraApi.GetUriContentAsync(issueType.IconUri, cancellationToken).ConfigureAwait(false); + return await _jiraClient.Server.GetUriContentAsync(issueType.IconUri, cancellationToken).ConfigureAwait(false); } } } diff --git a/GreenshotJiraPlugin/JiraConnector.cs b/GreenshotJiraPlugin/JiraConnector.cs index 1351ce2d3..6d9c933f3 100644 --- a/GreenshotJiraPlugin/JiraConnector.cs +++ b/GreenshotJiraPlugin/JiraConnector.cs @@ -37,7 +37,7 @@ using GreenshotPlugin.Core; namespace GreenshotJiraPlugin { /// - /// This encapsulates the JiraApi to make it possible to change as less old Greenshot code as needed + /// This encapsulates the JiraClient to make it possible to change as less old Greenshot code as needed /// public class JiraConnector : IDisposable { private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(JiraConnector)); @@ -48,7 +48,7 @@ namespace GreenshotJiraPlugin { private DateTimeOffset _loggedInTime = DateTimeOffset.MinValue; private bool _loggedIn; private readonly int _timeout; - private JiraApi _jiraApi; + private IJiraClient _jiraClient; private IssueTypeBitmapCache _issueTypeBitmapCache; /// @@ -60,7 +60,7 @@ namespace GreenshotJiraPlugin { { if (args.PropertyName == nameof(CoreConfig.IconSize)) { - JiraPlugin.Instance.JiraConnector._jiraApi?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height }); + JiraPlugin.Instance.JiraConnector._jiraClient?.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height }); } }; @@ -70,7 +70,7 @@ namespace GreenshotJiraPlugin { /// Dispose, logout the users /// public void Dispose() { - if (_jiraApi != null) + if (_jiraClient != null) { Task.Run(async () => await LogoutAsync()).Wait(); } @@ -103,21 +103,21 @@ namespace GreenshotJiraPlugin { { return false; } - _jiraApi = new JiraApi(new Uri(JiraConfig.Url)); - _jiraApi.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height }); + _jiraClient = JiraClient.Create(new Uri(JiraConfig.Url)); + _jiraClient.Behaviour.SetConfig(new SvgConfiguration { Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height }); - _issueTypeBitmapCache = new IssueTypeBitmapCache(_jiraApi); + _issueTypeBitmapCache = new IssueTypeBitmapCache(_jiraClient); LoginInfo loginInfo; try { - loginInfo = await _jiraApi.Session.StartAsync(user, password, cancellationToken); + loginInfo = await _jiraClient.Session.StartAsync(user, password, cancellationToken); Monitor = new JiraMonitor(); - await Monitor.AddJiraInstanceAsync(_jiraApi, cancellationToken); + await Monitor.AddJiraInstanceAsync(_jiraClient, cancellationToken); - var favIconUri = _jiraApi.JiraBaseUri.AppendSegments("favicon.ico"); + var favIconUri = _jiraClient.JiraBaseUri.AppendSegments("favicon.ico"); try { - FavIcon = await _jiraApi.GetUriContentAsync(favIconUri, cancellationToken); + FavIcon = await _jiraClient.Server.GetUriContentAsync(favIconUri, cancellationToken); } catch (Exception ex) { @@ -177,10 +177,10 @@ namespace GreenshotJiraPlugin { /// End the session, if there was one /// public async Task LogoutAsync(CancellationToken cancellationToken = default(CancellationToken)) { - if (_jiraApi != null && _loggedIn) + if (_jiraClient != null && _loggedIn) { Monitor.Dispose(); - await _jiraApi.Session.EndAsync(cancellationToken); + await _jiraClient.Session.EndAsync(cancellationToken); _loggedIn = false; } } @@ -208,7 +208,7 @@ namespace GreenshotJiraPlugin { public async Task> GetFavoriteFiltersAsync(CancellationToken cancellationToken = default(CancellationToken)) { await CheckCredentialsAsync(cancellationToken); - return await _jiraApi.Filter.GetFavoritesAsync(cancellationToken).ConfigureAwait(false); + return await _jiraClient.Filter.GetFavoritesAsync(cancellationToken).ConfigureAwait(false); } /// @@ -222,7 +222,7 @@ namespace GreenshotJiraPlugin { await CheckCredentialsAsync(cancellationToken); try { - return await _jiraApi.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false); + return await _jiraClient.Issue.GetAsync(issueKey, cancellationToken).ConfigureAwait(false); } catch { @@ -244,7 +244,7 @@ namespace GreenshotJiraPlugin { { content.WriteToStream(memoryStream); memoryStream.Seek(0, SeekOrigin.Begin); - await _jiraApi.Attachment.AttachAsync(issueKey, memoryStream, content.Filename, content.ContentType, cancellationToken).ConfigureAwait(false); + await _jiraClient.Attachment.AttachAsync(issueKey, memoryStream, content.Filename, content.ContentType, cancellationToken).ConfigureAwait(false); } } @@ -258,7 +258,7 @@ namespace GreenshotJiraPlugin { public async Task AddCommentAsync(string issueKey, string body, string visibility = null, CancellationToken cancellationToken = default(CancellationToken)) { await CheckCredentialsAsync(cancellationToken); - await _jiraApi.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false); + await _jiraClient.Issue.AddCommentAsync(issueKey, body, visibility, cancellationToken).ConfigureAwait(false); } /// @@ -270,7 +270,7 @@ namespace GreenshotJiraPlugin { public async Task> SearchAsync(Filter filter, CancellationToken cancellationToken = default(CancellationToken)) { await CheckCredentialsAsync(cancellationToken); - var searchResult = await _jiraApi.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false); + var searchResult = await _jiraClient.Issue.SearchAsync(filter.Jql, 20, new[] { "summary", "reporter", "assignee", "created", "issuetype" }, cancellationToken).ConfigureAwait(false); return searchResult.Issues; } @@ -288,7 +288,7 @@ namespace GreenshotJiraPlugin { /// /// Get the base uri /// - public Uri JiraBaseUri => _jiraApi.JiraBaseUri; + public Uri JiraBaseUri => _jiraClient.JiraBaseUri; /// /// Is the user "logged in? diff --git a/GreenshotJiraPlugin/JiraMonitor.cs b/GreenshotJiraPlugin/JiraMonitor.cs index d38cdee5c..562bf6c4c 100644 --- a/GreenshotJiraPlugin/JiraMonitor.cs +++ b/GreenshotJiraPlugin/JiraMonitor.cs @@ -42,8 +42,8 @@ namespace GreenshotJiraPlugin private static readonly LogSource Log = new LogSource(); private readonly Regex _jiraKeyPattern = new Regex(@"[A-Z][A-Z0-9]+\-[0-9]+"); private readonly WindowsTitleMonitor _monitor; - private readonly IList _jiraInstances = new List(); - private readonly IDictionary _projectJiraApiMap = new Dictionary(); + private readonly IList _jiraInstances = new List(); + private readonly IDictionary _projectJiraClientMap = new Dictionary(); private readonly int _maxEntries; // TODO: Add issues from issueHistory (JQL -> Where.IssueKey.InIssueHistory()) private IDictionary _recentJiras = new Dictionary(); @@ -93,10 +93,10 @@ namespace GreenshotJiraPlugin /// Retrieve the API belonging to a JiraDetails /// /// - /// JiraAPI - public JiraApi GetJiraApiForKey(JiraDetails jiraDetails) + /// IJiraClient + public IJiraClient GetJiraClientForKey(JiraDetails jiraDetails) { - return _projectJiraApiMap[jiraDetails.ProjectKey]; + return _projectJiraClientMap[jiraDetails.ProjectKey]; } /// @@ -117,7 +117,7 @@ namespace GreenshotJiraPlugin /// /// /// - public async Task AddJiraInstanceAsync(JiraApi jiraInstance, CancellationToken token = default(CancellationToken)) + public async Task AddJiraInstanceAsync(IJiraClient jiraInstance, CancellationToken token = default(CancellationToken)) { _jiraInstances.Add(jiraInstance); var projects = await jiraInstance.Project.GetAllAsync(cancellationToken: token).ConfigureAwait(false); @@ -125,9 +125,9 @@ namespace GreenshotJiraPlugin { foreach (var project in projects) { - if (!_projectJiraApiMap.ContainsKey(project.Key)) + if (!_projectJiraClientMap.ContainsKey(project.Key)) { - _projectJiraApiMap.Add(project.Key, jiraInstance); + _projectJiraClientMap.Add(project.Key, jiraInstance); } } } @@ -142,10 +142,10 @@ namespace GreenshotJiraPlugin { try { - JiraApi jiraApi; - if (_projectJiraApiMap.TryGetValue(jiraDetails.ProjectKey, out jiraApi)) + IJiraClient jiraClient; + if (_projectJiraClientMap.TryGetValue(jiraDetails.ProjectKey, out jiraClient)) { - var issue = await jiraApi.Issue.GetAsync(jiraDetails.JiraKey).ConfigureAwait(false); + var issue = await jiraClient.Issue.GetAsync(jiraDetails.JiraKey).ConfigureAwait(false); jiraDetails.JiraIssue = issue; } // Send event @@ -179,9 +179,9 @@ namespace GreenshotJiraPlugin var projectKey = jiraKeyParts[0]; var jiraId = jiraKeyParts[1]; - JiraApi jiraApi; + IJiraClient jiraClient; // Check if we have a JIRA instance with a project for this key - if (_projectJiraApiMap.TryGetValue(projectKey, out jiraApi)) + if (_projectJiraClientMap.TryGetValue(projectKey, out jiraClient)) { // We have found a project for this _jira key, so it must be a valid & known JIRA JiraDetails currentJiraDetails; diff --git a/GreenshotJiraPlugin/packages.config b/GreenshotJiraPlugin/packages.config index d3e269a7c..5c071995c 100644 --- a/GreenshotJiraPlugin/packages.config +++ b/GreenshotJiraPlugin/packages.config @@ -1,8 +1,8 @@  - - - + + + \ No newline at end of file From 7599766e3a4224a1285a96408e11c9cc2cf2e636 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 Jan 2017 08:29:27 +0100 Subject: [PATCH 23/39] Added something to show errors during async code, which is used in the JIRA Plugin. --- GreenshotJiraPlugin/JiraPlugin.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/GreenshotJiraPlugin/JiraPlugin.cs b/GreenshotJiraPlugin/JiraPlugin.cs index 24969d25f..ed26d888d 100644 --- a/GreenshotJiraPlugin/JiraPlugin.cs +++ b/GreenshotJiraPlugin/JiraPlugin.cs @@ -25,6 +25,8 @@ using Greenshot.Plugin; using System; using System.Threading.Tasks; using Dapplo.Log; +using Greenshot.Forms; +using Greenshot.Helpers; using GreenshotJiraPlugin.Forms; using GreenshotPlugin.Core; using log4net; @@ -57,6 +59,22 @@ namespace GreenshotJiraPlugin { public JiraPlugin() { _instance = this; + // Added to prevent Greenshot from shutting down when there was an exception in a Task + TaskScheduler.UnobservedTaskException += (sender, args) => + { + try + { + Exception exceptionToLog = args.Exception; + string exceptionText = EnvironmentInfo.BuildReport(exceptionToLog); + Log.Error("Exception caught in the UnobservedTaskException handler."); + Log.Error(exceptionText); + new BugReportForm(exceptionText).ShowDialog(); + } + finally + { + args.SetObserved(); + } + }; } public IEnumerable Destinations() { From e98452e268acbe73558c93e2d561fa3cb845cd24 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 Jan 2017 08:31:39 +0100 Subject: [PATCH 24/39] Changed download links to HTTPS [skip ci] --- Greenshot/Helpers/UpdateHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Greenshot/Helpers/UpdateHelper.cs b/Greenshot/Helpers/UpdateHelper.cs index 68d5d5d9f..28c522c18 100644 --- a/Greenshot/Helpers/UpdateHelper.cs +++ b/Greenshot/Helpers/UpdateHelper.cs @@ -36,8 +36,8 @@ namespace Greenshot.Experimental { public static class UpdateHelper { private static readonly ILog Log = LogManager.GetLogger(typeof(UpdateHelper)); private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection(); - private const string StableDownloadLink = "http://getgreenshot.org/downloads/"; - private const string VersionHistoryLink = "http://getgreenshot.org/version-history/"; + private const string StableDownloadLink = "https://getgreenshot.org/downloads/"; + private const string VersionHistoryLink = "https://getgreenshot.org/version-history/"; private static readonly object LockObject = new object(); private static RssFile _latestGreenshot; private static string _downloadLink = StableDownloadLink; From 027a4ad8dbdf93aa1aa94ba3b51a0026434acc07 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 Jan 2017 09:19:37 +0100 Subject: [PATCH 25/39] SUPPORT-155: Generating URL to "original" size/file --- GreenshotFlickrPlugin/FlickrUtils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GreenshotFlickrPlugin/FlickrUtils.cs b/GreenshotFlickrPlugin/FlickrUtils.cs index 00cb56ed4..c9f8019a0 100644 --- a/GreenshotFlickrPlugin/FlickrUtils.cs +++ b/GreenshotFlickrPlugin/FlickrUtils.cs @@ -42,7 +42,7 @@ namespace GreenshotFlickrPlugin { private const string FLICKR_ACCESS_TOKEN_URL = FLICKR_OAUTH_BASE_URL + "access_token"; private const string FLICKR_AUTHORIZE_URL = FLICKR_OAUTH_BASE_URL + "authorize"; private const string FLICKR_REQUEST_TOKEN_URL = FLICKR_OAUTH_BASE_URL + "request_token"; - private const string FLICKR_FARM_URL = "https://farm{0}.staticflickr.com/{1}/{2}_{3}.jpg"; + private const string FLICKR_FARM_URL = "https://farm{0}.staticflickr.com/{1}/{2}_{3}_o.{4}"; // REST private const string FLICKR_REST_URL = FLICKR_API_BASE_URL + "rest/"; private const string FLICKR_GET_INFO_URL = FLICKR_REST_URL + "?method=flickr.photos.getInfo"; @@ -132,7 +132,8 @@ namespace GreenshotFlickrPlugin { string serverId = item.Attributes["server"].Value; string photoId = item.Attributes["id"].Value; string secret = item.Attributes["secret"].Value; - return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, secret); + string originalFormat = item.Attributes["originalformat"].Value; + return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, secret, originalFormat); } } } From b47ca067e460ec3cfbc22fc3bc7d562c6915306f Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 Jan 2017 14:34:47 +0100 Subject: [PATCH 26/39] BUG-2124: Fixed link to use originalsecret attribute. --- GreenshotFlickrPlugin/FlickrUtils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GreenshotFlickrPlugin/FlickrUtils.cs b/GreenshotFlickrPlugin/FlickrUtils.cs index c9f8019a0..39c423cdf 100644 --- a/GreenshotFlickrPlugin/FlickrUtils.cs +++ b/GreenshotFlickrPlugin/FlickrUtils.cs @@ -131,9 +131,9 @@ namespace GreenshotFlickrPlugin { string farmId = item.Attributes["farm"].Value; string serverId = item.Attributes["server"].Value; string photoId = item.Attributes["id"].Value; - string secret = item.Attributes["secret"].Value; + string originalsecret = item.Attributes["originalsecret"].Value; string originalFormat = item.Attributes["originalformat"].Value; - return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, secret, originalFormat); + return string.Format(FLICKR_FARM_URL, farmId, serverId, photoId, originalsecret, originalFormat); } } } From 9e9548288146d17d7c0cc7eef05444074add18fb Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 Jan 2017 17:25:19 +0100 Subject: [PATCH 27/39] Fix for BUG-2115 and BUG-2122, the underlying Jira library used the wrong XSRF value which was accepted by later JIRAs. --- GreenshotJiraPlugin/GreenshotJiraPlugin.csproj | 4 ++-- GreenshotJiraPlugin/packages.config | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index fb1e8108b..b29d53140 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -38,8 +38,8 @@ ..\packages\Dapplo.HttpExtensions.0.6.17\lib\net45\Dapplo.HttpExtensions.dll True - - ..\packages\Dapplo.Jira.0.5.8\lib\net45\Dapplo.Jira.dll + + ..\packages\Dapplo.Jira.0.5.12\lib\net45\Dapplo.Jira.dll True diff --git a/GreenshotJiraPlugin/packages.config b/GreenshotJiraPlugin/packages.config index 5c071995c..3562425cc 100644 --- a/GreenshotJiraPlugin/packages.config +++ b/GreenshotJiraPlugin/packages.config @@ -1,7 +1,7 @@  - + From 98415aaa81800d35ace5f4d16fcc74c914694e3b Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 Jan 2017 17:33:21 +0100 Subject: [PATCH 28/39] BUG-2102: Fixing an issue when a second ColorDialog is opened. --- Greenshot/Controls/ColorButton.cs | 6 ++++-- Greenshot/Controls/ToolStripColorButton.cs | 6 ++++-- Greenshot/Forms/ColorDialog.cs | 8 +------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Greenshot/Controls/ColorButton.cs b/Greenshot/Controls/ColorButton.cs index d37fbf1c9..a08f0afab 100644 --- a/Greenshot/Controls/ColorButton.cs +++ b/Greenshot/Controls/ColorButton.cs @@ -68,8 +68,10 @@ namespace Greenshot.Controls { } private void ColorButtonClick(object sender, EventArgs e) { - ColorDialog colorDialog = ColorDialog.GetInstance(); - colorDialog.Color = SelectedColor; + var colorDialog = new ColorDialog + { + Color = SelectedColor + }; // Using the parent to make sure the dialog doesn't show on another window colorDialog.ShowDialog(Parent.Parent); if (colorDialog.DialogResult == DialogResult.Cancel) diff --git a/Greenshot/Controls/ToolStripColorButton.cs b/Greenshot/Controls/ToolStripColorButton.cs index ac4fcd736..8f5acd7d9 100644 --- a/Greenshot/Controls/ToolStripColorButton.cs +++ b/Greenshot/Controls/ToolStripColorButton.cs @@ -66,8 +66,10 @@ namespace Greenshot.Controls { } private void ColorButtonClick(object sender, EventArgs e) { - ColorDialog colorDialog = ColorDialog.GetInstance(); - colorDialog.Color = SelectedColor; + var colorDialog = new ColorDialog + { + Color = SelectedColor + }; // Using the parent to make sure the dialog doesn't show on another window colorDialog.ShowDialog(Parent.Parent); if (colorDialog.DialogResult == DialogResult.Cancel) diff --git a/Greenshot/Forms/ColorDialog.cs b/Greenshot/Forms/ColorDialog.cs index 5cfbf187d..5799e0351 100644 --- a/Greenshot/Forms/ColorDialog.cs +++ b/Greenshot/Forms/ColorDialog.cs @@ -34,10 +34,9 @@ namespace Greenshot { /// Description of ColorDialog. /// public partial class ColorDialog : BaseForm { - private static ColorDialog _uniqueInstance; private static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection(); - private ColorDialog() { + public ColorDialog() { SuspendLayout(); InitializeComponent(); SuspendLayout(); @@ -47,11 +46,6 @@ namespace Greenshot { UpdateRecentColorsButtonRow(); } - public static ColorDialog GetInstance() - { - return _uniqueInstance ?? (_uniqueInstance = new ColorDialog()); - } - private readonly List