Fixed Windows 10 incompatibility with 1809

Removed experimental QR code
Updated dependencies.
This commit is contained in:
Robin 2020-04-12 23:23:02 +02:00
parent 5fbd605239
commit 3055d42689
16 changed files with 18 additions and 221 deletions

View file

@ -56,7 +56,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="!$(MSBuildProjectName.Contains('Tests')) And $(MSBuildProjectName.StartsWith('Greenshot'))"> <ItemGroup Condition="!$(MSBuildProjectName.Contains('Tests')) And $(MSBuildProjectName.StartsWith('Greenshot'))">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50"> <PackageReference Include="Nerdbank.GitVersioning" Version="3.1.74">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> </PackageReference>

View file

@ -31,7 +31,6 @@ using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Security.Permissions; using System.Security.Permissions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -39,7 +38,6 @@ using System.Windows.Forms;
using GreenshotPlugin.IniFile; using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Ocr; using GreenshotPlugin.Interfaces.Ocr;
using ZXing;
namespace Greenshot.Forms { namespace Greenshot.Forms {
/// <summary> /// <summary>
@ -153,11 +151,11 @@ namespace Greenshot.Forms {
InitializeComponent(); InitializeComponent();
// Only double-buffer when we are not in a TerminalServerSession // Only double-buffer when we are not in a TerminalServerSession
DoubleBuffered = !IsTerminalServerSession; DoubleBuffered = !IsTerminalServerSession;
Text = "Greenshot capture form"; Text = @"Greenshot capture form";
// Make sure we never capture the captureform // Make sure we never capture the capture-form
WindowDetails.RegisterIgnoreHandle(Handle); WindowDetails.RegisterIgnoreHandle(Handle);
// Unregister at close // Un-register at close
FormClosing += ClosingHandler; FormClosing += ClosingHandler;
// set cursor location // set cursor location
@ -322,7 +320,7 @@ namespace Greenshot.Forms {
if (_capture.CaptureDetails.OcrInformation is null) if (_capture.CaptureDetails.OcrInformation is null)
{ {
var ocrProvider = SimpleServiceProvider.Current.GetInstance<IOcrProvider>(); var ocrProvider = SimpleServiceProvider.Current.GetInstance<IOcrProvider>();
if (ocrProvider is object) if (ocrProvider != null)
{ {
var uiTaskScheduler = SimpleServiceProvider.Current.GetInstance<TaskScheduler>(); var uiTaskScheduler = SimpleServiceProvider.Current.GetInstance<TaskScheduler>();
@ -338,30 +336,10 @@ namespace Greenshot.Forms {
Invalidate(); Invalidate();
} }
break; break;
case Keys.Q: }
if (_capture.CaptureDetails.QrResult is null)
{
// create a barcode reader instance
IBarcodeReader reader = new BarcodeReader();
// detect and decode the barcode inside the bitmap
var result = reader.Decode((Bitmap)_capture.Image);
// do something with the result
if (result != null)
{
Log.InfoFormat("Found QR of type {0} with text {1}", result.BarcodeFormat, result.Text);
_capture.CaptureDetails.QrResult = result;
}
}
else
{
Invalidate();
}
break;
}
} }
/// <summary>
/// <summary>
/// The mousedown handler of the capture form /// The mousedown handler of the capture form
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
@ -402,13 +380,7 @@ namespace Greenshot.Forms {
_captureRect = new Rectangle(_mouseMovePos, new Size(1, 1)); _captureRect = new Rectangle(_mouseMovePos, new Size(1, 1));
// Go and process the capture // Go and process the capture
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
} else if (_capture.CaptureDetails.QrResult != null && _capture.CaptureDetails.QrResult.BoundingQrBox().Contains(_mouseMovePos)) } else {
{
// Handle a click on a QR code
_captureRect = new Rectangle(_mouseMovePos, Size.Empty);
// Go and process the capture
DialogResult = DialogResult.OK;
} else {
Invalidate(); Invalidate();
} }
@ -891,29 +863,7 @@ namespace Greenshot.Forms {
} }
} }
// Only draw Cursor if it's (partly) visible
// QR Code
if (_capture.CaptureDetails.QrResult != null)
{
var result = _capture.CaptureDetails.QrResult;
var boundingBox = _capture.CaptureDetails.QrResult.BoundingQrBox();
if (!boundingBox.IsEmpty)
{
Log.InfoFormat("Found QR of type {0} - {1}", result.BarcodeFormat, result.Text);
Invalidate(boundingBox);
using var pen = new Pen(Color.BlueViolet, 10);
using var solidBrush = new SolidBrush(Color.Green);
using var solidWhiteBrush = new SolidBrush(Color.White);
using var font = new Font(FontFamily.GenericSerif, 12, FontStyle.Regular);
graphics.FillRectangle(solidWhiteBrush, boundingBox);
graphics.DrawRectangle(pen, boundingBox);
graphics.DrawString(result.Text, font, solidBrush, boundingBox);
}
}
// Only draw Cursor if it's (partly) visible
if (_capture.Cursor != null && _capture.CursorVisible && clipRectangle.IntersectsWith(new Rectangle(_capture.CursorLocation, _capture.Cursor.Size))) { if (_capture.Cursor != null && _capture.CursorVisible && clipRectangle.IntersectsWith(new Rectangle(_capture.CursorLocation, _capture.Cursor.Size))) {
graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y); graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
} }

View file

@ -18,7 +18,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Tools.InnoSetup" version="6.0.3" GeneratePathProperty="true" /> <PackageReference Include="Tools.InnoSetup" version="6.0.3" GeneratePathProperty="true" />
<PackageReference Include="ZXing.Net" Version="0.16.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -145,7 +145,7 @@ namespace Greenshot.Helpers {
public static void CaptureWindowInteractive(bool captureMouse) public static void CaptureWindowInteractive(bool captureMouse)
{ {
using CaptureHelper captureHelper = new CaptureHelper(CaptureMode.Window); using CaptureHelper captureHelper = new CaptureHelper(CaptureMode.Window, captureMouse);
captureHelper.MakeCapture(); captureHelper.MakeCapture();
} }
@ -608,28 +608,7 @@ namespace Greenshot.Helpers {
return; return;
} }
// User clicked on a QR Code // Make sure the user sees that the capture is made
var qrResult = _capture.CaptureDetails.QrResult;
if (qrResult != null && _captureRect.Size.IsEmpty && qrResult.BoundingQrBox().Contains(_captureRect.Location))
{
if (qrResult.Text.StartsWith("http"))
{
Process.Start(qrResult.Text);
}
else
{
Clipboard.SetText(qrResult.Text);
}
// Disable capturing
_captureMode = CaptureMode.None;
// Dispose the capture, we don't need it anymore (the surface copied all information and we got the title (if any)).
_capture.Dispose();
_capture = null;
return;
}
// Make sure the user sees that the capture is made
if (_capture.CaptureDetails.CaptureMode == CaptureMode.File || _capture.CaptureDetails.CaptureMode == CaptureMode.Clipboard) { if (_capture.CaptureDetails.CaptureMode == CaptureMode.File || _capture.CaptureDetails.CaptureMode == CaptureMode.Clipboard) {
// Maybe not "made" but the original is still there... somehow // Maybe not "made" but the original is still there... somehow
outputMade = true; outputMade = true;

View file

@ -1,52 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 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/>.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZXing;
namespace Greenshot.Helpers
{
public static class QrExtensions
{
/// <summary>
/// Find the bounding box for the Qr Result.
/// </summary>
/// <param name="result">Result</param>
/// <returns>Rectangle</returns>
public static Rectangle BoundingQrBox(this Result result)
{
var xValues = result.ResultPoints.Select(p => (int)p.X).ToList();
int xMin = xValues.Min();
int xMax = xValues.Max();
var yValues = result.ResultPoints.Select(p => (int)p.Y).ToList();
int yMin = yValues.Min();
int yMax = yValues.Max();
return new Rectangle(xMin, yMin, xMax - xMin, yMax - yMin);
}
}
}

View file

@ -1,52 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 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/>.
*/
using System.Drawing;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces;
using log4net;
using ZXing;
namespace Greenshot.Processors {
/// <summary>
/// This processor processes a capture to see if there is a QR ode on it
/// </summary>
public class ZXingQrProcessor : AbstractProcessor {
private static readonly ILog LOG = LogManager.GetLogger(typeof(ZXingQrProcessor));
public override string Designation => "ZXingQrProcessor";
public override string Description => Designation;
public override bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails) {
// create a barcode reader instance
IBarcodeReader reader = new BarcodeReader();
// detect and decode the barcode inside the bitmap
var result = reader.Decode((Bitmap)surface.Image);
// do something with the result
if (result == null) return false;
LOG.InfoFormat("Found QR of type {0} - {1}", result.BarcodeFormat, result.Text);
captureDetails.QrResult = result;
return true;
}
}
}

View file

@ -16,7 +16,7 @@
<application> <application>
<!-- Windows 10 --> <!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
<maxversiontested Id="10.0.18362.0"/> <maxversiontested Id="10.0.18363.0"/>
<!-- Windows 8.1 --> <!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" /> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!--Windows 8 --> <!--Windows 8 -->

View file

@ -26,7 +26,6 @@ Source: {#ReleaseDir}\Dapplo.Log.dll; DestDir: {app}; Components: greenshot; Fla
Source: {#ReleaseDir}\Svg.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion Source: {#ReleaseDir}\Svg.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
Source: {#ReleaseDir}\Fizzler.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion Source: {#ReleaseDir}\Fizzler.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
Source: {#ReleaseDir}\Newtonsoft.Json.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion Source: {#ReleaseDir}\Newtonsoft.Json.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
Source: {#ReleaseDir}\zxing*.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
Source: ..\..\log4net.xml; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion Source: ..\..\log4net.xml; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion
Source: {#ReleaseDir}\checksum.SHA256; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion Source: {#ReleaseDir}\checksum.SHA256; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
;Source: ..\greenshot-defaults.ini; DestDir: {app}; Flags: overwritereadonly ignoreversion replacesameversion ;Source: ..\greenshot-defaults.ini; DestDir: {app}; Flags: overwritereadonly ignoreversion replacesameversion

View file

@ -12,6 +12,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj" /> <ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj" />
<PackageReference Include="Dapplo.Jira" version="0.9.19" /> <PackageReference Include="Dapplo.Jira" version="0.9.21" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -2,11 +2,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Linq;
using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Ocr; using GreenshotPlugin.Interfaces.Ocr;
using log4net; using log4net;
using ZXing;
namespace GreenshotPlugin.Core namespace GreenshotPlugin.Core
{ {
@ -20,7 +18,7 @@ namespace GreenshotPlugin.Core
private Rectangle _screenBounds; private Rectangle _screenBounds;
/// <summary> /// <summary>
/// Get/Set the Screenbounds /// Get/Set the screen bounds
/// </summary> /// </summary>
public Rectangle ScreenBounds { public Rectangle ScreenBounds {
get { get {
@ -180,19 +178,6 @@ namespace GreenshotPlugin.Core
// TODO: Remove invisible lines/words? // TODO: Remove invisible lines/words?
CaptureDetails.OcrInformation?.Offset(-cropRectangle.Location.X, -cropRectangle.Location.Y); CaptureDetails.OcrInformation?.Offset(-cropRectangle.Location.X, -cropRectangle.Location.Y);
// Offset the Qr information
// TODO: Remove invisible QR codes?
var oldQrResult = CaptureDetails.QrResult;
if (oldQrResult != null)
{
CaptureDetails.OcrInformation?.Offset(-cropRectangle.Location.X, -cropRectangle.Location.Y);
var offsetPoints = CaptureDetails.QrResult.ResultPoints
.Select(p => new ResultPoint(p.X - cropRectangle.Location.X, p.Y - cropRectangle.Location.Y)).ToArray();
var newQqResult = new Result(oldQrResult.Text, oldQrResult.RawBytes, offsetPoints, oldQrResult.BarcodeFormat);
CaptureDetails.QrResult = newQqResult;
}
// Remove invisible elements // Remove invisible elements
var visibleElements = new List<ICaptureElement>(); var visibleElements = new List<ICaptureElement>();
foreach(var captureElement in _elements) { foreach(var captureElement in _elements) {

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Ocr; using GreenshotPlugin.Interfaces.Ocr;
using ZXing;
namespace GreenshotPlugin.Core namespace GreenshotPlugin.Core
{ {
@ -45,9 +44,6 @@ namespace GreenshotPlugin.Core
/// <inheritdoc /> /// <inheritdoc />
public OcrInformation OcrInformation { get; set; } public OcrInformation OcrInformation { get; set; }
/// <inheritdoc />
public Result QrResult { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public Dictionary<string, string> MetaData { get; } = new Dictionary<string, string>(); public Dictionary<string, string> MetaData { get; } = new Dictionary<string, string>();

View file

@ -16,7 +16,6 @@
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.10.9" /> <PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.10.9" />
<PackageReference Include="log4net" version="2.0.8" /> <PackageReference Include="log4net" version="2.0.8" />
<PackageReference Include="Svg" Version="3.0.102" /> <PackageReference Include="Svg" Version="3.0.102" />
<PackageReference Include="ZXing.Net" Version="0.16.5" />
<Reference Include="Accessibility" /> <Reference Include="Accessibility" />
<Reference Include="CustomMarshalers" /> <Reference Include="CustomMarshalers" />
</ItemGroup> </ItemGroup>

View file

@ -102,7 +102,7 @@ namespace GreenshotPlugin.Hooking
} }
/// <summary> /// <summary>
/// WinEventDelegate for the creation & destruction /// WinEventDelegate for the creation and destruction
/// </summary> /// </summary>
/// <param name="eventType"></param> /// <param name="eventType"></param>
/// <param name="hWnd"></param> /// <param name="hWnd"></param>

View file

@ -22,7 +22,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using GreenshotPlugin.Interfaces.Ocr; using GreenshotPlugin.Interfaces.Ocr;
using ZXing;
namespace GreenshotPlugin.Interfaces { namespace GreenshotPlugin.Interfaces {
/// <summary> /// <summary>
@ -100,10 +99,5 @@ namespace GreenshotPlugin.Interfaces {
/// Store the OCR information for this capture /// Store the OCR information for this capture
/// </summary> /// </summary>
OcrInformation OcrInformation { get; set; } OcrInformation OcrInformation { get; set; }
}
/// <summary>
/// Store the QR information for this capture
/// </summary>
Result QrResult { get; set; }
}
} }

View file

@ -12,7 +12,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" /> <PackageReference Include="Microsoft.Windows.SDK.Contracts" version="10.0.17763.1000" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj" /> <ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj" />

View file

@ -107,7 +107,7 @@ namespace GreenshotWin10Plugin
// Create the toast and attach event listeners // Create the toast and attach event listeners
var toast = new ToastNotification(toastXml) var toast = new ToastNotification(toastXml)
{ {
ExpiresOnReboot = true, // Windows 10 first with 1903: ExpiresOnReboot = true,
ExpirationTime = timeout > 0 ? DateTimeOffset.Now.AddMilliseconds(timeout) : (DateTimeOffset?)null ExpirationTime = timeout > 0 ? DateTimeOffset.Now.AddMilliseconds(timeout) : (DateTimeOffset?)null
}; };