Added the Windows 10 addon, both OCR and Sharing, for dotnet core 3.0

This commit is contained in:
Robin 2018-11-25 15:04:01 +01:00
commit d736de4add
4 changed files with 15 additions and 5 deletions

View file

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<RootNamespace>Greenshot.Addon.Win10</RootNamespace> <RootNamespace>Greenshot.Addon.Win10</RootNamespace>
<AssemblyName>Greenshot.Addon.Win10</AssemblyName> <AssemblyName>Greenshot.Addon.Win10</AssemblyName>
<TargetFrameworks>net471</TargetFrameworks> <TargetFrameworks>netcoreapp3.0;net471</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -12,6 +12,13 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.3.0" />
<Reference Include="Windows">
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net471'"> <ItemGroup Condition="'$(TargetFramework)' == 'net471'">
<!-- Light up Windows 10 features --> <!-- Light up Windows 10 features -->
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">

View file

@ -79,7 +79,7 @@ namespace Greenshot.Addon.Win10
public bool IsDestroyed { get; set; } public bool IsDestroyed { get; set; }
public bool IsShareCompleted { get; set; } public bool IsShareCompleted { get; set; }
public TaskCompletionSource<bool> ShareTask { get; } = new TaskCompletionSource<bool>(); public TaskCompletionSource<bool> ShareTask { get; } = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
public bool IsDataRequested { get; set; } public bool IsDataRequested { get; set; }
} }
@ -90,7 +90,7 @@ namespace Greenshot.Addon.Win10
/// <param name="surface"></param> /// <param name="surface"></param>
/// <param name="captureDetails"></param> /// <param name="captureDetails"></param>
/// <returns>ExportInformation</returns> /// <returns>ExportInformation</returns>
protected override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) public override async Task<ExportInformation> ExportCaptureAsync(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{ {
var exportInformation = new ExportInformation(Designation, Description); var exportInformation = new ExportInformation(Designation, Description);
try try
@ -121,7 +121,7 @@ namespace Greenshot.Addon.Win10
}); });
var windowHandle = new WindowInteropHelper(triggerWindow).Handle; var windowHandle = new WindowInteropHelper(triggerWindow).Handle;
Share(shareInfo, windowHandle, surface, captureDetails).Wait(); await Share(shareInfo, windowHandle, surface, captureDetails);
Log.Debug().WriteLine("Sharing finished, closing window."); Log.Debug().WriteLine("Sharing finished, closing window.");
triggerWindow.Close(); triggerWindow.Close();
if (string.IsNullOrWhiteSpace(shareInfo.ApplicationName)) if (string.IsNullOrWhiteSpace(shareInfo.ApplicationName))
@ -216,6 +216,7 @@ namespace Greenshot.Addon.Win10
} }
// Signal that the stream is ready // Signal that the stream is ready
streamedFileDataRequest.Dispose(); streamedFileDataRequest.Dispose();
shareInfo.ShareTask.TrySetResult(true);
} }
catch (Exception) catch (Exception)
{ {

View file

@ -120,9 +120,9 @@
<ProjectReference Include="..\Greenshot.Addon.OneDrive\Greenshot.Addon.OneDrive.csproj" /> <ProjectReference Include="..\Greenshot.Addon.OneDrive\Greenshot.Addon.OneDrive.csproj" />
<ProjectReference Include="..\Greenshot.Addon.Photobucket\Greenshot.Addon.Photobucket.csproj" /> <ProjectReference Include="..\Greenshot.Addon.Photobucket\Greenshot.Addon.Photobucket.csproj" />
<ProjectReference Include="..\Greenshot.Addon.Tfs\Greenshot.Addon.Tfs.csproj" /> <ProjectReference Include="..\Greenshot.Addon.Tfs\Greenshot.Addon.Tfs.csproj" />
<ProjectReference Include="..\Greenshot.Addon.Win10\Greenshot.Addon.Win10.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net471' "> <ItemGroup Condition="'$(TargetFramework)' == 'net471' ">
<ProjectReference Include="..\Greenshot.Addon.Jira\Greenshot.Addon.Jira.csproj" /> <ProjectReference Include="..\Greenshot.Addon.Jira\Greenshot.Addon.Jira.csproj" />
<!--ProjectReference Include="..\Greenshot.Addon.Win10\Greenshot.Addon.Win10.csproj" /-->
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -174,6 +174,8 @@ namespace Greenshot
// A dirty fix to make sure the messagebox is visible as a Greenshot window on the taskbar // A dirty fix to make sure the messagebox is visible as a Greenshot window on the taskbar
using (var multiInstanceForm = new DpiAwareForm using (var multiInstanceForm = new DpiAwareForm
{ {
// TODO: Fix a problem that in this case instance is null
Icon = GreenshotResources.Instance.GetGreenshotIcon(), Icon = GreenshotResources.Instance.GetGreenshotIcon(),
ShowInTaskbar = true, ShowInTaskbar = true,
MaximizeBox = false, MaximizeBox = false,