diff --git a/Directory.Build.props b/Directory.Build.props index 6ce7c7c6e..37b63badc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -56,7 +56,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index e415d1053..bad4a0d24 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -31,7 +31,6 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Globalization; -using System.Linq; using System.Security.Permissions; using System.Threading; using System.Threading.Tasks; @@ -39,7 +38,6 @@ using System.Windows.Forms; using GreenshotPlugin.IniFile; using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces.Ocr; -using ZXing; namespace Greenshot.Forms { /// @@ -153,11 +151,11 @@ namespace Greenshot.Forms { InitializeComponent(); // Only double-buffer when we are not in a TerminalServerSession 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); - // Unregister at close + // Un-register at close FormClosing += ClosingHandler; // set cursor location @@ -322,7 +320,7 @@ namespace Greenshot.Forms { if (_capture.CaptureDetails.OcrInformation is null) { var ocrProvider = SimpleServiceProvider.Current.GetInstance(); - if (ocrProvider is object) + if (ocrProvider != null) { var uiTaskScheduler = SimpleServiceProvider.Current.GetInstance(); @@ -338,30 +336,10 @@ namespace Greenshot.Forms { Invalidate(); } 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; - } + } } - - /// + /// /// The mousedown handler of the capture form /// /// @@ -402,13 +380,7 @@ namespace Greenshot.Forms { _captureRect = new Rectangle(_mouseMovePos, new Size(1, 1)); // Go and process the capture DialogResult = DialogResult.OK; - } else if (_capture.CaptureDetails.QrResult != null && _capture.CaptureDetails.QrResult.BoundingQrBox().Contains(_mouseMovePos)) - { - // Handle a click on a QR code - _captureRect = new Rectangle(_mouseMovePos, Size.Empty); - // Go and process the capture - DialogResult = DialogResult.OK; - } else { + } else { Invalidate(); } @@ -891,29 +863,7 @@ namespace Greenshot.Forms { } } - - // 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 + // Only draw Cursor if it's (partly) visible 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); } diff --git a/Greenshot/Greenshot.csproj b/Greenshot/Greenshot.csproj index a321ad9b9..1b25c59a2 100644 --- a/Greenshot/Greenshot.csproj +++ b/Greenshot/Greenshot.csproj @@ -18,7 +18,6 @@ - diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index ea7707f1f..d8a617995 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -145,7 +145,7 @@ namespace Greenshot.Helpers { public static void CaptureWindowInteractive(bool captureMouse) { - using CaptureHelper captureHelper = new CaptureHelper(CaptureMode.Window); + using CaptureHelper captureHelper = new CaptureHelper(CaptureMode.Window, captureMouse); captureHelper.MakeCapture(); } @@ -608,28 +608,7 @@ namespace Greenshot.Helpers { return; } - // User clicked on a QR Code - 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 + // Make sure the user sees that the capture is made if (_capture.CaptureDetails.CaptureMode == CaptureMode.File || _capture.CaptureDetails.CaptureMode == CaptureMode.Clipboard) { // Maybe not "made" but the original is still there... somehow outputMade = true; diff --git a/Greenshot/Helpers/QrExtensions.cs b/Greenshot/Helpers/QrExtensions.cs deleted file mode 100644 index ac96863ad..000000000 --- a/Greenshot/Helpers/QrExtensions.cs +++ /dev/null @@ -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 . - */ - -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 - { - /// - /// Find the bounding box for the Qr Result. - /// - /// Result - /// Rectangle - 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); - } - } -} diff --git a/Greenshot/Processors/ZXingQrProcessor.cs b/Greenshot/Processors/ZXingQrProcessor.cs deleted file mode 100644 index 0fa9e08e4..000000000 --- a/Greenshot/Processors/ZXingQrProcessor.cs +++ /dev/null @@ -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 . - */ - -using System.Drawing; -using GreenshotPlugin.Core; -using GreenshotPlugin.Interfaces; -using log4net; -using ZXing; - -namespace Greenshot.Processors { - /// - /// This processor processes a capture to see if there is a QR ode on it - /// - 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; - } - } -} diff --git a/Greenshot/greenshot.manifest b/Greenshot/greenshot.manifest index cae29e2dc..77ba35d7a 100644 --- a/Greenshot/greenshot.manifest +++ b/Greenshot/greenshot.manifest @@ -16,7 +16,7 @@ - + diff --git a/Greenshot/releases/innosetup/setup.iss b/Greenshot/releases/innosetup/setup.iss index bf4485edf..b2fd8e371 100644 --- a/Greenshot/releases/innosetup/setup.iss +++ b/Greenshot/releases/innosetup/setup.iss @@ -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}\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}\zxing*.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion Source: ..\..\log4net.xml; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion Source: {#ReleaseDir}\checksum.SHA256; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion ;Source: ..\greenshot-defaults.ini; DestDir: {app}; Flags: overwritereadonly ignoreversion replacesameversion diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index b739c7aab..5579b7dac 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/GreenshotPlugin/Core/Capture.cs b/GreenshotPlugin/Core/Capture.cs index 78b93627b..95a7fb872 100644 --- a/GreenshotPlugin/Core/Capture.cs +++ b/GreenshotPlugin/Core/Capture.cs @@ -2,11 +2,9 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; -using System.Linq; using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces.Ocr; using log4net; -using ZXing; namespace GreenshotPlugin.Core { @@ -20,7 +18,7 @@ namespace GreenshotPlugin.Core private Rectangle _screenBounds; /// - /// Get/Set the Screenbounds + /// Get/Set the screen bounds /// public Rectangle ScreenBounds { get { @@ -180,19 +178,6 @@ namespace GreenshotPlugin.Core // TODO: Remove invisible lines/words? 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 var visibleElements = new List(); foreach(var captureElement in _elements) { diff --git a/GreenshotPlugin/Core/CaptureDetails.cs b/GreenshotPlugin/Core/CaptureDetails.cs index 9f7682d5a..f6e0474ea 100644 --- a/GreenshotPlugin/Core/CaptureDetails.cs +++ b/GreenshotPlugin/Core/CaptureDetails.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces.Ocr; -using ZXing; namespace GreenshotPlugin.Core { @@ -45,9 +44,6 @@ namespace GreenshotPlugin.Core /// public OcrInformation OcrInformation { get; set; } - /// - public Result QrResult { get; set; } - /// public Dictionary MetaData { get; } = new Dictionary(); diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj index 16ba0a08c..1a9598bc0 100644 --- a/GreenshotPlugin/GreenshotPlugin.csproj +++ b/GreenshotPlugin/GreenshotPlugin.csproj @@ -16,7 +16,6 @@ - diff --git a/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs b/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs index 088b045e3..e62cdf89a 100644 --- a/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs +++ b/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs @@ -102,7 +102,7 @@ namespace GreenshotPlugin.Hooking } /// - /// WinEventDelegate for the creation & destruction + /// WinEventDelegate for the creation and destruction /// /// /// diff --git a/GreenshotPlugin/Interfaces/ICaptureDetails.cs b/GreenshotPlugin/Interfaces/ICaptureDetails.cs index 33df1a822..055cd598b 100644 --- a/GreenshotPlugin/Interfaces/ICaptureDetails.cs +++ b/GreenshotPlugin/Interfaces/ICaptureDetails.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using GreenshotPlugin.Interfaces.Ocr; -using ZXing; namespace GreenshotPlugin.Interfaces { /// @@ -100,10 +99,5 @@ namespace GreenshotPlugin.Interfaces { /// Store the OCR information for this capture /// OcrInformation OcrInformation { get; set; } - - /// - /// Store the QR information for this capture - /// - Result QrResult { get; set; } - } + } } diff --git a/GreenshotWin10Plugin/GreenshotWin10Plugin.csproj b/GreenshotWin10Plugin/GreenshotWin10Plugin.csproj index 4e6095274..a17df050e 100644 --- a/GreenshotWin10Plugin/GreenshotWin10Plugin.csproj +++ b/GreenshotWin10Plugin/GreenshotWin10Plugin.csproj @@ -12,7 +12,7 @@ - + diff --git a/GreenshotWin10Plugin/ToastNotificationService.cs b/GreenshotWin10Plugin/ToastNotificationService.cs index 4af060bf9..70ef5084a 100644 --- a/GreenshotWin10Plugin/ToastNotificationService.cs +++ b/GreenshotWin10Plugin/ToastNotificationService.cs @@ -107,7 +107,7 @@ namespace GreenshotWin10Plugin // Create the toast and attach event listeners var toast = new ToastNotification(toastXml) { - ExpiresOnReboot = true, + // Windows 10 first with 1903: ExpiresOnReboot = true, ExpirationTime = timeout > 0 ? DateTimeOffset.Now.AddMilliseconds(timeout) : (DateTimeOffset?)null };