mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Small enhancements to some off the class documentation. Working on performance tests for the screen capture. Updated Dapplo.Windows.
This commit is contained in:
parent
20467f7acf
commit
e1c5ebdba8
38 changed files with 314 additions and 66 deletions
|
@ -49,8 +49,8 @@
|
|||
<PackageReference Include="Dapplo.HttpExtensions" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Dapplo.Confluence" Version="0.8.16" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
<PackageReference Include="Dapplo.HttpExtensions" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
<PackageReference Include="AutoProperties.Fody" Version="1.19.0" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="CliWrap" Version="2.2.0" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -49,8 +49,8 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -49,8 +49,8 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapplo.Windows">
|
||||
<Version>0.8.3</Version>
|
||||
<Version>0.8.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Dapplo.Windows.Com">
|
||||
<Version>0.8.3</Version>
|
||||
<Version>0.8.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Unofficial.Microsoft.mshtml" Version="7.0.3300" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Utils" Version="1.1.9" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Dapplo.Jira" Version="0.8.9" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -136,9 +136,9 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
<PackageReference Include="AutoProperties.Fody" Version="1.19.0" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<PackageReference Include="AutoProperties.Fody" Version="1.19.0" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Interop.Microsoft.Office.Interop.OneNote" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1003" />
|
||||
|
|
|
@ -28,8 +28,13 @@ using Dapplo.Config.Language;
|
|||
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace Greenshot.Addon.OneDrive.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface contains all the translations for the OneDrive addon
|
||||
/// </summary>
|
||||
[Language("OneDrive")]
|
||||
public interface IOneDriveLanguage : ILanguage, INotifyPropertyChanged
|
||||
{
|
||||
|
@ -50,3 +55,5 @@ namespace Greenshot.Addon.OneDrive.Configuration
|
|||
string ResetCredentialsButton { get; }
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
|
@ -25,11 +25,20 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace Greenshot.Addon.OneDrive.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// The request to get a link
|
||||
/// </summary>
|
||||
public class OneDriveGetLinkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of the link which is requested
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public string Type;
|
||||
|
||||
/// <summary>
|
||||
/// Scope of the link
|
||||
/// </summary>
|
||||
[JsonProperty("scope")]
|
||||
public string Scope;
|
||||
}
|
||||
|
|
|
@ -25,18 +25,21 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace Greenshot.Addon.OneDrive.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the response for the "get link" API
|
||||
/// </summary>
|
||||
public class OneDriveGetLinkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID for the response
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
public string Id;
|
||||
|
||||
/// <summary>
|
||||
/// The property for the actual link
|
||||
/// </summary>
|
||||
[JsonProperty("link")]
|
||||
public OneDriveGetLinkResponseLink Link;
|
||||
|
||||
public class OneDriveGetLinkResponseLink
|
||||
{
|
||||
[JsonProperty("webUrl")]
|
||||
public string WebUrl;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Greenshot.Addon.OneDrive.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// The actual link
|
||||
/// </summary>
|
||||
public class OneDriveGetLinkResponseLink
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the value of the link
|
||||
/// </summary>
|
||||
[JsonProperty("webUrl")]
|
||||
public string WebUrl;
|
||||
}
|
||||
}
|
|
@ -25,11 +25,20 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace Greenshot.Addon.OneDrive.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// The response for the upload, only what we need is defined here
|
||||
/// </summary>
|
||||
public class OneDriveUploadResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Id of the response
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
public string Id;
|
||||
|
||||
/// <summary>
|
||||
/// The url
|
||||
/// </summary>
|
||||
[JsonProperty("webUrl")]
|
||||
public string WebUrl;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -34,6 +34,7 @@ using Greenshot.Addons.ViewModels;
|
|||
|
||||
namespace Greenshot.Addon.OneDrive.ViewModels
|
||||
{
|
||||
/// <inherit />
|
||||
public sealed class OneDriveConfigViewModel : SimpleConfigScreen
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -41,11 +42,33 @@ namespace Greenshot.Addon.OneDrive.ViewModels
|
|||
/// </summary>
|
||||
private CompositeDisposable _disposables;
|
||||
|
||||
/// <summary>
|
||||
/// Used in the view to change the configuration
|
||||
/// </summary>
|
||||
public IOneDriveConfiguration OneDriveConfiguration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Used in the view for the translations
|
||||
/// </summary>
|
||||
public IOneDriveLanguage OneDriveLanguage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Used in the view for the translations
|
||||
/// </summary>
|
||||
public IGreenshotLanguage GreenshotLanguage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Used in the view to change the file configuration
|
||||
/// </summary>
|
||||
public FileConfigPartViewModel FileConfigPartViewModel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor used for dependency injection
|
||||
/// </summary>
|
||||
/// <param name="oneDriveConfiguration">IOneDriveConfiguration</param>
|
||||
/// <param name="oneDriveLanguage">IOneDriveLanguage</param>
|
||||
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
|
||||
/// <param name="fileConfigPartViewModel"><FileConfigPartViewModel/param>
|
||||
public OneDriveConfigViewModel(
|
||||
IOneDriveConfiguration oneDriveConfiguration,
|
||||
IOneDriveLanguage oneDriveLanguage,
|
||||
|
@ -58,6 +81,8 @@ namespace Greenshot.Addon.OneDrive.ViewModels
|
|||
GreenshotLanguage = greenshotLanguage;
|
||||
FileConfigPartViewModel = fileConfigPartViewModel;
|
||||
}
|
||||
|
||||
/// <inherit />
|
||||
public override void Initialize(IConfig config)
|
||||
{
|
||||
FileConfigPartViewModel.DestinationFileConfiguration = OneDriveConfiguration;
|
||||
|
@ -78,6 +103,7 @@ namespace Greenshot.Addon.OneDrive.ViewModels
|
|||
base.Initialize(config);
|
||||
}
|
||||
|
||||
/// <inherit />
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
_disposables.Dispose();
|
||||
|
@ -98,6 +124,9 @@ namespace Greenshot.Addon.OneDrive.ViewModels
|
|||
|
||||
public bool CanResetCredentials => OneDriveConfiguration.HasToken();
|
||||
|
||||
/// <summary>
|
||||
/// Used to reset/clear the OAuth credentials
|
||||
/// </summary>
|
||||
public void ResetCredentials()
|
||||
{
|
||||
OneDriveConfiguration.ResetToken();
|
||||
|
|
|
@ -49,8 +49,8 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -61,6 +61,6 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -3,64 +3,83 @@ using Windows.Storage.Streams;
|
|||
|
||||
namespace Greenshot.Addon.Win10
|
||||
{
|
||||
/// <summary>
|
||||
/// This is an IRandomAccessStream implementation which uses a MemoryStream
|
||||
/// </summary>
|
||||
public sealed class MemoryRandomAccessStream : MemoryStream, IRandomAccessStream
|
||||
{
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public MemoryRandomAccessStream()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor where also bytes are already passed
|
||||
/// </summary>
|
||||
/// <param name="bytes">byte array</param>
|
||||
public MemoryRandomAccessStream(byte[] bytes)
|
||||
{
|
||||
Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
public IInputStream GetInputStreamAt(ulong position)
|
||||
/// <inheritdoc />
|
||||
public IInputStream GetInputStreamAt(ulong position)
|
||||
{
|
||||
Seek((long)position, SeekOrigin.Begin);
|
||||
|
||||
return this.AsInputStream();
|
||||
}
|
||||
|
||||
public IOutputStream GetOutputStreamAt(ulong position)
|
||||
/// <inheritdoc />
|
||||
public IOutputStream GetOutputStreamAt(ulong position)
|
||||
{
|
||||
Seek((long)position, SeekOrigin.Begin);
|
||||
|
||||
return this.AsOutputStream();
|
||||
}
|
||||
|
||||
ulong IRandomAccessStream.Position => (ulong)Position;
|
||||
/// <inheritdoc />
|
||||
ulong IRandomAccessStream.Position => (ulong)Position;
|
||||
|
||||
public ulong Size
|
||||
/// <inheritdoc />
|
||||
public ulong Size
|
||||
{
|
||||
get { return (ulong)Length; }
|
||||
set { SetLength((long)value); }
|
||||
}
|
||||
|
||||
public IRandomAccessStream CloneStream()
|
||||
/// <inheritdoc />
|
||||
public IRandomAccessStream CloneStream()
|
||||
{
|
||||
var cloned = new MemoryRandomAccessStream();
|
||||
CopyTo(cloned);
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public void Seek(ulong position)
|
||||
/// <inheritdoc />
|
||||
public void Seek(ulong position)
|
||||
{
|
||||
Seek((long)position, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
public Windows.Foundation.IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
|
||||
/// <inheritdoc />
|
||||
public Windows.Foundation.IAsyncOperationWithProgress<IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options)
|
||||
{
|
||||
var inputStream = GetInputStreamAt(0);
|
||||
return inputStream.ReadAsync(buffer, count, options);
|
||||
}
|
||||
|
||||
Windows.Foundation.IAsyncOperation<bool> IOutputStream.FlushAsync()
|
||||
/// <inheritdoc />
|
||||
Windows.Foundation.IAsyncOperation<bool> IOutputStream.FlushAsync()
|
||||
{
|
||||
var outputStream = GetOutputStreamAt(0);
|
||||
return outputStream.FlushAsync();
|
||||
}
|
||||
|
||||
public Windows.Foundation.IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)
|
||||
/// <inheritdoc />
|
||||
public Windows.Foundation.IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)
|
||||
{
|
||||
var outputStream = GetOutputStreamAt(0);
|
||||
return outputStream.WriteAsync(buffer);
|
||||
|
|
|
@ -38,12 +38,18 @@ namespace Greenshot.Addon.Win10.Native
|
|||
private readonly IDataTransferManagerInterOp _dataTransferManagerInterOp;
|
||||
private readonly IntPtr _windowHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The DataTransferManager
|
||||
/// </summary>
|
||||
public DataTransferManager DataTransferManager
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor which takes a handle to initialize
|
||||
/// </summary>
|
||||
/// <param name="handle"></param>
|
||||
public DataTransferManagerHelper(IntPtr handle)
|
||||
{
|
||||
//TODO: Add a check for failure here. This will fail for versions of Windows below Windows 10
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace Greenshot.Addon.Win10
|
|||
/// <inheritdoc />
|
||||
public class Win10AddonModule : AddonModule
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
if (WindowsVersion.IsWindows10OrLater)
|
||||
|
|
|
@ -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";
|
||||
/// <inheritdoc />
|
||||
public override string Description { get; } = "Windows 10 OCR";
|
||||
|
||||
/// <summary>
|
||||
/// Icon for the OCR function, the icon was found via: http://help4windows.com/windows_8_imageres_dll.shtml
|
||||
|
|
|
@ -54,6 +54,12 @@ namespace Greenshot.Addon.Win10
|
|||
private readonly ExportNotification _exportNotification;
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor used for dependency injection
|
||||
/// </summary>
|
||||
/// <param name="coreConfiguration">ICoreConfiguration</param>
|
||||
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
|
||||
/// <param name="exportNotification">ExportNotification</param>
|
||||
public Win10ShareDestination(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
|
@ -62,7 +68,8 @@ namespace Greenshot.Addon.Win10
|
|||
_exportNotification = exportNotification;
|
||||
}
|
||||
|
||||
public override string Description { get; } = "Windows 10 share";
|
||||
/// <inheritdoc />
|
||||
public override string Description { get; } = "Windows 10 share";
|
||||
|
||||
/// <summary>
|
||||
/// Icon for the App-share, the icon was found via: http://help4windows.com/windows_8_shell32_dll.shtml
|
||||
|
|
|
@ -62,10 +62,10 @@
|
|||
<Version>0.9.18</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard">
|
||||
<Version>0.8.3</Version>
|
||||
<Version>0.8.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Dapplo.Windows.Icons">
|
||||
<Version>0.8.3</Version>
|
||||
<Version>0.8.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
@ -75,7 +75,7 @@
|
|||
<Version>3.0.0-alpha0096</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Svg">
|
||||
<Version>2.3.0</Version>
|
||||
<Version>2.4.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapplo.Windows.Icons">
|
||||
<Version>0.8.3</Version>
|
||||
<Version>0.8.7</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<Version>4.5.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Memory">
|
||||
<Version>4.5.1</Version>
|
||||
<Version>4.5.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Numerics.Vectors">
|
||||
<Version>4.5.0</Version>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<Version>1.2.19</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Svg">
|
||||
<Version>2.3.0</Version>
|
||||
<Version>2.4.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
103
src/Greenshot.PerformanceTests/Capture/ScreenCapture.cs
Normal file
103
src/Greenshot.PerformanceTests/Capture/ScreenCapture.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
{
|
||||
/// <summary>
|
||||
/// The screen Capture code
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,8 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.1" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.2" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -78,6 +78,7 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
|
||||
<PackageReference Include="xunit.analyzers" Version="0.10.0" />
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
<ApplicationManifest>greenshot.manifest</ApplicationManifest>
|
||||
<AssemblyTitle>Greenshot</AssemblyTitle>
|
||||
<AssemblyName>Greenshot</AssemblyName>
|
||||
<!--RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained-->
|
||||
<Platforms>AnyCPU;x86</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -91,16 +88,16 @@
|
|||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||
<PackageReference Include="Dapplo.Log.LogFile" Version="1.3.11" />
|
||||
<PackageReference Include="Dapplo.Log.Loggers" Version="1.3.11" />
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.3" />
|
||||
<PackageReference Include="Dapplo.Windows.Multimedia" Version="0.8.3" />
|
||||
<PackageReference Include="Fody" Version="3.3.5">
|
||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.7" />
|
||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.7" />
|
||||
<PackageReference Include="Dapplo.Windows.Multimedia" Version="0.8.7" />
|
||||
<PackageReference Include="Fody" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="2.0.0-alpha0106" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.0.0-alpha0096" />
|
||||
<PackageReference Include="Svg" Version="2.3.0" />
|
||||
<PackageReference Include="Svg" Version="2.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue