From bf0c23f81218ae743b80483170acb806a51e7788 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 5 Jun 2018 10:08:33 +0200 Subject: [PATCH] Working on removing obsolete code, updated dependencies. --- src/Greenshot.Addon.Box/BoxDestination.cs | 10 +- .../Greenshot.Addon.Box.csproj | 36 +- src/Greenshot.Addon.Box/packages.config | 18 +- .../ConfluenceDestination.cs | 25 +- .../Greenshot.Addon.Confluence.csproj | 36 +- .../packages.config | 18 +- .../DropboxDestination.cs | 16 +- .../Greenshot.Addon.Dropbox.csproj | 36 +- src/Greenshot.Addon.Dropbox/packages.config | 18 +- .../Greenshot.Addon.ExternalCommand.csproj | 36 +- .../packages.config | 18 +- .../FlickrDestination.cs | 21 +- .../Greenshot.Addon.Flickr.csproj | 36 +- src/Greenshot.Addon.Flickr/packages.config | 18 +- .../GooglePhotosDestination.cs | 18 +- .../Greenshot.Addon.GooglePhotos.csproj | 36 +- .../packages.config | 18 +- .../Greenshot.Addon.Imgur.csproj | 36 +- src/Greenshot.Addon.Imgur/ImgurDestination.cs | 12 +- src/Greenshot.Addon.Imgur/packages.config | 18 +- .../Greenshot.Addon.Jira.csproj | 36 +- src/Greenshot.Addon.Jira/JiraDestination.cs | 71 +- src/Greenshot.Addon.Jira/packages.config | 18 +- .../Drawing/Surface.cs | 29 +- .../Greenshot.Addon.LegacyEditor.csproj | 45 +- .../packages.config | 21 +- .../Greenshot.Addon.Lutim.csproj | 36 +- src/Greenshot.Addon.Lutim/LutimDestination.cs | 14 +- src/Greenshot.Addon.Lutim/packages.config | 18 +- .../Greenshot.Addon.OCR.csproj | 36 +- src/Greenshot.Addon.OCR/packages.config | 18 +- .../Greenshot.Addon.Office.csproj | 40 +- src/Greenshot.Addon.Office/packages.config | 20 +- .../OneDriveDestination.cs | 11 +- .../Greenshot.Addon.Photobucket.csproj | 36 +- .../packages.config | 18 +- src/Greenshot.Addon.Tfs/TfsDestination.cs | 16 +- .../Greenshot.Addon.Win10.csproj | 36 +- src/Greenshot.Addon.Win10/packages.config | 18 +- src/Greenshot.Addons/AddonsModule.cs | 5 + .../Controls/OAuthLoginForm.Designer.cs | 92 -- .../Controls/OAuthLoginForm.cs | 105 -- .../Controls/PleaseWaitForm.cs | 23 +- src/Greenshot.Addons/Core/NetworkHelper.cs | 913 ------------------ src/Greenshot.Addons/Greenshot.Addons.csproj | 51 +- src/Greenshot.Addons/packages.config | 22 +- src/Greenshot.Gfx/Greenshot.Gfx.csproj | 36 +- src/Greenshot.Gfx/packages.config | 18 +- .../Greenshot.PerformanceTests.csproj | 36 +- .../packages.config | 18 +- src/Greenshot.Tests/Greenshot.Tests.csproj | 36 +- src/Greenshot.Tests/packages.config | 18 +- src/Greenshot/Components/HotkeyHandler.cs | 36 +- src/Greenshot/Forms/MainForm.cs | 25 +- src/Greenshot/Greenshot.csproj | 48 +- src/Greenshot/Help/HelpFileLoader.cs | 14 +- src/Greenshot/packages.config | 24 +- 57 files changed, 761 insertions(+), 1776 deletions(-) delete mode 100644 src/Greenshot.Addons/Controls/OAuthLoginForm.Designer.cs delete mode 100644 src/Greenshot.Addons/Controls/OAuthLoginForm.cs delete mode 100644 src/Greenshot.Addons/Core/NetworkHelper.cs diff --git a/src/Greenshot.Addon.Box/BoxDestination.cs b/src/Greenshot.Addon.Box/BoxDestination.cs index dada3ca26..49abcc670 100644 --- a/src/Greenshot.Addon.Box/BoxDestination.cs +++ b/src/Greenshot.Addon.Box/BoxDestination.cs @@ -32,6 +32,7 @@ using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.HttpExtensions; using Dapplo.HttpExtensions.OAuth; @@ -56,6 +57,7 @@ namespace Greenshot.Addon.Box private static readonly LogSource Log = new LogSource(); private readonly IBoxConfiguration _boxConfiguration; private readonly IBoxLanguage _boxLanguage; + private readonly Func> _pleaseWaitFormFactory; private readonly INetworkConfiguration _networkConfiguration; private readonly IResourceProvider _resourceProvider; private readonly OAuth2Settings _oauth2Settings; @@ -67,11 +69,13 @@ namespace Greenshot.Addon.Box IGreenshotLanguage greenshotLanguage, IBoxConfiguration boxConfiguration, IBoxLanguage boxLanguage, + Func> pleaseWaitFormFactory, INetworkConfiguration networkConfiguration, IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage) { _boxConfiguration = boxConfiguration; _boxLanguage = boxLanguage; + _pleaseWaitFormFactory = pleaseWaitFormFactory; _networkConfiguration = networkConfiguration; _resourceProvider = resourceProvider; @@ -131,16 +135,16 @@ namespace Greenshot.Addon.Box try { string url; - using (var pleaseWaitForm = new PleaseWaitForm("Box", _boxLanguage.CommunicationWait)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("Box", _boxLanguage.CommunicationWait, default)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { url = await UploadToBoxAsync(surfaceToUpload).ConfigureAwait(true); } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } diff --git a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj index 3ef04d005..4d5c3ecd7 100644 --- a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj +++ b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj @@ -94,32 +94,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Box/packages.config b/src/Greenshot.Addon.Box/packages.config index fb6aab0fd..adf096c1a 100644 --- a/src/Greenshot.Addon.Box/packages.config +++ b/src/Greenshot.Addon.Box/packages.config @@ -22,15 +22,15 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs b/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs index 21324db8e..8a239bbe6 100644 --- a/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs +++ b/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs @@ -29,6 +29,7 @@ using System.Diagnostics; using System.Drawing; using System.Threading; using System.Windows; +using Autofac.Features.OwnedInstances; using Dapplo.Confluence; using Dapplo.Confluence.Entities; using Dapplo.Log; @@ -54,6 +55,7 @@ namespace Greenshot.Addon.Confluence private static readonly Bitmap ConfluenceIcon; private readonly IConfluenceConfiguration _confluenceConfiguration; private readonly IConfluenceLanguage _confluenceLanguage; + private readonly Func> _pleaseWaitFormFactory; private IConfluenceClient _confluenceClient; private readonly Content _page; @@ -80,18 +82,22 @@ namespace Greenshot.Addon.Confluence ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotLanguage, IConfluenceConfiguration confluenceConfiguration, - IConfluenceLanguage confluenceLanguage) : base(coreConfiguration, greenshotLanguage) + IConfluenceLanguage confluenceLanguage, + Func> pleaseWaitFormFactory + ) : base(coreConfiguration, greenshotLanguage) { _confluenceConfiguration = confluenceConfiguration; _confluenceLanguage = confluenceLanguage; + _pleaseWaitFormFactory = pleaseWaitFormFactory; } - protected ConfluenceDestination( + private ConfluenceDestination( ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotLanguage, IConfluenceConfiguration confluenceConfiguration, IConfluenceLanguage confluenceLanguage, - Content page) : this(coreConfiguration, greenshotLanguage, confluenceConfiguration, confluenceLanguage) + Func> pleaseWaitFormFactory, + Content page) : this(coreConfiguration, greenshotLanguage, confluenceConfiguration, confluenceLanguage, pleaseWaitFormFactory) { _page = page; } @@ -125,7 +131,7 @@ namespace Greenshot.Addon.Confluence } foreach (var currentPage in currentPages) { - yield return new ConfluenceDestination(CoreConfiguration, GreenshotLanguage, _confluenceConfiguration, _confluenceLanguage, currentPage); + yield return new ConfluenceDestination(CoreConfiguration, GreenshotLanguage, _confluenceConfiguration, _confluenceLanguage, _pleaseWaitFormFactory, currentPage); } } @@ -180,10 +186,13 @@ namespace Greenshot.Addon.Confluence errorMessage = null; try { - // TODO: Create content - new PleaseWaitForm().ShowAndWait(Description, _confluenceLanguage.CommunicationWait, - () => _confluenceClient.Attachment.AttachAsync(page.Id, surfaceToUpload, filename, null, "image/" + _confluenceConfiguration.UploadFormat.ToString().ToLower()) - ); + // TODO: Create content + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory()) + { + ownedPleaseWaitForm.Value.ShowAndWait(Description, _confluenceLanguage.CommunicationWait, + () => _confluenceClient.Attachment.AttachAsync(page.Id, surfaceToUpload, filename, null, + "image/" + _confluenceConfiguration.UploadFormat.ToString().ToLower())); + } Log.Debug().WriteLine("Uploaded to Confluence."); if (!_confluenceConfiguration.CopyWikiMarkupForImageToClipboard) { diff --git a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj index 09b9fcddd..23916be22 100644 --- a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj +++ b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj @@ -116,32 +116,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Confluence/packages.config b/src/Greenshot.Addon.Confluence/packages.config index 2f5299d53..5d4508012 100644 --- a/src/Greenshot.Addon.Confluence/packages.config +++ b/src/Greenshot.Addon.Confluence/packages.config @@ -24,15 +24,15 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Dropbox/DropboxDestination.cs b/src/Greenshot.Addon.Dropbox/DropboxDestination.cs index 9dd804a92..291002b11 100644 --- a/src/Greenshot.Addon.Dropbox/DropboxDestination.cs +++ b/src/Greenshot.Addon.Dropbox/DropboxDestination.cs @@ -32,6 +32,7 @@ using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.HttpExtensions; using Dapplo.HttpExtensions.OAuth; @@ -61,6 +62,7 @@ namespace Greenshot.Addon.Dropbox private readonly IDropboxConfiguration _dropboxPluginConfiguration; private readonly IDropboxLanguage _dropboxLanguage; private readonly IResourceProvider _resourceProvider; + private readonly Func> _pleaseWaitFormFactory; private OAuth2Settings _oAuth2Settings; private IHttpBehaviour _oAuthHttpBehaviour; @@ -70,14 +72,16 @@ namespace Greenshot.Addon.Dropbox INetworkConfiguration networkConfiguration, IResourceProvider resourceProvider, ICoreConfiguration coreConfiguration, - IGreenshotLanguage greenshotLanguage - ) : base(coreConfiguration, greenshotLanguage) + IGreenshotLanguage greenshotLanguage, + Func> pleaseWaitFormFactory + ) : base(coreConfiguration, greenshotLanguage) { _dropboxPluginConfiguration = dropboxPluginConfiguration; _dropboxLanguage = dropboxLanguage; _resourceProvider = resourceProvider; + _pleaseWaitFormFactory = pleaseWaitFormFactory; - _oAuth2Settings = new OAuth2Settings + _oAuth2Settings = new OAuth2Settings { AuthorizationUri = DropboxApiUri. AppendSegments("1", "oauth2", "authorize"). @@ -143,9 +147,9 @@ namespace Greenshot.Addon.Dropbox try { var cancellationTokenSource = new CancellationTokenSource(); - using (var pleaseWaitForm = new PleaseWaitForm("Dropbox", _dropboxLanguage.CommunicationWait, cancellationTokenSource)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("Dropbox", _dropboxLanguage.CommunicationWait, cancellationTokenSource)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { var filename = surfaceToUpload.GenerateFilename(CoreConfiguration, _dropboxPluginConfiguration); @@ -162,7 +166,7 @@ namespace Greenshot.Addon.Dropbox } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } } diff --git a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj index b619315d7..1f835920d 100644 --- a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj +++ b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj @@ -106,32 +106,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Dropbox/packages.config b/src/Greenshot.Addon.Dropbox/packages.config index fb6aab0fd..adf096c1a 100644 --- a/src/Greenshot.Addon.Dropbox/packages.config +++ b/src/Greenshot.Addon.Dropbox/packages.config @@ -22,15 +22,15 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj index 621b7abbe..43352c0c1 100644 --- a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj +++ b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj @@ -100,32 +100,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.ExternalCommand/packages.config b/src/Greenshot.Addon.ExternalCommand/packages.config index 2ce032649..7ebbe20c8 100644 --- a/src/Greenshot.Addon.ExternalCommand/packages.config +++ b/src/Greenshot.Addon.ExternalCommand/packages.config @@ -20,14 +20,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Flickr/FlickrDestination.cs b/src/Greenshot.Addon.Flickr/FlickrDestination.cs index 173ece189..44f877b2f 100644 --- a/src/Greenshot.Addon.Flickr/FlickrDestination.cs +++ b/src/Greenshot.Addon.Flickr/FlickrDestination.cs @@ -34,6 +34,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Linq; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.HttpExtensions; using Dapplo.HttpExtensions.Extensions; @@ -52,6 +53,9 @@ using Greenshot.Gfx; namespace Greenshot.Addon.Flickr { + /// + /// This defines the flickr destination + /// [Destination("Flickr")] public class FlickrDestination : AbstractDestination { @@ -60,6 +64,7 @@ namespace Greenshot.Addon.Flickr private readonly IFlickrConfiguration _flickrConfiguration; private readonly IFlickrLanguage _flickrLanguage; private readonly IResourceProvider _resourceProvider; + private readonly Func> _pleaseWaitFormFactory; private readonly OAuth1Settings _oAuthSettings; private readonly OAuth1HttpBehaviour _oAuthHttpBehaviour; private const string FlickrFarmUrl = "https://farm{0}.staticflickr.com/{1}/{2}_{3}.jpg"; @@ -80,14 +85,16 @@ namespace Greenshot.Addon.Flickr INetworkConfiguration networkConfiguration, IResourceProvider resourceProvider, ICoreConfiguration coreConfiguration, - IGreenshotLanguage greenshotLanguage - ) : base(coreConfiguration, greenshotLanguage) + IGreenshotLanguage greenshotLanguage, + Func> pleaseWaitFormFactory + ) : base(coreConfiguration, greenshotLanguage) { _flickrConfiguration = flickrConfiguration; _flickrLanguage = flickrLanguage; _resourceProvider = resourceProvider; + _pleaseWaitFormFactory = pleaseWaitFormFactory; - _oAuthSettings = new OAuth1Settings + _oAuthSettings = new OAuth1Settings { Token = flickrConfiguration, ClientId = flickrConfiguration.ClientId, @@ -151,16 +158,16 @@ namespace Greenshot.Addon.Flickr { var cancellationTokenSource = new CancellationTokenSource(); - using (var pleaseWaitForm = new PleaseWaitForm("Flickr", _flickrLanguage.CommunicationWait, cancellationTokenSource)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("Flickr", _flickrLanguage.CommunicationWait, cancellationTokenSource)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { - uploadUrl = await UploadToFlickrAsync(surface, captureDetails.Title); + uploadUrl = await UploadToFlickrAsync(surface, captureDetails.Title, cancellationTokenSource.Token); } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } diff --git a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj index bd3624c20..597743a73 100644 --- a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj +++ b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj @@ -103,32 +103,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Flickr/packages.config b/src/Greenshot.Addon.Flickr/packages.config index 21d913d55..6f752d248 100644 --- a/src/Greenshot.Addon.Flickr/packages.config +++ b/src/Greenshot.Addon.Flickr/packages.config @@ -21,14 +21,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.GooglePhotos/GooglePhotosDestination.cs b/src/Greenshot.Addon.GooglePhotos/GooglePhotosDestination.cs index 5c7e68dec..010af7cb5 100644 --- a/src/Greenshot.Addon.GooglePhotos/GooglePhotosDestination.cs +++ b/src/Greenshot.Addon.GooglePhotos/GooglePhotosDestination.cs @@ -32,6 +32,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.HttpExtensions; using Dapplo.HttpExtensions.OAuth; @@ -57,6 +58,7 @@ namespace Greenshot.Addon.GooglePhotos private readonly IGooglePhotosLanguage _googlePhotosLanguage; private readonly INetworkConfiguration _networkConfiguration; private readonly IResourceProvider _resourceProvider; + private readonly Func> _pleaseWaitFormFactory; private readonly OAuth2Settings _oAuth2Settings; public GooglePhotosDestination( @@ -65,15 +67,17 @@ namespace Greenshot.Addon.GooglePhotos INetworkConfiguration networkConfiguration, IResourceProvider resourceProvider, ICoreConfiguration coreConfiguration, - IGreenshotLanguage greenshotLanguage + IGreenshotLanguage greenshotLanguage, + Func> pleaseWaitFormFactory ) : base(coreConfiguration, greenshotLanguage) { _googlePhotosConfiguration = googlePhotosConfiguration; _googlePhotosLanguage = googlePhotosLanguage; _networkConfiguration = networkConfiguration; _resourceProvider = resourceProvider; + _pleaseWaitFormFactory = pleaseWaitFormFactory; - _oAuth2Settings = new OAuth2Settings + _oAuth2Settings = new OAuth2Settings { AuthorizationUri = new Uri("https://accounts.google.com").AppendSegments("o", "oauth2", "auth"). ExtendQuery(new Dictionary @@ -121,21 +125,21 @@ namespace Greenshot.Addon.GooglePhotos return exportInformation; } - public async Task Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload) + private async Task Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload) { try { string url; - using (var pleaseWaitForm = new PleaseWaitForm("GooglePhotos", _googlePhotosLanguage.CommunicationWait)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("GooglePhotos", _googlePhotosLanguage.CommunicationWait, default)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { url = await UploadToPicasa(surfaceToUpload).ConfigureAwait(true); } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } @@ -160,7 +164,7 @@ namespace Greenshot.Addon.GooglePhotos /// /// /// - public async Task UploadToPicasa(ISurface surface, IProgress progress = null, CancellationToken token = default) + private async Task UploadToPicasa(ISurface surface, IProgress progress = null, CancellationToken token = default) { string filename = surface.GenerateFilename(CoreConfiguration, _googlePhotosConfiguration); diff --git a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj index 9bb1180ad..cf361d428 100644 --- a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj +++ b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj @@ -89,32 +89,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.GooglePhotos/packages.config b/src/Greenshot.Addon.GooglePhotos/packages.config index 21d913d55..6f752d248 100644 --- a/src/Greenshot.Addon.GooglePhotos/packages.config +++ b/src/Greenshot.Addon.GooglePhotos/packages.config @@ -21,14 +21,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj index 8517381cc..fa84efa42 100644 --- a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj +++ b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj @@ -111,32 +111,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll ..\packages\MahApps.Metro.1.6.4\lib\net46\MahApps.Metro.dll diff --git a/src/Greenshot.Addon.Imgur/ImgurDestination.cs b/src/Greenshot.Addon.Imgur/ImgurDestination.cs index 1042a3bf2..9a5ca78a5 100644 --- a/src/Greenshot.Addon.Imgur/ImgurDestination.cs +++ b/src/Greenshot.Addon.Imgur/ImgurDestination.cs @@ -28,6 +28,7 @@ using System.Drawing; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.Log; using Dapplo.Windows.Extensions; @@ -55,6 +56,7 @@ namespace Greenshot.Addon.Imgur private readonly IImgurLanguage _imgurLanguage; private readonly ImgurApi _imgurApi; private readonly ImgurHistoryViewModel _imgurHistoryViewModel; + private readonly Func> _pleaseWaitFormFactory; private readonly IResourceProvider _resourceProvider; public ImgurDestination( @@ -64,12 +66,14 @@ namespace Greenshot.Addon.Imgur IImgurLanguage imgurLanguage, ImgurApi imgurApi, ImgurHistoryViewModel imgurHistoryViewModel, - IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage) + Func> pleaseWaitFormFactory, + IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage) { _imgurConfiguration = imgurConfiguration; _imgurLanguage = imgurLanguage; _imgurApi = imgurApi; _imgurHistoryViewModel = imgurHistoryViewModel; + _pleaseWaitFormFactory = pleaseWaitFormFactory; _resourceProvider = resourceProvider; } @@ -114,9 +118,9 @@ namespace Greenshot.Addon.Imgur var cancellationTokenSource = new CancellationTokenSource(); // TODO: Replace the form - using (var pleaseWaitForm = new PleaseWaitForm("Imgur", _imgurLanguage.CommunicationWait, cancellationTokenSource)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("Imgur", _imgurLanguage.CommunicationWait, cancellationTokenSource)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { imgurImage = await _imgurApi.UploadToImgurAsync(surfaceToUpload, captureDetails.Title, null, cancellationTokenSource.Token).ConfigureAwait(true); @@ -141,7 +145,7 @@ namespace Greenshot.Addon.Imgur } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } diff --git a/src/Greenshot.Addon.Imgur/packages.config b/src/Greenshot.Addon.Imgur/packages.config index bb7fc58e6..47aeb23c4 100644 --- a/src/Greenshot.Addon.Imgur/packages.config +++ b/src/Greenshot.Addon.Imgur/packages.config @@ -23,15 +23,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj index fbb1c89f6..6636bac75 100644 --- a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj +++ b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj @@ -114,32 +114,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Jira/JiraDestination.cs b/src/Greenshot.Addon.Jira/JiraDestination.cs index 717bf839e..cd5c80180 100644 --- a/src/Greenshot.Addon.Jira/JiraDestination.cs +++ b/src/Greenshot.Addon.Jira/JiraDestination.cs @@ -57,6 +57,7 @@ namespace Greenshot.Addon.Jira private readonly JiraConnector _jiraConnector; private readonly IWindowManager _windowManager; private readonly Func> _jiraViewModelFactory; + private readonly Func> _pleaseWaitFormFactory; private readonly IResourceProvider _resourceProvider; private readonly IJiraConfiguration _jiraConfiguration; private readonly IJiraLanguage _jiraLanguage; @@ -66,7 +67,8 @@ namespace Greenshot.Addon.Jira IJiraLanguage jiraLanguage, JiraConnector jiraConnector, Func> jiraViewModelFactory, - IWindowManager windowManager, + Func> pleaseWaitFormFactory, + IWindowManager windowManager, IResourceProvider resourceProvider, ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotLanguage @@ -77,19 +79,21 @@ namespace Greenshot.Addon.Jira _jiraConnector = jiraConnector; _windowManager = windowManager; _jiraViewModelFactory = jiraViewModelFactory; + _pleaseWaitFormFactory = pleaseWaitFormFactory; _resourceProvider = resourceProvider; } - protected JiraDestination(IJiraConfiguration jiraConfiguration, + private JiraDestination(IJiraConfiguration jiraConfiguration, IJiraLanguage jiraLanguage, JiraConnector jiraConnector, Func> jiraViewModelFactory, - IWindowManager windowManager, + Func> pleaseWaitFormFactory, + IWindowManager windowManager, IResourceProvider resourceProvider, Issue jiraIssue, ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotLanguage - ) : this(jiraConfiguration, jiraLanguage, jiraConnector, jiraViewModelFactory, windowManager, resourceProvider, coreConfiguration, greenshotLanguage) + ) : this(jiraConfiguration, jiraLanguage, jiraConnector, jiraViewModelFactory, pleaseWaitFormFactory, windowManager, resourceProvider, coreConfiguration, greenshotLanguage) { _jiraIssue = jiraIssue; } @@ -159,7 +163,7 @@ namespace Greenshot.Addon.Jira foreach (var jiraDetails in _jiraConnector.RecentJiras) { yield return new JiraDestination( - _jiraConfiguration, _jiraLanguage, _jiraConnector, _jiraViewModelFactory, + _jiraConfiguration, _jiraLanguage, _jiraConnector, _jiraViewModelFactory, _pleaseWaitFormFactory, _windowManager, _resourceProvider, jiraDetails.JiraIssue, CoreConfiguration, GreenshotLanguage); } } @@ -169,21 +173,24 @@ namespace Greenshot.Addon.Jira var exportInformation = new ExportInformation(Designation, Description); if (_jiraIssue != null) { - try - { - // Run upload in the background - new PleaseWaitForm().ShowAndWait(Description, _jiraLanguage.CommunicationWait, - async () => - { - await _jiraConnector.AttachAsync(_jiraIssue.Key, surface).ConfigureAwait(true); - surface.UploadUrl = _jiraConnector.JiraBaseUri.AppendSegments("browse", _jiraIssue.Key).AbsoluteUri; - } - ); - Log.Debug().WriteLine("Uploaded to Jira {0}", _jiraIssue.Key); - exportInformation.ExportMade = true; - exportInformation.Uri = surface.UploadUrl; - } - catch (Exception e) + try + { + // Run upload in the background + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory()) + { + ownedPleaseWaitForm.Value.ShowAndWait(Description, _jiraLanguage.CommunicationWait, + async () => + { + await _jiraConnector.AttachAsync(_jiraIssue.Key, surface).ConfigureAwait(true); + surface.UploadUrl = _jiraConnector.JiraBaseUri.AppendSegments("browse", _jiraIssue.Key) + .AbsoluteUri; + }); + } + Log.Debug().WriteLine("Uploaded to Jira {0}", _jiraIssue.Key); + exportInformation.ExportMade = true; + exportInformation.Uri = surface.UploadUrl; + } + catch (Exception e) { MessageBox.Show(_jiraLanguage.UploadFailure + " " + e.Message); } @@ -200,17 +207,23 @@ namespace Greenshot.Addon.Jira { surface.UploadUrl = _jiraConnector.JiraBaseUri.AppendSegments("browse", jiraViewModel.Value.JiraIssue.Key).AbsoluteUri; // Run upload in the background - new PleaseWaitForm().ShowAndWait(Description, _jiraLanguage.CommunicationWait, - async () => - { - await _jiraConnector.AttachAsync(jiraViewModel.Value.JiraIssue.Key, surface, jiraViewModel.Value.Filename).ConfigureAwait(true); - - if (!string.IsNullOrEmpty(jiraViewModel.Value.Comment)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory()) + { + ownedPleaseWaitForm.Value.ShowAndWait(Description, _jiraLanguage.CommunicationWait, + async () => { - await _jiraConnector.AddCommentAsync(jiraViewModel.Value.JiraIssue.Key, jiraViewModel.Value.Comment).ConfigureAwait(true); + await _jiraConnector.AttachAsync(jiraViewModel.Value.JiraIssue.Key, surface, + jiraViewModel.Value.Filename).ConfigureAwait(true); + + if (!string.IsNullOrEmpty(jiraViewModel.Value.Comment)) + { + await _jiraConnector.AddCommentAsync(jiraViewModel.Value.JiraIssue.Key, + jiraViewModel.Value.Comment).ConfigureAwait(true); + } } - } - ); + ); + } + Log.Debug().WriteLine("Uploaded to Jira {0}", jiraViewModel.Value.JiraIssue.Key); exportInformation.ExportMade = true; exportInformation.Uri = surface.UploadUrl; diff --git a/src/Greenshot.Addon.Jira/packages.config b/src/Greenshot.Addon.Jira/packages.config index f48555779..c2aec5957 100644 --- a/src/Greenshot.Addon.Jira/packages.config +++ b/src/Greenshot.Addon.Jira/packages.config @@ -24,15 +24,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs index b0ca849bc..690931f1e 100644 --- a/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs +++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs @@ -32,6 +32,7 @@ using System.Drawing.Imaging; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Windows.Forms; +using Dapplo.HttpExtensions; using Dapplo.Ini; using Dapplo.Log; using Dapplo.Windows.Common.Extensions; @@ -1999,12 +2000,34 @@ namespace Greenshot.Addon.LegacyEditor.Drawing if (e.Data.GetDataPresent("Text")) { var possibleUrl = ClipboardHelper.GetText(e.Data); + try + { + if (possibleUrl != null && possibleUrl.StartsWith("http")) + { + var uri = new Uri(possibleUrl); + + using (var image = uri.GetAsAsync().Result) + { + if (image != null) + { + AddImageContainer(image, mouse.X, mouse.Y); + return; + } + } + } + } + catch (Exception ex) + { + Log.Error().WriteLine(ex, "Couldn't download url {0}", possibleUrl); + } // Test if it's an url and try to download the image so we have it in the original form if (possibleUrl != null && possibleUrl.StartsWith("http")) { - using (var image = NetworkHelper.DownloadBitmap(possibleUrl)) - { - if (image != null) + var uri = new Uri(possibleUrl); + + using (var image = uri.GetAsAsync().Result) + { + if (image != null) { AddImageContainer(image, mouse.X, mouse.Y); return; diff --git a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj index 3106b3fcd..c057a03c3 100644 --- a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj +++ b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj @@ -61,6 +61,9 @@ ..\packages\Dapplo.CaliburnMicro.Translations.1.0.46\lib\net46\Dapplo.CaliburnMicro.Translations.dll + + ..\packages\Dapplo.HttpExtensions.0.8.35\lib\net46\Dapplo.HttpExtensions.dll + ..\packages\Dapplo.Ini.0.5.28\lib\net45\Dapplo.Ini.dll @@ -76,35 +79,35 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Clipboard.0.5.60\lib\net46\Dapplo.Windows.Clipboard.dll + + ..\packages\Dapplo.Windows.Clipboard.0.5.61\lib\net46\Dapplo.Windows.Clipboard.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll @@ -114,11 +117,13 @@ + ..\packages\System.Reactive.4.0.0\lib\net46\System.Reactive.dll + diff --git a/src/Greenshot.Addon.LegacyEditor/packages.config b/src/Greenshot.Addon.LegacyEditor/packages.config index 327122ec3..e6307ec36 100644 --- a/src/Greenshot.Addon.LegacyEditor/packages.config +++ b/src/Greenshot.Addon.LegacyEditor/packages.config @@ -14,20 +14,21 @@ + - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj index b12aeef58..540554d8e 100644 --- a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj +++ b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj @@ -106,32 +106,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll ..\packages\MahApps.Metro.1.6.4\lib\net46\MahApps.Metro.dll diff --git a/src/Greenshot.Addon.Lutim/LutimDestination.cs b/src/Greenshot.Addon.Lutim/LutimDestination.cs index 0f98cf05a..51a52257e 100644 --- a/src/Greenshot.Addon.Lutim/LutimDestination.cs +++ b/src/Greenshot.Addon.Lutim/LutimDestination.cs @@ -24,6 +24,7 @@ using System.Drawing; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.Log; using Greenshot.Addon.Lutim.Entities; @@ -46,19 +47,22 @@ namespace Greenshot.Addon.Lutim { private readonly ILutimLanguage _lutimLanguage; private readonly LutimApi _lutimApi; private readonly IResourceProvider _resourceProvider; + private readonly Func> _pleaseWaitFormFactory; public LutimDestination(ILutimConfiguration lutimConfiguration, ILutimLanguage lutimLanguage, LutimApi lutimApi, IResourceProvider resourceProvider, ICoreConfiguration coreConfiguration, - IGreenshotLanguage greenshotLanguage + IGreenshotLanguage greenshotLanguage, + Func> pleaseWaitFormFactory ) : base(coreConfiguration, greenshotLanguage) { _lutimConfiguration = lutimConfiguration; _lutimLanguage = lutimLanguage; _lutimApi = lutimApi; _resourceProvider = resourceProvider; + _pleaseWaitFormFactory = pleaseWaitFormFactory; } public override string Description => _lutimLanguage.UploadMenuItem; @@ -90,9 +94,7 @@ namespace Greenshot.Addon.Lutim { /// /// Upload the capture to lutim /// - /// ICaptureDetails /// ISurface - /// out string for the url /// true if the upload succeeded private async Task Upload(ISurface surfaceToUpload) { @@ -102,9 +104,9 @@ namespace Greenshot.Addon.Lutim { LutimInfo lutimInfo; var cancellationTokenSource = new CancellationTokenSource(); - using (var pleaseWaitForm = new PleaseWaitForm("Lutim", _lutimLanguage.CommunicationWait, cancellationTokenSource)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("Lutim", _lutimLanguage.CommunicationWait, cancellationTokenSource)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { lutimInfo = await _lutimApi.UploadToLutim(surfaceToUpload).ConfigureAwait(true); @@ -121,7 +123,7 @@ namespace Greenshot.Addon.Lutim { } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } diff --git a/src/Greenshot.Addon.Lutim/packages.config b/src/Greenshot.Addon.Lutim/packages.config index 8b9b3bf80..a6a3b4fff 100644 --- a/src/Greenshot.Addon.Lutim/packages.config +++ b/src/Greenshot.Addon.Lutim/packages.config @@ -22,15 +22,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj index d85797f68..aa6856e71 100644 --- a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj +++ b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj @@ -97,32 +97,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.OCR/packages.config b/src/Greenshot.Addon.OCR/packages.config index d71822c6e..383023dd9 100644 --- a/src/Greenshot.Addon.OCR/packages.config +++ b/src/Greenshot.Addon.OCR/packages.config @@ -19,14 +19,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj index 8ba3fa2c2..a833e6936 100644 --- a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj +++ b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj @@ -84,35 +84,35 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Com.0.5.60\lib\net46\Dapplo.Windows.Com.dll + + ..\packages\Dapplo.Windows.Com.0.5.61\lib\net46\Dapplo.Windows.Com.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Office/packages.config b/src/Greenshot.Addon.Office/packages.config index 27228e04a..02b28e4aa 100644 --- a/src/Greenshot.Addon.Office/packages.config +++ b/src/Greenshot.Addon.Office/packages.config @@ -20,16 +20,16 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.OneDrive/OneDriveDestination.cs b/src/Greenshot.Addon.OneDrive/OneDriveDestination.cs index 6df749e5f..d9b5ba4fb 100644 --- a/src/Greenshot.Addon.OneDrive/OneDriveDestination.cs +++ b/src/Greenshot.Addon.OneDrive/OneDriveDestination.cs @@ -31,6 +31,7 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.HttpExtensions; using Dapplo.HttpExtensions.JsonNet; @@ -60,6 +61,7 @@ namespace Greenshot.Addon.OneDrive private readonly IOneDriveConfiguration _oneDriveConfiguration; private readonly IOneDriveLanguage _oneDriveLanguage; private readonly IResourceProvider _resourceProvider; + private readonly Func> _pleaseWaitFormFactory; private readonly OAuth2Settings _oauth2Settings; private static readonly Uri GraphUri = new Uri("https://graph.microsoft.com"); private static readonly Uri OneDriveUri = GraphUri.AppendSegments("v1.0", "me", "drive"); @@ -72,6 +74,7 @@ namespace Greenshot.Addon.OneDrive IOneDriveLanguage oneDriveLanguage, INetworkConfiguration networkConfiguration, IResourceProvider resourceProvider, + Func> pleaseWaitFormFactory, ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotLanguage ) : base(coreConfiguration, greenshotLanguage) @@ -79,6 +82,7 @@ namespace Greenshot.Addon.OneDrive _oneDriveConfiguration = oneDriveConfiguration; _oneDriveLanguage = oneDriveLanguage; _resourceProvider = resourceProvider; + _pleaseWaitFormFactory = pleaseWaitFormFactory; // Configure the OAuth2 settings for OneDrive communication _oauth2Settings = new OAuth2Settings { @@ -147,10 +151,9 @@ namespace Greenshot.Addon.OneDrive Uri response; var cancellationTokenSource = new CancellationTokenSource(); - using (var pleaseWaitForm = new PleaseWaitForm("OneDrive plug-in", _oneDriveLanguage.CommunicationWait, - cancellationTokenSource)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("OneDrive", _oneDriveLanguage.CommunicationWait, cancellationTokenSource)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { var oneDriveResponse = await UploadToOneDriveAsync(_oauth2Settings, surfaceToUpload, null, cancellationTokenSource.Token); @@ -168,7 +171,7 @@ namespace Greenshot.Addon.OneDrive } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } diff --git a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj index 0bbbe678c..c11304d1c 100644 --- a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj +++ b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj @@ -103,32 +103,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Photobucket/packages.config b/src/Greenshot.Addon.Photobucket/packages.config index 21d913d55..6f752d248 100644 --- a/src/Greenshot.Addon.Photobucket/packages.config +++ b/src/Greenshot.Addon.Photobucket/packages.config @@ -21,14 +21,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Tfs/TfsDestination.cs b/src/Greenshot.Addon.Tfs/TfsDestination.cs index 9797809f5..35501fd41 100644 --- a/src/Greenshot.Addon.Tfs/TfsDestination.cs +++ b/src/Greenshot.Addon.Tfs/TfsDestination.cs @@ -29,6 +29,7 @@ using System.Drawing; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Autofac.Features.OwnedInstances; using Dapplo.Addons; using Dapplo.Log; using Greenshot.Addon.Tfs.Entities; @@ -53,6 +54,7 @@ namespace Greenshot.Addon.Tfs private readonly ITfsConfiguration _tfsConfiguration; private readonly ITfsLanguage _tfsLanguage; private readonly TfsClient _tfsClient; + private readonly Func> _pleaseWaitFormFactory; private readonly IResourceProvider _resourceProvider; private readonly WorkItem _workItem; @@ -62,11 +64,13 @@ namespace Greenshot.Addon.Tfs ITfsConfiguration tfsConfiguration, ITfsLanguage tfsLanguage, TfsClient tfsClient, + Func> pleaseWaitFormFactory, IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage) { _tfsConfiguration = tfsConfiguration; _tfsLanguage = tfsLanguage; _tfsClient = tfsClient; + _pleaseWaitFormFactory = pleaseWaitFormFactory; _resourceProvider = resourceProvider; } @@ -76,8 +80,9 @@ namespace Greenshot.Addon.Tfs ITfsConfiguration tfsConfiguration, ITfsLanguage tfsLanguage, TfsClient tfsClient, + Func> pleaseWaitFormFactory, IResourceProvider resourceProvider, - WorkItem workItem) :this(coreConfiguration, greenshotLanguage, tfsConfiguration, tfsLanguage, tfsClient, resourceProvider) + WorkItem workItem) :this(coreConfiguration, greenshotLanguage, tfsConfiguration, tfsLanguage, tfsClient, pleaseWaitFormFactory, resourceProvider) { _workItem = workItem; } @@ -108,7 +113,7 @@ namespace Greenshot.Addon.Tfs } foreach (var workitem in workitems) { - yield return new TfsDestination(CoreConfiguration, GreenshotLanguage, _tfsConfiguration, _tfsLanguage, _tfsClient, _resourceProvider, workitem); + yield return new TfsDestination(CoreConfiguration, GreenshotLanguage, _tfsConfiguration, _tfsLanguage, _tfsClient, _pleaseWaitFormFactory, _resourceProvider, workitem); } } @@ -171,10 +176,9 @@ namespace Greenshot.Addon.Tfs Uri response; var cancellationTokenSource = new CancellationTokenSource(); - using (var pleaseWaitForm = new PleaseWaitForm("TFS plug-in", _tfsLanguage.CommunicationWait, - cancellationTokenSource)) + using (var ownedPleaseWaitForm = _pleaseWaitFormFactory("TFS plug-in", _tfsLanguage.CommunicationWait, cancellationTokenSource)) { - pleaseWaitForm.Show(); + ownedPleaseWaitForm.Value.Show(); try { var result = await _tfsClient.CreateAttachment(surfaceToUpload); @@ -183,7 +187,7 @@ namespace Greenshot.Addon.Tfs } finally { - pleaseWaitForm.Close(); + ownedPleaseWaitForm.Value.Close(); } } diff --git a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj index 291175d6a..693593c4f 100644 --- a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj +++ b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj @@ -81,32 +81,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Addon.Win10/packages.config b/src/Greenshot.Addon.Win10/packages.config index a3435c2ba..1da0841df 100644 --- a/src/Greenshot.Addon.Win10/packages.config +++ b/src/Greenshot.Addon.Win10/packages.config @@ -15,14 +15,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/Greenshot.Addons/AddonsModule.cs b/src/Greenshot.Addons/AddonsModule.cs index 6b186ccad..ce65be0ed 100644 --- a/src/Greenshot.Addons/AddonsModule.cs +++ b/src/Greenshot.Addons/AddonsModule.cs @@ -24,6 +24,7 @@ using Autofac; using Dapplo.Addons; using Greenshot.Addons.Components; +using Greenshot.Addons.Controls; using Greenshot.Addons.ViewModels; namespace Greenshot.Addons @@ -39,6 +40,10 @@ namespace Greenshot.Addons builder .RegisterType() .AsSelf(); + + builder + .RegisterType() + .AsSelf(); base.Load(builder); } diff --git a/src/Greenshot.Addons/Controls/OAuthLoginForm.Designer.cs b/src/Greenshot.Addons/Controls/OAuthLoginForm.Designer.cs deleted file mode 100644 index 758e6beeb..000000000 --- a/src/Greenshot.Addons/Controls/OAuthLoginForm.Designer.cs +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Greenshot - a free and open source screenshot tool - * Copyright (C) 2007-2018 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 . - */ -namespace Greenshot.Addons.Controls { - partial class OAuthLoginForm { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() { - this._addressTextBox = new System.Windows.Forms.TextBox(); - this._browser = new ExtendedWebBrowser(); - this.SuspendLayout(); - // - // _addressTextBox - // - this._addressTextBox.Cursor = System.Windows.Forms.Cursors.Arrow; - this._addressTextBox.Dock = System.Windows.Forms.DockStyle.Top; - this._addressTextBox.Enabled = false; - this._addressTextBox.Location = new System.Drawing.Point(0, 0); - this._addressTextBox.Name = "addressTextBox"; - this._addressTextBox.Size = new System.Drawing.Size(595, 20); - this._addressTextBox.TabIndex = 3; - this._addressTextBox.TabStop = false; - // - // _browser - // - this._browser.Dock = System.Windows.Forms.DockStyle.Fill; - this._browser.Location = new System.Drawing.Point(0, 20); - this._browser.MinimumSize = new System.Drawing.Size(100, 100); - this._browser.Name = "browser"; - this._browser.Size = new System.Drawing.Size(595, 295); - this._browser.TabIndex = 4; - // - // OAuthLoginForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(595, 315); - this.Controls.Add(this._browser); - this.Controls.Add(this._addressTextBox); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "OAuthLoginForm"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox _addressTextBox; - private ExtendedWebBrowser _browser; - - } -} diff --git a/src/Greenshot.Addons/Controls/OAuthLoginForm.cs b/src/Greenshot.Addons/Controls/OAuthLoginForm.cs deleted file mode 100644 index 19ee63843..000000000 --- a/src/Greenshot.Addons/Controls/OAuthLoginForm.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Greenshot - a free and open source screenshot tool - * Copyright (C) 2007-2018 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.Windows.Forms; -using Dapplo.Log; -using Dapplo.Windows.Desktop; -using Greenshot.Addons.Core; - -namespace Greenshot.Addons.Controls { - /// - /// The OAuthLoginForm is used to allow the user to authorize Greenshot with an "Oauth" application - /// - public sealed partial class OAuthLoginForm : Form { - private static readonly LogSource Log = new LogSource(); - private readonly string _callbackUrl; - private IDictionary _callbackParameters; - - public IDictionary CallbackParameters => _callbackParameters; - - public bool IsOk => DialogResult == DialogResult.OK; - - public OAuthLoginForm(string browserTitle, Size size, string authorizationLink, string callbackUrl) { - // Make sure Greenshot uses the correct browser version - IEHelper.FixBrowserVersion(false); - - _callbackUrl = callbackUrl; - // Fix for BUG-2071 - if (callbackUrl.EndsWith("/")) - { - _callbackUrl = callbackUrl.Substring(0, callbackUrl.Length - 1); - } - InitializeComponent(); - ClientSize = size; - Icon = GreenshotResources.GetGreenshotIcon(); - Text = browserTitle; - _addressTextBox.Text = authorizationLink; - - // The script errors are suppressed by using the ExtendedWebBrowser - _browser.ScriptErrorsSuppressed = false; - _browser.DocumentCompleted += Browser_DocumentCompleted; - _browser.Navigated += Browser_Navigated; - _browser.Navigating += Browser_Navigating; - _browser.Navigate(new Uri(authorizationLink)); - } - - /// - /// Make sure the form is visible - /// - /// EventArgs - protected override async void OnShown(EventArgs e) { - base.OnShown(e); - await InteropWindowFactory.CreateFor(Handle).ToForegroundAsync(); - } - - private void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { - Log.Debug().WriteLine("document completed with url: {0}", _browser.Url); - CheckUrl(); - } - - private void Browser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { - Log.Debug().WriteLine("Navigating to url: {0}", _browser.Url); - _addressTextBox.Text = e.Url.ToString(); - } - - private void Browser_Navigated(object sender, WebBrowserNavigatedEventArgs e) { - Log.Debug().WriteLine("Navigated to url: {0}", _browser.Url); - CheckUrl(); - } - - private void CheckUrl() { - if (_browser.Url.ToString().StartsWith(_callbackUrl)) { - var correctedUri = new Uri(_browser.Url.AbsoluteUri.Replace("#", "&")); - - string queryParams = correctedUri.Query; - if (queryParams.Length > 0) { - queryParams = NetworkHelper.UrlDecode(queryParams); - //Store the Token and Token Secret - _callbackParameters = NetworkHelper.ParseQueryString(queryParams); - } - DialogResult = DialogResult.OK; - } - } - } -} diff --git a/src/Greenshot.Addons/Controls/PleaseWaitForm.cs b/src/Greenshot.Addons/Controls/PleaseWaitForm.cs index f9128dc23..327e362f5 100644 --- a/src/Greenshot.Addons/Controls/PleaseWaitForm.cs +++ b/src/Greenshot.Addons/Controls/PleaseWaitForm.cs @@ -39,7 +39,9 @@ namespace Greenshot.Addons.Controls /// public sealed partial class PleaseWaitForm : Form { - /// + private readonly IGreenshotLanguage _greenshotLanguage; + + /// /// Prevent the close-window button showing /// private const int CP_NOCLOSE_BUTTON = 0x200; @@ -49,16 +51,20 @@ namespace Greenshot.Addons.Controls private readonly CancellationTokenSource _cancellationTokenSource; private Thread _waitFor; - public PleaseWaitForm() + public PleaseWaitForm(IGreenshotLanguage greenshotLanguage) { - // + _greenshotLanguage = greenshotLanguage; + // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); Icon = GreenshotResources.GetGreenshotIcon(); } - public PleaseWaitForm(string title, string text, CancellationTokenSource cancellationTokenSource = default) : this() + public PleaseWaitForm(IGreenshotLanguage greenshotLanguage, + string title, + string text, + CancellationTokenSource cancellationTokenSource = default) : this(greenshotLanguage) { _title = title; _cancellationTokenSource = cancellationTokenSource; @@ -88,7 +94,7 @@ namespace Greenshot.Addons.Controls _title = title; Text = title; label_pleasewait.Text = text; - cancelButton.Text = Language.GetString("CANCEL"); + cancelButton.Text = _greenshotLanguage.Cancel; Show(); await executeTask; @@ -107,10 +113,10 @@ namespace Greenshot.Addons.Controls _title = title; Text = title; label_pleasewait.Text = text; - cancelButton.Text = Language.GetString("CANCEL"); + cancelButton.Text = _greenshotLanguage.Cancel; - // Make sure the form is shown. - Show(); + // Make sure the form is shown. + Show(); // Variable to store the exception, if one is generated, from inside the thread. Exception threadException = null; @@ -140,6 +146,7 @@ namespace Greenshot.Addons.Controls // Wait until finished while (!_waitFor.Join(TimeSpan.FromMilliseconds(100))) { + // TODO: Remove this please!!!! Application.DoEvents(); } Log.Debug().WriteLine("Finished {0}", title); diff --git a/src/Greenshot.Addons/Core/NetworkHelper.cs b/src/Greenshot.Addons/Core/NetworkHelper.cs deleted file mode 100644 index 0a6c9a7d7..000000000 --- a/src/Greenshot.Addons/Core/NetworkHelper.cs +++ /dev/null @@ -1,913 +0,0 @@ -#region Greenshot GNU General Public License - -// Greenshot - a free and open source screenshot tool -// Copyright (C) 2007-2018 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 . - -#endregion - -#region Usings - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Net; -using System.Text; -using System.Text.RegularExpressions; -using Dapplo.Ini; -using Dapplo.Log; -using Greenshot.Addons.Interfaces; -using Greenshot.Addons.Interfaces.Plugin; -using Greenshot.Gfx; - -#endregion - -namespace Greenshot.Addons.Core -{ - /// - /// HTTP Method to make sure we have the correct method - /// - public enum HTTPMethod - { - GET, - POST, - PUT, - DELETE, - HEAD - } - - /// - /// Description of NetworkHelper. - /// - public static class NetworkHelper - { - private static readonly LogSource Log = new LogSource(); - private static readonly ICoreConfiguration Config = IniConfig.Current.Get(); - - static NetworkHelper() - { - try - { - // Disable certificate checking - ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true; - } - catch (Exception ex) - { - Log.Warn().WriteLine(ex, "An error has occured while allowing self-signed certificates:"); - } - } - - /// - /// Download a uri response as string - /// - /// An Uri to specify the download location - /// string with the file content - public static string GetAsString(Uri uri) - { - return GetResponseAsString(CreateWebRequest(uri)); - } - - /// - /// Download the FavIcon as a Bitmap - /// - /// - /// Bitmap with the FavIcon - public static Bitmap DownloadFavIcon(Uri baseUri) - { - var url = new Uri(baseUri, new Uri("favicon.ico")); - try - { - var request = CreateWebRequest(url); - using (var response = (HttpWebResponse) request.GetResponse()) - { - if (request.HaveResponse) - { - using (var responseStream = response.GetResponseStream()) - { - if (responseStream != null) - { - using (var image = BitmapHelper.FromStream(responseStream)) - { - return image.Height > 16 && image.Width > 16 ? new Bitmap(image, 16, 16) : new Bitmap(image); - } - } - } - } - } - } - catch (Exception e) - { - Log.Error().WriteLine(e, "Problem downloading the FavIcon from: " + baseUri); - } - return null; - } - - /// - /// Download the uri into a memorystream, without catching exceptions - /// - /// Of an image - /// MemoryStream which is already seeked to 0 - public static MemoryStream GetAsMemoryStream(string url) - { - var request = CreateWebRequest(url); - using (var response = (HttpWebResponse) request.GetResponse()) - { - var memoryStream = new MemoryStream(); - using (var responseStream = response.GetResponseStream()) - { - responseStream?.CopyTo(memoryStream); - // Make sure it can be used directly - memoryStream.Seek(0, SeekOrigin.Begin); - } - return memoryStream; - } - } - - /// - /// Download the uri to Bitmap - /// - /// Of an image - /// Bitmap - public static Bitmap DownloadBitmap(string url) - { - var extensions = new StringBuilder(); - foreach (var extension in BitmapHelper.StreamConverters.Keys) - { - if (string.IsNullOrEmpty(extension)) - { - continue; - } - extensions.AppendFormat(@"\.{0}|", extension); - } - extensions.Length--; - - var imageUrlRegex = new Regex($@"(http|https)://.*(?{extensions})"); - var match = imageUrlRegex.Match(url); - try - { - using (var memoryStream = GetAsMemoryStream(url)) - { - try - { - return BitmapHelper.FromStream(memoryStream, match.Success ? match.Groups["extension"]?.Value : null); - } - catch (Exception) - { - // If we arrive here, the image loading didn't work, try to see if the response has a http(s) URL to an image and just take this instead. - string content; - using (var streamReader = new StreamReader(memoryStream, Encoding.UTF8, true)) - { - content = streamReader.ReadLine(); - } - if (string.IsNullOrEmpty(content)) - { - throw; - } - match = imageUrlRegex.Match(content); - if (!match.Success) - { - throw; - } - using (var memoryStream2 = GetAsMemoryStream(match.Value)) - { - return BitmapHelper.FromStream(memoryStream2, match.Groups["extension"]?.Value); - } - } - } - } - catch (Exception e) - { - Log.Error().WriteLine(e, "Problem downloading the image from: " + url); - } - return null; - } - - /// - /// Helper method to create a web request with a lot of default settings - /// - /// string with uri to connect to - /// WebRequest - public static HttpWebRequest CreateWebRequest(string uri) - { - return CreateWebRequest(new Uri(uri)); - } - - /// - /// Helper method to create a web request with a lot of default settings - /// - /// string with uri to connect to - /// /// - /// Method to use - /// WebRequest - public static HttpWebRequest CreateWebRequest(string uri, HTTPMethod method) - { - return CreateWebRequest(new Uri(uri), method); - } - - /// - /// Helper method to create a web request with a lot of default settings - /// - /// Uri with uri to connect to - /// Method to use - /// WebRequest - public static HttpWebRequest CreateWebRequest(Uri uri, HTTPMethod method) - { - var webRequest = CreateWebRequest(uri); - webRequest.Method = method.ToString(); - return webRequest; - } - - /// - /// Helper method to create a web request, eventually with proxy - /// - /// Uri with uri to connect to - /// WebRequest - public static HttpWebRequest CreateWebRequest(Uri uri) - { - var webRequest = (HttpWebRequest) WebRequest.Create(uri); - webRequest.Proxy = Config.UseProxy ? CreateProxy(uri) : null; - // Make sure the default credentials are available - webRequest.Credentials = CredentialCache.DefaultCredentials; - - // Allow redirect, this is usually needed so that we don't get a problem when a service moves - webRequest.AllowAutoRedirect = true; - // Set default timeouts - webRequest.Timeout = Config.WebRequestTimeout * 1000; - webRequest.ReadWriteTimeout = Config.WebRequestReadWriteTimeout * 1000; - return webRequest; - } - - /// - /// Create a IWebProxy Object which can be used to access the Internet - /// This method will check the configuration if the proxy is allowed to be used. - /// Usages can be found in the DownloadFavIcon or Jira and Confluence plugins - /// - /// - /// IWebProxy filled with all the proxy details or null if none is set/wanted - public static IWebProxy CreateProxy(Uri uri) - { - if (!Config.UseProxy) - { - return null; - } - - IWebProxy proxyToUse = WebRequest.DefaultWebProxy; - if (proxyToUse != null) - { - proxyToUse.Credentials = CredentialCache.DefaultCredentials; - if (!Log.IsDebugEnabled()) - { - return proxyToUse; - } - - // check the proxy for the Uri - if (!proxyToUse.IsBypassed(uri)) - { - var proxyUri = proxyToUse.GetProxy(uri); - if (proxyUri != null) - { - Log.Debug().WriteLine("Using proxy: " + proxyUri + " for " + uri); - } - else - { - Log.Debug().WriteLine("No proxy found!"); - } - } - else - { - Log.Debug().WriteLine("Proxy bypass for: " + uri); - } - } - else - { - Log.Debug().WriteLine("No proxy found!"); - } - return proxyToUse; - } - - /// - /// UrlEncodes a string without the requirement for System.Web - /// - /// - /// - // [Obsolete("Use System.Uri.EscapeDataString instead")] - public static string UrlEncode(string text) - { - if (string.IsNullOrEmpty(text)) - { - return null; - } - - // Sytem.Uri provides reliable parsing, but doesn't encode spaces. - return Uri.EscapeDataString(text).Replace("%20", "+"); - } - - /// - /// A wrapper around the EscapeDataString, as the limit is 32766 characters - /// See: http://msdn.microsoft.com/en-us/library/system.uri.escapedatastring%28v=vs.110%29.aspx - /// - /// - /// escaped data string - public static string EscapeDataString(string text) - { - if (string.IsNullOrEmpty(text)) - { - return null; - } - - var result = new StringBuilder(); - var currentLocation = 0; - while (currentLocation < text.Length) - { - var process = text.Substring(currentLocation, Math.Min(16384, text.Length - currentLocation)); - result.Append(Uri.EscapeDataString(process)); - currentLocation = currentLocation + 16384; - } - return result.ToString(); - } - - /// - /// UrlDecodes a string without requiring System.Web - /// - /// String to decode. - /// decoded string - public static string UrlDecode(string text) - { - // pre-process for + sign space formatting since System.Uri doesn't handle it - // plus literals are encoded as %2b normally so this should be safe - text = text.Replace("+", " "); - return Uri.UnescapeDataString(text); - } - - /// - /// ParseQueryString without the requirement for System.Web - /// - /// - /// IDictionary string, string - public static IDictionary ParseQueryString(string queryString) - { - IDictionary parameters = new SortedDictionary(); - // remove anything other than query string from uri - if (queryString.Contains("?")) - { - queryString = queryString.Substring(queryString.IndexOf('?') + 1); - } - foreach (var vp in Regex.Split(queryString, "&")) - { - if (string.IsNullOrEmpty(vp)) - { - continue; - } - var singlePair = Regex.Split(vp, "="); - if (parameters.ContainsKey(singlePair[0])) - { - parameters.Remove(singlePair[0]); - } - parameters.Add(singlePair[0], singlePair.Length == 2 ? singlePair[1] : string.Empty); - } - return parameters; - } - - /// - /// Generate the query paramters - /// - /// the list of query parameters - /// a string with the query parameters - public static string GenerateQueryParameters(IDictionary queryParameters) - { - if (queryParameters == null || queryParameters.Count == 0) - { - return string.Empty; - } - - queryParameters = new SortedDictionary(queryParameters); - - var sb = new StringBuilder(); - foreach (var key in queryParameters.Keys) - { - sb.AppendFormat(CultureInfo.InvariantCulture, "{0}={1}&", key, UrlEncode($"{queryParameters[key]}")); - } - sb.Remove(sb.Length - 1, 1); - - return sb.ToString(); - } - - /// - /// Write Multipart Form Data directly to the HttpWebRequest - /// - /// HttpWebRequest to write the multipart form data to - /// Parameters to include in the multipart form data - public static void WriteMultipartFormData(HttpWebRequest webRequest, IDictionary postParameters) - { - string boundary = $"----------{Guid.NewGuid():N}"; - webRequest.ContentType = "multipart/form-data; boundary=" + boundary; - using (var formDataStream = webRequest.GetRequestStream()) - { - WriteMultipartFormData(formDataStream, boundary, postParameters); - } - } - - /// - /// Write Multipart Form Data to the HttpListenerResponse - /// - /// HttpListenerResponse - /// Parameters to include in the multipart form data - public static void WriteMultipartFormData(HttpListenerResponse response, IDictionary postParameters) - { - string boundary = $"----------{Guid.NewGuid():N}"; - response.ContentType = "multipart/form-data; boundary=" + boundary; - WriteMultipartFormData(response.OutputStream, boundary, postParameters); - } - - /// - /// Write Multipart Form Data to a Stream, content-type should be set before this! - /// - /// Stream to write the multipart form data to - /// String boundary for the multipart/form-data - /// Parameters to include in the multipart form data - public static void WriteMultipartFormData(Stream formDataStream, string boundary, IDictionary postParameters) - { - var needsClrf = false; - foreach (var param in postParameters) - { - // Add a CRLF to allow multiple parameters to be added. - // Skip it on the first parameter, add it to subsequent parameters. - if (needsClrf) - { - formDataStream.Write(Encoding.UTF8.GetBytes("\r\n"), 0, Encoding.UTF8.GetByteCount("\r\n")); - } - - needsClrf = true; - - var binaryContainer = param.Value as IBinaryContainer; - if (binaryContainer != null) - { - binaryContainer.WriteFormDataToStream(boundary, param.Key, formDataStream); - } - else - { - string postData = $"--{boundary}\r\nContent-Disposition: form-data; name=\"{param.Key}\"\r\n\r\n{param.Value}"; - formDataStream.Write(Encoding.UTF8.GetBytes(postData), 0, Encoding.UTF8.GetByteCount(postData)); - } - } - - // Add the end of the request. Start with a newline - var footer = "\r\n--" + boundary + "--\r\n"; - formDataStream.Write(Encoding.UTF8.GetBytes(footer), 0, Encoding.UTF8.GetByteCount(footer)); - } - - /// - /// Post the parameters "x-www-form-urlencoded" - /// - /// - /// - public static void UploadFormUrlEncoded(HttpWebRequest webRequest, IDictionary parameters) - { - webRequest.ContentType = "application/x-www-form-urlencoded"; - var urlEncoded = GenerateQueryParameters(parameters); - - var data = Encoding.UTF8.GetBytes(urlEncoded); - using (var requestStream = webRequest.GetRequestStream()) - { - requestStream.Write(data, 0, data.Length); - } - } - - /// - /// Log the headers of the WebResponse, if IsDebugEnabled - /// - /// WebResponse - private static void DebugHeaders(WebResponse response) - { - if (!Log.IsDebugEnabled()) - { - return; - } - Log.Debug().WriteLine("Debug information on the response from {0} :", response.ResponseUri); - foreach (var key in response.Headers.AllKeys) - { - Log.Debug().WriteLine("Reponse-header: {0}={1}", key, response.Headers[key]); - } - } - - /// - /// Process the web response. - /// - /// The request object. - /// The response data. - /// TODO: This method should handle the StatusCode better! - public static string GetResponseAsString(HttpWebRequest webRequest) - { - return GetResponseAsString(webRequest, false); - } - - /// - /// Read the response as string - /// - /// - /// string or null - private static string GetResponseAsString(HttpWebResponse response) - { - if (response == null) - { - return null; - } - using (response) - { - var responseStream = response.GetResponseStream(); - if (responseStream == null) - { - return null; - } - - using (var reader = new StreamReader(responseStream, true)) - { - return reader.ReadToEnd(); - } - } - } - - /// - /// - /// - /// - /// - public static string GetResponseAsString(HttpWebRequest webRequest, bool alsoReturnContentOnError) - { - string responseData = null; - HttpWebResponse response = null; - var isHttpError = false; - try - { - response = (HttpWebResponse) webRequest.GetResponse(); - Log.Info().WriteLine("Response status: {0}", response.StatusCode); - isHttpError = (int) response.StatusCode >= 300; - if (isHttpError) - { - Log.Error().WriteLine("HTTP error {0}", response.StatusCode); - } - DebugHeaders(response); - responseData = GetResponseAsString(response); - if (isHttpError) - { - Log.Error().WriteLine("HTTP response {0}", responseData); - } - } - catch (WebException e) - { - response = (HttpWebResponse) e.Response; - var statusCode = HttpStatusCode.Unused; - if (response != null) - { - statusCode = response.StatusCode; - Log.Error().WriteLine("HTTP error {0}", statusCode); - var errorContent = GetResponseAsString(response); - if (alsoReturnContentOnError) - { - return errorContent; - } - Log.Error().WriteLine("Content: {0}", errorContent); - } - Log.Error().WriteLine(e, "WebException: "); - if (statusCode == HttpStatusCode.Unauthorized) - { - throw new UnauthorizedAccessException(e.Message); - } - throw; - } - finally - { - if (response != null) - { - if (isHttpError) - { - Log.Error().WriteLine("HTTP error {0} with content: {1}", response.StatusCode, responseData); - } - response.Close(); - } - } - return responseData; - } - - /// - /// Get LastModified for a URI - /// - /// Uri - /// DateTime - public static DateTime GetLastModified(Uri uri) - { - try - { - var webRequest = CreateWebRequest(uri); - webRequest.Method = HTTPMethod.HEAD.ToString(); - using (var webResponse = (HttpWebResponse) webRequest.GetResponse()) - { - Log.Debug().WriteLine("RSS feed was updated at {0}", webResponse.LastModified); - return webResponse.LastModified; - } - } - catch (Exception wE) - { - Log.Warn().WriteLine("Problem requesting HTTP - HEAD on uri {0}", uri); - Log.Warn().WriteLine(wE.Message); - // Pretend it is old - return DateTime.MinValue; - } - } - } - - /// - /// This interface can be used to pass binary information around, like byte[] or Image - /// - public interface IBinaryContainer - { - string ContentType { get; } - string Filename { get; set; } - void WriteFormDataToStream(string boundary, string name, Stream formDataStream); - void WriteToStream(Stream formDataStream); - string ToBase64String(Base64FormattingOptions formattingOptions); - byte[] ToByteArray(); - void Upload(HttpWebRequest webRequest); - } - - /// - /// A container to supply files to a Multi-part form data upload - /// - public class ByteContainer : IBinaryContainer - { - private readonly byte[] _file; - private readonly int _fileSize; - - public ByteContainer(byte[] file) : this(file, null) - { - } - - public ByteContainer(byte[] file, string filename) : this(file, filename, null) - { - } - - public ByteContainer(byte[] file, string filename, string contenttype) : this(file, filename, contenttype, 0) - { - } - - public ByteContainer(byte[] file, string filename, string contenttype, int filesize) - { - _file = file; - Filename = filename; - ContentType = contenttype; - _fileSize = filesize == 0 ? file.Length : filesize; - } - - /// - /// Create a Base64String from the byte[] - /// - /// string - public string ToBase64String(Base64FormattingOptions formattingOptions) - { - return Convert.ToBase64String(_file, 0, _fileSize, formattingOptions); - } - - /// - /// Returns the initial byte-array which was supplied when creating the FileParameter - /// - /// byte[] - public byte[] ToByteArray() - { - return _file; - } - - /// - /// Write Multipart Form Data directly to the HttpWebRequest response stream - /// - /// Separator - /// name - /// Stream to write to - public void WriteFormDataToStream(string boundary, string name, Stream formDataStream) - { - // Add just the first part of this param, since we will write the file data directly to the Stream - string header = - $"--{boundary}\r\nContent-Disposition: form-data; name=\"{name}\"; filename=\"{Filename ?? name}\";\r\nContent-Type: {ContentType ?? "application/octet-stream"}\r\n\r\n"; - - formDataStream.Write(Encoding.UTF8.GetBytes(header), 0, Encoding.UTF8.GetByteCount(header)); - - // Write the file data directly to the Stream, rather than serializing it to a string. - formDataStream.Write(_file, 0, _fileSize); - } - - /// - /// A plain "write data to stream" - /// - /// Stream to write to - public void WriteToStream(Stream dataStream) - { - // Write the file data directly to the Stream, rather than serializing it to a string. - dataStream.Write(_file, 0, _fileSize); - } - - /// - /// Upload the file to the webrequest - /// - /// - public void Upload(HttpWebRequest webRequest) - { - webRequest.ContentType = ContentType; - webRequest.ContentLength = _fileSize; - using (var requestStream = webRequest.GetRequestStream()) - { - WriteToStream(requestStream); - } - } - - public string ContentType { get; } - - public string Filename { get; set; } - } - - /// - /// A container to supply images to a Multi-part form data upload - /// - public class BitmapContainer : IBinaryContainer - { - private readonly Bitmap _bitmap; - private readonly SurfaceOutputSettings _outputSettings; - - public BitmapContainer(Bitmap bitmap, SurfaceOutputSettings outputSettings, string filename) - { - _bitmap = bitmap; - _outputSettings = outputSettings; - Filename = filename; - } - - /// - /// Create a Base64String from the image by saving it to a memory stream and converting it. - /// Should be avoided if possible, as this uses a lot of memory. - /// - /// string - public string ToBase64String(Base64FormattingOptions formattingOptions) - { - using (var stream = new MemoryStream()) - { - ImageOutput.SaveToStream(_bitmap, null, stream, _outputSettings); - return Convert.ToBase64String(stream.GetBuffer(), 0, (int) stream.Length, formattingOptions); - } - } - - /// - /// Create a byte[] from the image by saving it to a memory stream. - /// Should be avoided if possible, as this uses a lot of memory. - /// - /// byte[] - public byte[] ToByteArray() - { - using (var stream = new MemoryStream()) - { - ImageOutput.SaveToStream(_bitmap, null, stream, _outputSettings); - return stream.ToArray(); - } - } - - /// - /// Write Multipart Form Data directly to the HttpWebRequest response stream - /// - /// Separator - /// Name of the thing/file - /// Stream to write to - public void WriteFormDataToStream(string boundary, string name, Stream formDataStream) - { - // Add just the first part of this param, since we will write the file data directly to the Stream - string header = $"--{boundary}\r\nContent-Disposition: form-data; name=\"{name}\"; filename=\"{Filename ?? name}\";\r\nContent-Type: {ContentType}\r\n\r\n"; - - formDataStream.Write(Encoding.UTF8.GetBytes(header), 0, Encoding.UTF8.GetByteCount(header)); - ImageOutput.SaveToStream(_bitmap, null, formDataStream, _outputSettings); - } - - /// - /// A plain "write data to stream" - /// - /// - public void WriteToStream(Stream dataStream) - { - // Write the file data directly to the Stream, rather than serializing it to a string. - ImageOutput.SaveToStream(_bitmap, null, dataStream, _outputSettings); - } - - /// - /// Upload the image to the webrequest - /// - /// - public void Upload(HttpWebRequest webRequest) - { - webRequest.ContentType = "image/" + _outputSettings.Format; - using (var requestStream = webRequest.GetRequestStream()) - { - WriteToStream(requestStream); - } - } - - public string ContentType => "image/" + _outputSettings.Format; - - public string Filename { get; set; } - } - - /// - /// A container to supply surfaces to a Multi-part form data upload - /// - public class SurfaceContainer : IBinaryContainer - { - private readonly SurfaceOutputSettings _outputSettings; - private readonly ISurface _surface; - - public SurfaceContainer(ISurface surface, SurfaceOutputSettings outputSettings, string filename) - { - _surface = surface; - _outputSettings = outputSettings; - Filename = filename; - } - - /// - /// Create a Base64String from the Surface by saving it to a memory stream and converting it. - /// Should be avoided if possible, as this uses a lot of memory. - /// - /// string - public string ToBase64String(Base64FormattingOptions formattingOptions) - { - using (var stream = new MemoryStream()) - { - ImageOutput.SaveToStream(_surface, stream, _outputSettings); - return Convert.ToBase64String(stream.GetBuffer(), 0, (int) stream.Length, formattingOptions); - } - } - - /// - /// Create a byte[] from the image by saving it to a memory stream. - /// Should be avoided if possible, as this uses a lot of memory. - /// - /// byte[] - public byte[] ToByteArray() - { - using (var stream = new MemoryStream()) - { - ImageOutput.SaveToStream(_surface, stream, _outputSettings); - return stream.ToArray(); - } - } - - /// - /// Write Multipart Form Data directly to the HttpWebRequest response stream - /// - /// Multipart separator - /// Name of the thing - /// Stream to write to - public void WriteFormDataToStream(string boundary, string name, Stream formDataStream) - { - // Add just the first part of this param, since we will write the file data directly to the Stream - string header = $"--{boundary}\r\nContent-Disposition: form-data; name=\"{name}\"; filename=\"{Filename ?? name}\";\r\nContent-Type: {ContentType}\r\n\r\n"; - - formDataStream.Write(Encoding.UTF8.GetBytes(header), 0, Encoding.UTF8.GetByteCount(header)); - ImageOutput.SaveToStream(_surface, formDataStream, _outputSettings); - } - - /// - /// A plain "write data to stream" - /// - /// - public void WriteToStream(Stream dataStream) - { - // Write the file data directly to the Stream, rather than serializing it to a string. - ImageOutput.SaveToStream(_surface, dataStream, _outputSettings); - } - - /// - /// Upload the Surface as image to the webrequest - /// - /// - public void Upload(HttpWebRequest webRequest) - { - webRequest.ContentType = ContentType; - using (var requestStream = webRequest.GetRequestStream()) - { - WriteToStream(requestStream); - } - } - - public string ContentType => "image/" + _outputSettings.Format; - public string Filename { get; set; } - } -} \ No newline at end of file diff --git a/src/Greenshot.Addons/Greenshot.Addons.csproj b/src/Greenshot.Addons/Greenshot.Addons.csproj index c0f3421a5..8766cf51e 100644 --- a/src/Greenshot.Addons/Greenshot.Addons.csproj +++ b/src/Greenshot.Addons/Greenshot.Addons.csproj @@ -89,38 +89,38 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Clipboard.0.5.60\lib\net46\Dapplo.Windows.Clipboard.dll + + ..\packages\Dapplo.Windows.Clipboard.0.5.61\lib\net46\Dapplo.Windows.Clipboard.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Icons.0.5.60\lib\net46\Dapplo.Windows.Icons.dll + + ..\packages\Dapplo.Windows.Icons.0.5.61\lib\net46\Dapplo.Windows.Icons.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll @@ -307,12 +307,6 @@ Component - - Form - - - OAuthLoginForm.cs - Form @@ -348,7 +342,6 @@ - diff --git a/src/Greenshot.Addons/packages.config b/src/Greenshot.Addons/packages.config index 8da16fdaf..4a24f2931 100644 --- a/src/Greenshot.Addons/packages.config +++ b/src/Greenshot.Addons/packages.config @@ -22,17 +22,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/src/Greenshot.Gfx/Greenshot.Gfx.csproj b/src/Greenshot.Gfx/Greenshot.Gfx.csproj index 79ca7eee7..f5f421596 100644 --- a/src/Greenshot.Gfx/Greenshot.Gfx.csproj +++ b/src/Greenshot.Gfx/Greenshot.Gfx.csproj @@ -64,32 +64,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll diff --git a/src/Greenshot.Gfx/packages.config b/src/Greenshot.Gfx/packages.config index d80c20238..3ff0dea37 100644 --- a/src/Greenshot.Gfx/packages.config +++ b/src/Greenshot.Gfx/packages.config @@ -15,15 +15,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj index eff0f36de..d3f208a14 100644 --- a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj +++ b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj @@ -69,32 +69,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll ..\packages\JeremyAnsel.ColorQuant.1.0.55\lib\net40\JeremyAnsel.ColorQuant.dll diff --git a/src/Greenshot.PerformanceTests/packages.config b/src/Greenshot.PerformanceTests/packages.config index a44e2a44c..cf80f2ce7 100644 --- a/src/Greenshot.PerformanceTests/packages.config +++ b/src/Greenshot.PerformanceTests/packages.config @@ -18,15 +18,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Greenshot.Tests/Greenshot.Tests.csproj b/src/Greenshot.Tests/Greenshot.Tests.csproj index 0e2375274..9eba0e71b 100644 --- a/src/Greenshot.Tests/Greenshot.Tests.csproj +++ b/src/Greenshot.Tests/Greenshot.Tests.csproj @@ -101,32 +101,32 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll ..\packages\Microsoft.CodeAnalysis.Common.2.8.2\lib\netstandard1.3\Microsoft.CodeAnalysis.dll diff --git a/src/Greenshot.Tests/packages.config b/src/Greenshot.Tests/packages.config index f2d218e8f..5b5ee1ac3 100644 --- a/src/Greenshot.Tests/packages.config +++ b/src/Greenshot.Tests/packages.config @@ -20,15 +20,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Greenshot/Components/HotkeyHandler.cs b/src/Greenshot/Components/HotkeyHandler.cs index 683f60353..01c1463da 100644 --- a/src/Greenshot/Components/HotkeyHandler.cs +++ b/src/Greenshot/Components/HotkeyHandler.cs @@ -30,11 +30,11 @@ using Dapplo.Addons; using Dapplo.CaliburnMicro; using Dapplo.Log; using Dapplo.Windows.Common; +using Greenshot.Addons; using Greenshot.Addons.Components; using Greenshot.Addons.Controls; using Greenshot.Addons.Core; using Greenshot.Addons.Interfaces.Plugin; -using Greenshot.Configuration; using Greenshot.Forms; using Greenshot.Helpers; @@ -48,13 +48,18 @@ namespace Greenshot.Components { private static readonly LogSource Log = new LogSource(); private readonly ICoreConfiguration _coreConfiguration; + private readonly IGreenshotLanguage _greenshotLanguage; private readonly WindowHandle _windowHandle; private static HotkeyHandler _instance; - public HotkeyHandler(ICoreConfiguration coreConfiguration, WindowHandle windowHandle) + public HotkeyHandler( + ICoreConfiguration coreConfiguration, + IGreenshotLanguage greenshotLanguage, + WindowHandle windowHandle) { _instance = this; _coreConfiguration = coreConfiguration; + _greenshotLanguage = greenshotLanguage; _windowHandle = windowHandle; } @@ -263,20 +268,21 @@ namespace Greenshot.Components private bool HandleFailedHotkeyRegistration(string failedKeys) { var success = false; - var warningTitle = Language.GetString(LangKey.warning); - var message = string.Format(Language.GetString(LangKey.warning_hotkeys), failedKeys, IsOneDriveBlockingHotkey() ? " (OneDrive)" : ""); - var dr = MessageBox.Show(MainForm.Instance, message, warningTitle, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation); - if (dr == DialogResult.Retry) + var warningTitle = _greenshotLanguage.Warning; + var message = string.Format(_greenshotLanguage.WarningHotkeys, failedKeys, IsOneDriveBlockingHotkey() ? " (OneDrive)" : ""); + var dialogResult = MessageBox.Show(MainForm.Instance, message, warningTitle, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation); + switch (dialogResult) { - Log.Debug().WriteLine("Re-trying to register hotkeys"); - HotkeyControl.UnregisterHotkeys(); - success = RegisterHotkeys(false); - } - else if (dr == DialogResult.Ignore) - { - Log.Debug().WriteLine("Ignoring failed hotkey registration"); - HotkeyControl.UnregisterHotkeys(); - success = RegisterHotkeys(true); + case DialogResult.Retry: + Log.Debug().WriteLine("Re-trying to register hotkeys"); + HotkeyControl.UnregisterHotkeys(); + success = RegisterHotkeys(false); + break; + case DialogResult.Ignore: + Log.Debug().WriteLine("Ignoring failed hotkey registration"); + HotkeyControl.UnregisterHotkeys(); + success = RegisterHotkeys(true); + break; } return success; } diff --git a/src/Greenshot/Forms/MainForm.cs b/src/Greenshot/Forms/MainForm.cs index 1a013f2f1..23b431ad7 100644 --- a/src/Greenshot/Forms/MainForm.cs +++ b/src/Greenshot/Forms/MainForm.cs @@ -74,6 +74,7 @@ namespace Greenshot.Forms private static readonly LogSource Log = new LogSource(); private readonly ICoreConfiguration _coreConfiguration; private readonly IWindowManager _windowManager; + private readonly IGreenshotLanguage _greenshotLanguage; private readonly Func> _configViewModelFactory; private readonly Func> _aboutFormFactory; @@ -95,6 +96,7 @@ namespace Greenshot.Forms { _coreConfiguration = coreConfiguration; _windowManager = windowManager; + _greenshotLanguage = greenshotLanguage; _configViewModelFactory = configViewModelFactory; _aboutFormFactory = aboutFormFactory; _destinationHolder = destinationHolder; @@ -148,8 +150,7 @@ namespace Greenshot.Forms { notifyIcon.BalloonTipClicked += BalloonTipClicked; notifyIcon.BalloonTipClosed += BalloonTipClosed; - notifyIcon.ShowBalloonTip(2000, "Greenshot", - Language.GetFormattedString(LangKey.tooltip_firststart, HotkeyControl.GetLocalizedHotkeyStringFromString(_coreConfiguration.RegionHotkey)), ToolTipIcon.Info); + notifyIcon.ShowBalloonTip(2000, "Greenshot", string.Format(_greenshotLanguage.TooltipFirststart, HotkeyControl.GetLocalizedHotkeyStringFromString(_coreConfiguration.RegionHotkey)), ToolTipIcon.Info); } catch (Exception ex) { @@ -602,7 +603,7 @@ namespace Greenshot.Forms } var allScreensBounds = WindowCapture.GetScreenBounds(); - var captureScreenItem = new ToolStripMenuItem(Language.GetString(LangKey.contextmenu_capturefullscreen_all)); + var captureScreenItem = new ToolStripMenuItem(_greenshotLanguage.ContextmenuCapturefullscreenAll); captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker) (() => CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen))); captureScreenMenuItem.DropDownItems.Add(captureScreenItem); foreach (var screen in Screen.AllScreens) @@ -611,19 +612,19 @@ namespace Greenshot.Forms var deviceAlignment = ""; if (screen.Bounds.Top == allScreensBounds.Top && screen.Bounds.Bottom != allScreensBounds.Bottom) { - deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_top); + deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenTop; } else if (screen.Bounds.Top != allScreensBounds.Top && screen.Bounds.Bottom == allScreensBounds.Bottom) { - deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_bottom); + deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenBottom; } if (screen.Bounds.Left == allScreensBounds.Left && screen.Bounds.Right != allScreensBounds.Right) { - deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_left); + deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenLeft; } else if (screen.Bounds.Left != allScreensBounds.Left && screen.Bounds.Right == allScreensBounds.Right) { - deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_right); + deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenRight; } captureScreenItem = new ToolStripMenuItem(deviceAlignment); captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker) (() => CaptureHelper.CaptureRegion(false, screenToCapture.Bounds))); @@ -903,7 +904,7 @@ namespace Greenshot.Forms // For the capture mousecursor option var captureMouseItem = new ToolStripMenuSelectListItem { - Text = Language.GetString("settings_capture_mousepointer"), + Text = _greenshotLanguage.SettingsCaptureMousepointer, Checked = _coreConfiguration.CaptureMousepointer, CheckOnClick = true }; @@ -917,7 +918,7 @@ namespace Greenshot.Forms // screenshot destination selectList = new ToolStripMenuSelectList("destinations", true) { - Text = Language.GetString(LangKey.settings_destination) + Text = _greenshotLanguage.SettingsDestination }; // Working with IDestination: foreach (var destination in _destinationHolder.SortedActiveDestinations) @@ -933,7 +934,7 @@ namespace Greenshot.Forms // Capture Modes selectList = new ToolStripMenuSelectList("capturemodes", false) { - Text = Language.GetString(LangKey.settings_window_capture_mode) + Text = _greenshotLanguage.SettingsWindowCaptureMode }; var enumTypeName = typeof(WindowCaptureModes).Name; foreach (WindowCaptureModes captureMode in Enum.GetValues(typeof(WindowCaptureModes))) @@ -947,7 +948,7 @@ namespace Greenshot.Forms // print options selectList = new ToolStripMenuSelectList("printoptions", true) { - Text = Language.GetString(LangKey.settings_printoptions) + Text = _greenshotLanguage.SettingsPrintoptions }; foreach (var outputPrintIniValue in _coreConfiguration.GetIniValues().Values.Where(value => value.PropertyName.StartsWith("OutputPrint") && value.ValueType == typeof(bool) && !_coreConfiguration.IsWriteProtected(value.PropertyName))) @@ -967,7 +968,7 @@ namespace Greenshot.Forms // effects selectList = new ToolStripMenuSelectList("effects", true) { - Text = Language.GetString(LangKey.settings_visualization) + Text = _greenshotLanguage.SettingsVisualization }; var iniValue = _coreConfiguration["PlayCameraSound"]; diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj index cd44c7fcd..20770d74e 100644 --- a/src/Greenshot/Greenshot.csproj +++ b/src/Greenshot/Greenshot.csproj @@ -118,41 +118,41 @@ ..\packages\Dapplo.Utils.1.0.158\lib\net45\Dapplo.Utils.dll - - ..\packages\Dapplo.Windows.0.5.60\lib\net46\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.0.5.61\lib\net46\Dapplo.Windows.dll - - ..\packages\Dapplo.Windows.Clipboard.0.5.60\lib\net46\Dapplo.Windows.Clipboard.dll + + ..\packages\Dapplo.Windows.Clipboard.0.5.61\lib\net46\Dapplo.Windows.Clipboard.dll - - ..\packages\Dapplo.Windows.Common.0.5.60\lib\net46\Dapplo.Windows.Common.dll + + ..\packages\Dapplo.Windows.Common.0.5.61\lib\net46\Dapplo.Windows.Common.dll - - ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.60\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll + + ..\packages\Dapplo.Windows.DesktopWindowsManager.0.5.61\lib\net46\Dapplo.Windows.DesktopWindowsManager.dll - - ..\packages\Dapplo.Windows.Dpi.0.5.60\lib\net46\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.Dpi.0.5.61\lib\net46\Dapplo.Windows.Dpi.dll - - ..\packages\Dapplo.Windows.Gdi32.0.5.60\lib\net46\Dapplo.Windows.Gdi32.dll + + ..\packages\Dapplo.Windows.Gdi32.0.5.61\lib\net46\Dapplo.Windows.Gdi32.dll - - ..\packages\Dapplo.Windows.Icons.0.5.60\lib\net46\Dapplo.Windows.Icons.dll + + ..\packages\Dapplo.Windows.Icons.0.5.61\lib\net46\Dapplo.Windows.Icons.dll - - ..\packages\Dapplo.Windows.Input.0.5.60\lib\net46\Dapplo.Windows.Input.dll + + ..\packages\Dapplo.Windows.Input.0.5.61\lib\net46\Dapplo.Windows.Input.dll - - ..\packages\Dapplo.Windows.Kernel32.0.5.60\lib\net46\Dapplo.Windows.Kernel32.dll + + ..\packages\Dapplo.Windows.Kernel32.0.5.61\lib\net46\Dapplo.Windows.Kernel32.dll - - ..\packages\Dapplo.Windows.Messages.0.5.60\lib\net46\Dapplo.Windows.Messages.dll + + ..\packages\Dapplo.Windows.Messages.0.5.61\lib\net46\Dapplo.Windows.Messages.dll - - ..\packages\Dapplo.Windows.Multimedia.0.5.60\lib\net46\Dapplo.Windows.Multimedia.dll + + ..\packages\Dapplo.Windows.Multimedia.0.5.61\lib\net46\Dapplo.Windows.Multimedia.dll - - ..\packages\Dapplo.Windows.User32.0.5.60\lib\net46\Dapplo.Windows.User32.dll + + ..\packages\Dapplo.Windows.User32.0.5.61\lib\net46\Dapplo.Windows.User32.dll ..\packages\gong-wpf-dragdrop.1.1.0\lib\net46\GongSolutions.Wpf.DragDrop.dll diff --git a/src/Greenshot/Help/HelpFileLoader.cs b/src/Greenshot/Help/HelpFileLoader.cs index 9c1b48ec6..6214c9753 100644 --- a/src/Greenshot/Help/HelpFileLoader.cs +++ b/src/Greenshot/Help/HelpFileLoader.cs @@ -23,8 +23,10 @@ #region Usings +using System; using System.Diagnostics; using System.Net; +using Dapplo.HttpExtensions; using Dapplo.Log; using Greenshot.Addons.Core; @@ -99,15 +101,13 @@ namespace Greenshot.Help { try { - var req = NetworkHelper.CreateWebRequest(url); - using (var res = (HttpWebResponse) req.GetResponse()) - { - return res.StatusCode; - } + var uri = new Uri(url); + var head = uri.HeadAsync().Result; + return HttpStatusCode.OK; } - catch (WebException e) + catch (Exception e) { - return ((HttpWebResponse) e.Response)?.StatusCode; + return HttpStatusCode.NotFound; } } } diff --git a/src/Greenshot/packages.config b/src/Greenshot/packages.config index 7a19e69b7..959b7cf67 100644 --- a/src/Greenshot/packages.config +++ b/src/Greenshot/packages.config @@ -31,18 +31,18 @@ - - - - - - - - - - - - + + + + + + + + + + + +