From e1c5ebdba84735f7b92e8682b57919b07c8ac48b Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 14 Jan 2019 10:35:14 +0100 Subject: [PATCH] Small enhancements to some off the class documentation. Working on performance tests for the screen capture. Updated Dapplo.Windows. --- .../Greenshot.Addon.Box.csproj | 4 +- .../Greenshot.Addon.Confluence.csproj | 2 +- .../Greenshot.Addon.Dropbox.csproj | 4 +- .../Greenshot.Addon.ExternalCommand.csproj | 4 +- .../Greenshot.Addon.Flickr.csproj | 4 +- .../Greenshot.Addon.GooglePhotos.csproj | 4 +- .../Greenshot.Addon.Imgur.csproj | 4 +- .../Greenshot.Addon.InternetExplorer.csproj | 4 +- .../Greenshot.Addon.Jira.csproj | 2 +- .../Greenshot.Addon.LegacyEditor.csproj | 6 +- .../Greenshot.Addon.Lutim.csproj | 2 +- .../Greenshot.Addon.OCR.csproj | 4 +- .../Greenshot.Addon.Office.csproj | 2 +- .../Configuration/IOneDriveLanguage.cs | 9 +- .../Entities/OneDriveGetLinkRequest.cs | 9 ++ .../Entities/OneDriveGetLinkResponse.cs | 15 ++- .../Entities/OneDriveGetLinkResponseLink.cs | 39 +++++++ .../Entities/OneDriveUploadResponse.cs | 9 ++ .../Greenshot.Addon.OneDrive.csproj | 2 +- .../ViewModels/OneDriveConfigViewModel.cs | 31 +++++- .../Greenshot.Addon.Photobucket.csproj | 4 +- .../Greenshot.Addon.Tfs.csproj | 2 +- .../Greenshot.Addon.Win10.csproj | 2 +- .../MemoryRandomAccessStream.cs | 37 +++++-- .../Native/DataTransferManagerHelper.cs | 8 +- src/Greenshot.Addon.Win10/Win10AddonModule.cs | 1 + .../Win10OcrDestination.cs | 3 +- .../Win10ShareDestination.cs | 9 +- src/Greenshot.Addons/Greenshot.Addons.csproj | 6 +- src/Greenshot.Core/Greenshot.Core.csproj | 2 +- .../Greenshot.Gfx.Experimental.csproj | 2 +- src/Greenshot.Gfx/Greenshot.Gfx.csproj | 2 +- .../Capture/ScreenCapture.cs | 103 ++++++++++++++++++ .../CapturePerformance.cs | 18 ++- .../Greenshot.PerformanceTests.csproj | 3 +- src/Greenshot.Tests/Greenshot.Tests.csproj | 1 + src/Greenshot.sln | 4 +- src/Greenshot/Greenshot.csproj | 13 +-- 38 files changed, 314 insertions(+), 66 deletions(-) create mode 100644 src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponseLink.cs create mode 100644 src/Greenshot.PerformanceTests/Capture/ScreenCapture.cs diff --git a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj index 1b70fe12e..1b60c85fe 100644 --- a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj +++ b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj @@ -49,8 +49,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj index 2f918bc42..5592695a7 100644 --- a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj +++ b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj @@ -55,7 +55,7 @@ - + all diff --git a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj index 709463db2..999e0a62e 100644 --- a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj +++ b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj @@ -51,8 +51,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj index e782bdad0..c7488ffdf 100644 --- a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj +++ b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj @@ -40,9 +40,9 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj index 39310dd89..4e4f9d6c5 100644 --- a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj +++ b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj @@ -49,8 +49,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj index 112c2a3cf..abd5a2c25 100644 --- a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj +++ b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj @@ -49,8 +49,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj index 83082750a..5d14503e8 100644 --- a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj +++ b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj @@ -50,8 +50,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj b/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj index 5ac50dae8..7943b4979 100644 --- a/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj +++ b/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj @@ -30,10 +30,10 @@ - 0.8.3 + 0.8.7 - 0.8.3 + 0.8.7 diff --git a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj index 9f83e1477..498840c81 100644 --- a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj +++ b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj @@ -53,7 +53,7 @@ - + all diff --git a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj index a6a552ec8..5d12de714 100644 --- a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj +++ b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj @@ -136,9 +136,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj index c64d6ee66..cdac568ad 100644 --- a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj +++ b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj @@ -50,7 +50,7 @@ - + all diff --git a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj index b9bf28d8c..a095b8f6b 100644 --- a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj +++ b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj @@ -40,8 +40,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj index d6bdf952e..43f3b9d13 100644 --- a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj +++ b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj @@ -40,7 +40,7 @@ - + diff --git a/src/Greenshot.Addon.OneDrive/Configuration/IOneDriveLanguage.cs b/src/Greenshot.Addon.OneDrive/Configuration/IOneDriveLanguage.cs index 377bfd237..629025ae9 100644 --- a/src/Greenshot.Addon.OneDrive/Configuration/IOneDriveLanguage.cs +++ b/src/Greenshot.Addon.OneDrive/Configuration/IOneDriveLanguage.cs @@ -28,8 +28,13 @@ using Dapplo.Config.Language; #endregion +#pragma warning disable 1591 + namespace Greenshot.Addon.OneDrive.Configuration { + /// + /// This interface contains all the translations for the OneDrive addon + /// [Language("OneDrive")] public interface IOneDriveLanguage : ILanguage, INotifyPropertyChanged { @@ -49,4 +54,6 @@ namespace Greenshot.Addon.OneDrive.Configuration string ResetCredentialsButton { get; } } -} \ No newline at end of file +} + +#pragma warning restore 1591 \ No newline at end of file diff --git a/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkRequest.cs b/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkRequest.cs index 3c76bcc38..60e12f9f6 100644 --- a/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkRequest.cs +++ b/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkRequest.cs @@ -25,11 +25,20 @@ using Newtonsoft.Json; namespace Greenshot.Addon.OneDrive.Entities { + /// + /// The request to get a link + /// public class OneDriveGetLinkRequest { + /// + /// The type of the link which is requested + /// [JsonProperty("type")] public string Type; + /// + /// Scope of the link + /// [JsonProperty("scope")] public string Scope; } diff --git a/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponse.cs b/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponse.cs index ea13dc655..e6841ccbe 100644 --- a/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponse.cs +++ b/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponse.cs @@ -25,18 +25,21 @@ using Newtonsoft.Json; namespace Greenshot.Addon.OneDrive.Entities { + /// + /// This is the response for the "get link" API + /// public class OneDriveGetLinkResponse { + /// + /// The ID for the response + /// [JsonProperty("id")] public string Id; + /// + /// The property for the actual link + /// [JsonProperty("link")] public OneDriveGetLinkResponseLink Link; - - public class OneDriveGetLinkResponseLink - { - [JsonProperty("webUrl")] - public string WebUrl; - } } } \ No newline at end of file diff --git a/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponseLink.cs b/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponseLink.cs new file mode 100644 index 000000000..a08a647ea --- /dev/null +++ b/src/Greenshot.Addon.OneDrive/Entities/OneDriveGetLinkResponseLink.cs @@ -0,0 +1,39 @@ +#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 + +using Newtonsoft.Json; + +namespace Greenshot.Addon.OneDrive.Entities +{ + /// + /// The actual link + /// + public class OneDriveGetLinkResponseLink + { + /// + /// This is the value of the link + /// + [JsonProperty("webUrl")] + public string WebUrl; + } +} \ No newline at end of file diff --git a/src/Greenshot.Addon.OneDrive/Entities/OneDriveUploadResponse.cs b/src/Greenshot.Addon.OneDrive/Entities/OneDriveUploadResponse.cs index 464abad8b..e52c4fa5b 100644 --- a/src/Greenshot.Addon.OneDrive/Entities/OneDriveUploadResponse.cs +++ b/src/Greenshot.Addon.OneDrive/Entities/OneDriveUploadResponse.cs @@ -25,11 +25,20 @@ using Newtonsoft.Json; namespace Greenshot.Addon.OneDrive.Entities { + /// + /// The response for the upload, only what we need is defined here + /// public class OneDriveUploadResponse { + /// + /// Id of the response + /// [JsonProperty("id")] public string Id; + /// + /// The url + /// [JsonProperty("webUrl")] public string WebUrl; } diff --git a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj index 3aa1032fc..1c47a2a49 100644 --- a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj +++ b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj @@ -50,7 +50,7 @@ - + all diff --git a/src/Greenshot.Addon.OneDrive/ViewModels/OneDriveConfigViewModel.cs b/src/Greenshot.Addon.OneDrive/ViewModels/OneDriveConfigViewModel.cs index f17d0c7e0..c0ee54642 100644 --- a/src/Greenshot.Addon.OneDrive/ViewModels/OneDriveConfigViewModel.cs +++ b/src/Greenshot.Addon.OneDrive/ViewModels/OneDriveConfigViewModel.cs @@ -34,6 +34,7 @@ using Greenshot.Addons.ViewModels; namespace Greenshot.Addon.OneDrive.ViewModels { + /// public sealed class OneDriveConfigViewModel : SimpleConfigScreen { /// @@ -41,11 +42,33 @@ namespace Greenshot.Addon.OneDrive.ViewModels /// private CompositeDisposable _disposables; + /// + /// Used in the view to change the configuration + /// public IOneDriveConfiguration OneDriveConfiguration { get; } - public IOneDriveLanguage OneDriveLanguage { get; } + + /// + /// Used in the view for the translations + /// + public IOneDriveLanguage OneDriveLanguage { get; } + + /// + /// Used in the view for the translations + /// public IGreenshotLanguage GreenshotLanguage { get; } + + /// + /// Used in the view to change the file configuration + /// public FileConfigPartViewModel FileConfigPartViewModel { get; } + /// + /// Constructor used for dependency injection + /// + /// IOneDriveConfiguration + /// IOneDriveLanguage + /// IGreenshotLanguage + /// public OneDriveConfigViewModel( IOneDriveConfiguration oneDriveConfiguration, IOneDriveLanguage oneDriveLanguage, @@ -58,6 +81,8 @@ namespace Greenshot.Addon.OneDrive.ViewModels GreenshotLanguage = greenshotLanguage; FileConfigPartViewModel = fileConfigPartViewModel; } + + /// public override void Initialize(IConfig config) { FileConfigPartViewModel.DestinationFileConfiguration = OneDriveConfiguration; @@ -78,6 +103,7 @@ namespace Greenshot.Addon.OneDrive.ViewModels base.Initialize(config); } + /// protected override void OnDeactivate(bool close) { _disposables.Dispose(); @@ -98,6 +124,9 @@ namespace Greenshot.Addon.OneDrive.ViewModels public bool CanResetCredentials => OneDriveConfiguration.HasToken(); + /// + /// Used to reset/clear the OAuth credentials + /// public void ResetCredentials() { OneDriveConfiguration.ResetToken(); diff --git a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj index 70d1bd7d6..c90485e7b 100644 --- a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj +++ b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj @@ -49,8 +49,8 @@ - - + + all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj index a6884cfc0..50060589a 100644 --- a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj +++ b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj @@ -50,7 +50,7 @@ - + all diff --git a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj index 4dee2c9b8..603db5808 100644 --- a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj +++ b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj @@ -61,6 +61,6 @@ - + \ No newline at end of file diff --git a/src/Greenshot.Addon.Win10/MemoryRandomAccessStream.cs b/src/Greenshot.Addon.Win10/MemoryRandomAccessStream.cs index 15997d69f..c763f0311 100644 --- a/src/Greenshot.Addon.Win10/MemoryRandomAccessStream.cs +++ b/src/Greenshot.Addon.Win10/MemoryRandomAccessStream.cs @@ -3,64 +3,83 @@ using Windows.Storage.Streams; namespace Greenshot.Addon.Win10 { + /// + /// This is an IRandomAccessStream implementation which uses a MemoryStream + /// public sealed class MemoryRandomAccessStream : MemoryStream, IRandomAccessStream { + /// + /// Default constructor + /// public MemoryRandomAccessStream() { } + /// + /// Constructor where also bytes are already passed + /// + /// byte array public MemoryRandomAccessStream(byte[] bytes) { Write(bytes, 0, bytes.Length); } - public IInputStream GetInputStreamAt(ulong position) + /// + public IInputStream GetInputStreamAt(ulong position) { Seek((long)position, SeekOrigin.Begin); return this.AsInputStream(); } - public IOutputStream GetOutputStreamAt(ulong position) + /// + public IOutputStream GetOutputStreamAt(ulong position) { Seek((long)position, SeekOrigin.Begin); return this.AsOutputStream(); } - ulong IRandomAccessStream.Position => (ulong)Position; + /// + ulong IRandomAccessStream.Position => (ulong)Position; - public ulong Size + /// + public ulong Size { get { return (ulong)Length; } set { SetLength((long)value); } } - public IRandomAccessStream CloneStream() + /// + public IRandomAccessStream CloneStream() { var cloned = new MemoryRandomAccessStream(); CopyTo(cloned); return cloned; } - public void Seek(ulong position) + /// + public void Seek(ulong position) { Seek((long)position, SeekOrigin.Begin); } - public Windows.Foundation.IAsyncOperationWithProgress ReadAsync(IBuffer buffer, uint count, InputStreamOptions options) + /// + public Windows.Foundation.IAsyncOperationWithProgress ReadAsync(IBuffer buffer, uint count, InputStreamOptions options) { var inputStream = GetInputStreamAt(0); return inputStream.ReadAsync(buffer, count, options); } - Windows.Foundation.IAsyncOperation IOutputStream.FlushAsync() + /// + Windows.Foundation.IAsyncOperation IOutputStream.FlushAsync() { var outputStream = GetOutputStreamAt(0); return outputStream.FlushAsync(); } - public Windows.Foundation.IAsyncOperationWithProgress WriteAsync(IBuffer buffer) + /// + public Windows.Foundation.IAsyncOperationWithProgress WriteAsync(IBuffer buffer) { var outputStream = GetOutputStreamAt(0); return outputStream.WriteAsync(buffer); diff --git a/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs b/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs index db8865784..a3437df72 100644 --- a/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs +++ b/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs @@ -38,12 +38,18 @@ namespace Greenshot.Addon.Win10.Native private readonly IDataTransferManagerInterOp _dataTransferManagerInterOp; private readonly IntPtr _windowHandle; + /// + /// The DataTransferManager + /// public DataTransferManager DataTransferManager { get; private set; } - + /// + /// Constructor which takes a handle to initialize + /// + /// public DataTransferManagerHelper(IntPtr handle) { //TODO: Add a check for failure here. This will fail for versions of Windows below Windows 10 diff --git a/src/Greenshot.Addon.Win10/Win10AddonModule.cs b/src/Greenshot.Addon.Win10/Win10AddonModule.cs index 084183f0a..52c579500 100644 --- a/src/Greenshot.Addon.Win10/Win10AddonModule.cs +++ b/src/Greenshot.Addon.Win10/Win10AddonModule.cs @@ -30,6 +30,7 @@ namespace Greenshot.Addon.Win10 /// public class Win10AddonModule : AddonModule { + /// protected override void Load(ContainerBuilder builder) { if (WindowsVersion.IsWindows10OrLater) diff --git a/src/Greenshot.Addon.Win10/Win10OcrDestination.cs b/src/Greenshot.Addon.Win10/Win10OcrDestination.cs index 44f6d7b8b..3df6140ab 100644 --- a/src/Greenshot.Addon.Win10/Win10OcrDestination.cs +++ b/src/Greenshot.Addon.Win10/Win10OcrDestination.cs @@ -44,7 +44,8 @@ namespace Greenshot.Addon.Win10 private readonly ExportNotification _exportNotification; private static readonly LogSource Log = new LogSource(); - public override string Description { get; } = "Windows 10 OCR"; + /// + public override string Description { get; } = "Windows 10 OCR"; /// /// Icon for the OCR function, the icon was found via: http://help4windows.com/windows_8_imageres_dll.shtml diff --git a/src/Greenshot.Addon.Win10/Win10ShareDestination.cs b/src/Greenshot.Addon.Win10/Win10ShareDestination.cs index 57e00cbc8..1279a66b7 100644 --- a/src/Greenshot.Addon.Win10/Win10ShareDestination.cs +++ b/src/Greenshot.Addon.Win10/Win10ShareDestination.cs @@ -54,6 +54,12 @@ namespace Greenshot.Addon.Win10 private readonly ExportNotification _exportNotification; private static readonly LogSource Log = new LogSource(); + /// + /// Default constructor used for dependency injection + /// + /// ICoreConfiguration + /// IGreenshotLanguage + /// ExportNotification public Win10ShareDestination( ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotLanguage, @@ -62,7 +68,8 @@ namespace Greenshot.Addon.Win10 _exportNotification = exportNotification; } - public override string Description { get; } = "Windows 10 share"; + /// + public override string Description { get; } = "Windows 10 share"; /// /// Icon for the App-share, the icon was found via: http://help4windows.com/windows_8_shell32_dll.shtml diff --git a/src/Greenshot.Addons/Greenshot.Addons.csproj b/src/Greenshot.Addons/Greenshot.Addons.csproj index 8c47e1c4b..627830466 100644 --- a/src/Greenshot.Addons/Greenshot.Addons.csproj +++ b/src/Greenshot.Addons/Greenshot.Addons.csproj @@ -62,10 +62,10 @@ 0.9.18 - 0.8.3 + 0.8.7 - 0.8.3 + 0.8.7 all @@ -75,7 +75,7 @@ 3.0.0-alpha0096 - 2.3.0 + 2.4.0 diff --git a/src/Greenshot.Core/Greenshot.Core.csproj b/src/Greenshot.Core/Greenshot.Core.csproj index ba95a1421..a3e2a37ec 100644 --- a/src/Greenshot.Core/Greenshot.Core.csproj +++ b/src/Greenshot.Core/Greenshot.Core.csproj @@ -29,7 +29,7 @@ - 0.8.3 + 0.8.7 diff --git a/src/Greenshot.Gfx.Experimental/Greenshot.Gfx.Experimental.csproj b/src/Greenshot.Gfx.Experimental/Greenshot.Gfx.Experimental.csproj index d991ba5e9..065c6f372 100644 --- a/src/Greenshot.Gfx.Experimental/Greenshot.Gfx.Experimental.csproj +++ b/src/Greenshot.Gfx.Experimental/Greenshot.Gfx.Experimental.csproj @@ -36,7 +36,7 @@ 4.5.0 - 4.5.1 + 4.5.2 4.5.0 diff --git a/src/Greenshot.Gfx/Greenshot.Gfx.csproj b/src/Greenshot.Gfx/Greenshot.Gfx.csproj index 5e1e507e1..61f859ded 100644 --- a/src/Greenshot.Gfx/Greenshot.Gfx.csproj +++ b/src/Greenshot.Gfx/Greenshot.Gfx.csproj @@ -32,7 +32,7 @@ 1.2.19 - 2.3.0 + 2.4.0 diff --git a/src/Greenshot.PerformanceTests/Capture/ScreenCapture.cs b/src/Greenshot.PerformanceTests/Capture/ScreenCapture.cs new file mode 100644 index 000000000..7343ee378 --- /dev/null +++ b/src/Greenshot.PerformanceTests/Capture/ScreenCapture.cs @@ -0,0 +1,103 @@ +#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.Diagnostics; +using System.Drawing; +using System.Drawing.Imaging; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Forms; +using System.Windows.Interop; +using System.Windows.Media.Imaging; +using Dapplo.Log; +using Dapplo.Windows.Common; +using Dapplo.Windows.Common.Extensions; +using Dapplo.Windows.Common.Structs; +using Dapplo.Windows.Gdi32; +using Dapplo.Windows.Gdi32.Enums; +using Dapplo.Windows.Gdi32.SafeHandles; +using Dapplo.Windows.Gdi32.Structs; +using Dapplo.Windows.Icons; +using Dapplo.Windows.User32; +using Dapplo.Windows.User32.Enums; +using Dapplo.Windows.User32.Structs; +using Greenshot.Addons.Config.Impl; +using Greenshot.Addons.Interfaces; +using Greenshot.Gfx; + +#endregion + +namespace Greenshot.Addons.Core +{ + /// + /// The screen Capture code + /// + public class ScreenCapture : IDisposable + { + private static readonly LogSource Log = new LogSource(); + private readonly ICoreConfiguration _coreConfiguration; + private readonly NativeRect _captureBounds; + private readonly SafeWindowDcHandle _desktopDcHandle; + private readonly SafeCompatibleDcHandle _safeCompatibleDcHandle; + private readonly BitmapInfoHeader _bitmapInfoHeader; + private readonly SafeDibSectionHandle _safeDibSectionHandle; + private readonly SafeSelectObjectHandle _safeSelectObjectHandle; + + public ScreenCapture(ICoreConfiguration coreConfiguration, NativeRect captureBounds) + { + _coreConfiguration = coreConfiguration; + _captureBounds = captureBounds; + _desktopDcHandle = SafeWindowDcHandle.FromDesktop(); + _safeCompatibleDcHandle = Gdi32Api.CreateCompatibleDC(_desktopDcHandle); + // Create BitmapInfoHeader for CreateDIBSection + _bitmapInfoHeader = BitmapInfoHeader.Create(captureBounds.Width, captureBounds.Height, 24); + + _safeDibSectionHandle = Gdi32Api.CreateDIBSection(_desktopDcHandle, ref _bitmapInfoHeader, DibColors.PalColors, out _, IntPtr.Zero, 0); + + // select the bitmap object and store the old handle + _safeSelectObjectHandle = _safeCompatibleDcHandle.SelectObject(_safeDibSectionHandle); + } + + public void CaptureFrame() + { + // bit-blt over (make copy) + // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags + Gdi32Api.BitBlt(_safeCompatibleDcHandle, 0, 0, _captureBounds.Width, _captureBounds.Height, _desktopDcHandle, _captureBounds.X, _captureBounds.Y, + RasterOperations.SourceCopy | RasterOperations.CaptureBlt); + + //return Imaging.CreateBitmapSourceFromHBitmap(_safeDibSectionHandle.DangerousGetHandle(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); + } + + public void Dispose() + { + _safeSelectObjectHandle.Dispose(); + _safeDibSectionHandle.Dispose(); + _safeCompatibleDcHandle.Dispose(); + _desktopDcHandle.Dispose(); + } + } +} \ No newline at end of file diff --git a/src/Greenshot.PerformanceTests/CapturePerformance.cs b/src/Greenshot.PerformanceTests/CapturePerformance.cs index dd2afb506..11100b64f 100644 --- a/src/Greenshot.PerformanceTests/CapturePerformance.cs +++ b/src/Greenshot.PerformanceTests/CapturePerformance.cs @@ -1,5 +1,6 @@ using System; using BenchmarkDotNet.Attributes; +using Dapplo.Windows.User32; using Greenshot.Addons.Core; namespace Greenshot.PerformanceTests @@ -10,7 +11,9 @@ namespace Greenshot.PerformanceTests [MinColumn, MaxColumn, MemoryDiagnoser] public class CapturePerformance { - [Benchmark] + private readonly ScreenCapture _screenCapture = new ScreenCapture(null, DisplayInfo.ScreenBounds); + + //[Benchmark] public void Capture() { using (var capture = WindowCapture.CaptureScreen()) @@ -25,5 +28,18 @@ namespace Greenshot.PerformanceTests } } } + + + [Benchmark] + public void CaptureBuffered() + { + _screenCapture.CaptureFrame(); + } + + [GlobalCleanup] + public void Cleanup() + { + _screenCapture.Dispose(); + } } } diff --git a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj index 53d92bab8..669a15a65 100644 --- a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj +++ b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj @@ -66,7 +66,8 @@ - + + \ No newline at end of file diff --git a/src/Greenshot.Tests/Greenshot.Tests.csproj b/src/Greenshot.Tests/Greenshot.Tests.csproj index 4d01ed21d..2857b603f 100644 --- a/src/Greenshot.Tests/Greenshot.Tests.csproj +++ b/src/Greenshot.Tests/Greenshot.Tests.csproj @@ -78,6 +78,7 @@ + diff --git a/src/Greenshot.sln b/src/Greenshot.sln index 3484b8c5b..d60b67bac 100644 --- a/src/Greenshot.sln +++ b/src/Greenshot.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2027 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28407.52 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot", "Greenshot\Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}" EndProject diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj index fc8eccad6..89eeaf85f 100644 --- a/src/Greenshot/Greenshot.csproj +++ b/src/Greenshot/Greenshot.csproj @@ -9,9 +9,6 @@ greenshot.manifest Greenshot Greenshot - - AnyCPU;x86 @@ -91,16 +88,16 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers - +