From 5571410483b321e24d59e568ace1e7d9f8d46555 Mon Sep 17 00:00:00 2001 From: Robin Krom Date: Thu, 3 Sep 2020 00:02:09 +0200 Subject: [PATCH] Made things work with .NET 5, there will still be issues. [skip ci] --- README.md | 10 +- src/Directory.Build.props | 6 +- .../Greenshot.Addon.Box.csproj | 4 +- .../Greenshot.Addon.Confluence.csproj | 4 +- .../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 | 9 +- src/Greenshot.Addon.Jira/JiraConnector.cs | 2 +- .../Greenshot.Addon.LegacyEditor.csproj | 4 +- .../Greenshot.Addon.Lutim.csproj | 4 +- .../Greenshot.Addon.Office.csproj | 4 +- .../Greenshot.Addon.OneDrive.csproj | 4 +- .../Greenshot.Addon.Photobucket.csproj | 4 +- .../Greenshot.Addon.Tfs.csproj | 4 +- .../Greenshot.Addon.Win10.csproj | 11 +- .../Native/DataTransferManagerHelper.cs | 16 +- src/Greenshot.Addons/Greenshot.Addons.csproj | 4 +- .../Interfaces/IGreenshotContract.cs | 60 ------ src/Greenshot.Core/Greenshot.Core.csproj | 4 +- src/Greenshot.Gfx/BitmapFactory.cs | 15 +- src/Greenshot.Gfx/BitmapWrapper.cs | 10 +- src/Greenshot.Gfx/Greenshot.Gfx.csproj | 4 +- src/Greenshot.Gfx/Structs/PixelExtensions.cs | 5 +- .../Greenshot.PerformanceTests.csproj | 4 +- src/Greenshot.Tests/FileAssert.cs | 8 +- src/Greenshot.Tests/Greenshot.Tests.csproj | 9 +- src/Greenshot/Components/GreenshotClient.cs | 79 -------- src/Greenshot/Components/GreenshotServer.cs | 178 ------------------ src/Greenshot/Greenshot.csproj | 8 +- src/global.json | 2 +- 34 files changed, 95 insertions(+), 405 deletions(-) delete mode 100644 src/Greenshot.Addons/Interfaces/IGreenshotContract.cs delete mode 100644 src/Greenshot/Components/GreenshotClient.cs delete mode 100644 src/Greenshot/Components/GreenshotServer.cs diff --git a/README.md b/README.md index ec28e04fc..7901f4c6b 100644 --- a/README.md +++ b/README.md @@ -31,20 +31,20 @@ This repository is work in progress for the next Greenshot (2.0?). Quick start for developers ---------------------------- * Download the latest (!!!) dotnet core SDK from here: https://github.com/dotnet/core-sdk ([quick-link to download](https://dotnetcli.blob.core.windows.net/dotnet/Sdk/master/dotnet-sdk-latest-win-x64.exe)) - * Make sure you only have the latest dotnet core 3.1 installed! -* Make sure you have the latest Visual Studio 2019, and enable "Use previews of the dotnet core SDK", as is shown here: https://stackoverflow.com/a/55033763 + * Make sure you only have the latest dotnet core 5 installed! +* Make sure you have the latest Visual Studio 2019 Preview, and enable "Use previews of the dotnet core SDK", as is shown here: https://stackoverflow.com/a/55033763 * Clone the [repository](https://github.com/greenshot/greenshot/tree/develop), branch develop * Open the solution from the src directory in Visual Studio * Rebuild and start... -If you can't use Visual Studio 2019, Rider from Jetbrains is also supported and you can also work with the commandline: +If you can't use Visual Studio 2019, Rider from Jetbrains might also work and you can also work with the commandline: * Open a powershell / shell in the directory where you cloned this repo * run dotnet build src/Greenshot.sln For users the major changes since 1.2.x are: -* dotnet core 3.1 support (why, read here: https://blogs.msdn.microsoft.com/dotnet/2018/10/04/update-on-net-core-3-0-and-net-framework-4-8/ ) +* .NET 5 support (why, read here: https://blogs.msdn.microsoft.com/dotnet/2018/10/04/update-on-net-core-3-0-and-net-framework-4-8/ ) * A newer and more modern configuration UI, using [MahApps.Metro](https://github.com/MahApps/MahApps.Metro "MahApps.Metro") -* Due to the update of .NET 2.0 to .NET 4.7.2 a lot of bugs are solved +* Due to the update of .NET 2.0 to .NET 4.7.2, and later to dotnet core 3.1, and now .NET 5, a lot of bugs are solved * Added Windows 10 destinations, OCR & share * Better DPI support * Simplified code should make development easier and quicker diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 49fc820c5..1a4ac01d0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -7,7 +7,7 @@ git https://github.com/greenshot/greenshot https://www.gnu.org/licenses/gpl.html - latest + 8 true true true @@ -58,10 +58,10 @@ - + diff --git a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj index a12fa328c..bccd16f6b 100644 --- a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj +++ b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Box Greenshot.Addon.Box - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj index 2ac4fd889..5110d6b1f 100644 --- a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj +++ b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Confluence Greenshot.Addon.Confluence - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj index 21115167d..49d0ae1af 100644 --- a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj +++ b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Dropbox Greenshot.Addon.Dropbox - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj index 179ba53b6..e73ec5e24 100644 --- a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj +++ b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.ExternalCommand Greenshot.Addon.ExternalCommand - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj index 1a9d670a8..61021146b 100644 --- a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj +++ b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Flickr Greenshot.Addon.Flickr - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj index 9620c21e6..c7a08d6b2 100644 --- a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj +++ b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.GooglePhotos Greenshot.Addon.GooglePhotos - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj index e27c74de9..765cc2654 100644 --- a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj +++ b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Imgur Greenshot.Addon.Imgur - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj b/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj index ce9c65c91..d1501f43d 100644 --- a/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj +++ b/src/Greenshot.Addon.InternetExplorer/Greenshot.Addon.InternetExplorer.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + net5.0-windows true diff --git a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj index d429e9df2..a74be3fa4 100644 --- a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj +++ b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Jira Greenshot.Addon.Jira - netcoreapp3.1 + net5.0-windows @@ -20,7 +20,8 @@ - - + + + diff --git a/src/Greenshot.Addon.Jira/JiraConnector.cs b/src/Greenshot.Addon.Jira/JiraConnector.cs index 9b3f1f93b..eb140a915 100644 --- a/src/Greenshot.Addon.Jira/JiraConnector.cs +++ b/src/Greenshot.Addon.Jira/JiraConnector.cs @@ -29,8 +29,8 @@ using System.Windows.Media.Imaging; using Dapplo.HttpExtensions; using Dapplo.HttpExtensions.Extensions; using Dapplo.Jira; -using Dapplo.Jira.Converters; using Dapplo.Jira.Entities; +using Dapplo.Jira.SvgWinForms.Converters; using Dapplo.Log; using DynamicData; using Greenshot.Addon.Jira.Configuration; diff --git a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj index adf6831bf..b0de92e2c 100644 --- a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj +++ b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.LegacyEditor Greenshot.Addon.LegacyEditor - netcoreapp3.1 + net5.0-windows true diff --git a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj index 46e86ea24..396683fef 100644 --- a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj +++ b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Lutim Greenshot.Addon.Lutim - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj index 5c064eece..b9b1c3fee 100644 --- a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj +++ b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Office Greenshot.Addon.Office - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj index 27b5fe929..cf59a7234 100644 --- a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj +++ b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.OneDrive Greenshot.Addon.OneDrive - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj index d45afa862..f7940b96c 100644 --- a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj +++ b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Photobucket Greenshot.Addon.Photobucket - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj index c8204fcb8..7eb35600e 100644 --- a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj +++ b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Tfs Greenshot.Addon.Tfs - netcoreapp3.1 + net5.0-windows diff --git a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj index 246fd4616..edb16a8d5 100644 --- a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj +++ b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj @@ -1,9 +1,9 @@ - + Greenshot.Addon.Win10 Greenshot.Addon.Win10 - netcoreapp3.1 + net5.0-windows @@ -18,8 +18,9 @@ - - - + + + + \ No newline at end of file diff --git a/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs b/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs index fb6e720b6..e51027b86 100644 --- a/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs +++ b/src/Greenshot.Addon.Win10/Native/DataTransferManagerHelper.cs @@ -1,19 +1,19 @@ // 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 . @@ -57,11 +57,11 @@ namespace Greenshot.Addon.Win10.Native _dataTransferManagerInterOp = (IDataTransferManagerInterOp)activationFactory; _windowHandle = handle; - var riid = new Guid(DataTransferManagerId); - var hresult = _dataTransferManagerInterOp.GetForWindow(_windowHandle, riid, out var dataTransferManager); - if (hresult.Failed()) + var guid = new Guid(DataTransferManagerId); + var hResult = _dataTransferManagerInterOp.GetForWindow(_windowHandle, guid, out var dataTransferManager); + if (hResult.Failed()) { - Log.Warn().WriteLine("HResult for GetForWindow: {0}", hresult); + Log.Warn().WriteLine("HResult for GetForWindow: {0}", hResult); } DataTransferManager = dataTransferManager; } diff --git a/src/Greenshot.Addons/Greenshot.Addons.csproj b/src/Greenshot.Addons/Greenshot.Addons.csproj index b4d7933c9..93f5e9bba 100644 --- a/src/Greenshot.Addons/Greenshot.Addons.csproj +++ b/src/Greenshot.Addons/Greenshot.Addons.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + net5.0-windows true diff --git a/src/Greenshot.Addons/Interfaces/IGreenshotContract.cs b/src/Greenshot.Addons/Interfaces/IGreenshotContract.cs deleted file mode 100644 index 654c731f3..000000000 --- a/src/Greenshot.Addons/Interfaces/IGreenshotContract.cs +++ /dev/null @@ -1,60 +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 . - -#if !NETCOREAPP3_1 - -using System.ServiceModel; - -namespace Greenshot.Addons.Interfaces -{ - /// - /// This interface specifies the functional interface that Greenshot provides - /// - [ServiceContract] - public interface IGreenshotContract - { - /// - /// Start a capture - /// - /// - [OperationContract] - void Capture(string parameters); - - /// - /// Exit the instance - /// - [OperationContract] - void Exit(); - - /// - /// Reload configuration - /// - [OperationContract] - void ReloadConfig(); - - /// - /// Open a file - /// - /// - [OperationContract] - void OpenFile(string filename); - } -} - -#endif \ No newline at end of file diff --git a/src/Greenshot.Core/Greenshot.Core.csproj b/src/Greenshot.Core/Greenshot.Core.csproj index 9a50f2d80..e16005bf8 100644 --- a/src/Greenshot.Core/Greenshot.Core.csproj +++ b/src/Greenshot.Core/Greenshot.Core.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + net5.0-windows true diff --git a/src/Greenshot.Gfx/BitmapFactory.cs b/src/Greenshot.Gfx/BitmapFactory.cs index 93a49da01..69332d41e 100644 --- a/src/Greenshot.Gfx/BitmapFactory.cs +++ b/src/Greenshot.Gfx/BitmapFactory.cs @@ -1,19 +1,19 @@ // 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 . @@ -23,6 +23,7 @@ using System.Drawing.Imaging; using Dapplo.Log; using Dapplo.Windows.Common.Extensions; using Dapplo.Windows.Common.Structs; +using Greenshot.Gfx.Structs; namespace Greenshot.Gfx { @@ -47,7 +48,7 @@ namespace Greenshot.Gfx } return CreateEmpty(sourceImage.Width, sourceImage.Height, pixelFormat, backgroundColor, sourceImage.HorizontalResolution, sourceImage.VerticalResolution); } - + /// /// A generic way to create an empty image /// @@ -137,7 +138,7 @@ namespace Greenshot.Gfx sourceRect = sourceRect.Intersect(bitmapRect); } - // If no pixelformat is supplied + // If no pixelformat is supplied if (PixelFormat.DontCare == targetFormat || PixelFormat.Undefined == targetFormat) { if (sourceBitmap.PixelFormat.IsPixelFormatSupported()) @@ -206,7 +207,7 @@ namespace Greenshot.Gfx Log.Warn().WriteLine(ex, "Problem cloning a propertyItem."); } } - + return BitmapWrapper.FromBitmap(newImage); } diff --git a/src/Greenshot.Gfx/BitmapWrapper.cs b/src/Greenshot.Gfx/BitmapWrapper.cs index 7c288cab7..bdd280eb3 100644 --- a/src/Greenshot.Gfx/BitmapWrapper.cs +++ b/src/Greenshot.Gfx/BitmapWrapper.cs @@ -1,19 +1,19 @@ // 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 . @@ -86,7 +86,7 @@ namespace Greenshot.Gfx /// public Size Size => new Size(Width, Height); - + /// /// Factory method /// diff --git a/src/Greenshot.Gfx/Greenshot.Gfx.csproj b/src/Greenshot.Gfx/Greenshot.Gfx.csproj index d8f96e209..2c405c2b7 100644 --- a/src/Greenshot.Gfx/Greenshot.Gfx.csproj +++ b/src/Greenshot.Gfx/Greenshot.Gfx.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + net5.0-windows true diff --git a/src/Greenshot.Gfx/Structs/PixelExtensions.cs b/src/Greenshot.Gfx/Structs/PixelExtensions.cs index 61393e1d9..f0198d397 100644 --- a/src/Greenshot.Gfx/Structs/PixelExtensions.cs +++ b/src/Greenshot.Gfx/Structs/PixelExtensions.cs @@ -103,7 +103,10 @@ namespace Greenshot.Gfx.Structs /// Color public static Color ToColor(this uint color) { - return Color.FromArgb((int)color); + unchecked + { + return Color.FromArgb((int)color); + } } } } \ No newline at end of file diff --git a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj index 91240097d..751085777 100644 --- a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj +++ b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj @@ -1,10 +1,10 @@ - + Greenshot.PerformanceTests Greenshot.PerformanceTests Exe - netcoreapp3.1 + net5.0-windows true diff --git a/src/Greenshot.Tests/FileAssert.cs b/src/Greenshot.Tests/FileAssert.cs index 6a622d0a7..cf623d12e 100644 --- a/src/Greenshot.Tests/FileAssert.cs +++ b/src/Greenshot.Tests/FileAssert.cs @@ -1,19 +1,19 @@ // 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 . diff --git a/src/Greenshot.Tests/Greenshot.Tests.csproj b/src/Greenshot.Tests/Greenshot.Tests.csproj index 98e055cee..720cbf632 100644 --- a/src/Greenshot.Tests/Greenshot.Tests.csproj +++ b/src/Greenshot.Tests/Greenshot.Tests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + net5.0-windows true @@ -32,15 +32,16 @@ + - + runtime; build; native; contentfiles; analyzers all - + diff --git a/src/Greenshot/Components/GreenshotClient.cs b/src/Greenshot/Components/GreenshotClient.cs deleted file mode 100644 index 2b8e30ebe..000000000 --- a/src/Greenshot/Components/GreenshotClient.cs +++ /dev/null @@ -1,79 +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 . - -#if !NETCOREAPP3_1 - -using System.Collections.Generic; -using System.ServiceModel; -using Greenshot.Addons.Interfaces; - -namespace Greenshot.Components -{ - /// - /// A simple helper to talk to an already running Greenshot instance - /// - public static class GreenshotClient - { - private static ChannelFactory ChannelFactory => new ChannelFactory(new NetNamedPipeBinding(), new EndpointAddress(GreenshotServerAction.EndPoint)); - - public static void Capture(string parameters) - { - using (var factory = ChannelFactory) - { - var client = factory.CreateChannel(); - client.Capture(parameters); - } - } - - public static void OpenFiles(List filesToOpen) - { - if (filesToOpen == null || filesToOpen.Count == 0) - { - return; - } - using (var factory = ChannelFactory) - { - var client = factory.CreateChannel(); - foreach (string filename in filesToOpen) - { - client.OpenFile(filename); - } - } - } - - public static void Exit() - { - using (var factory = ChannelFactory) - { - var client = factory.CreateChannel(); - client.Exit(); - } - } - - public static void ReloadConfig() - { - using (var factory = ChannelFactory) - { - var client = factory.CreateChannel(); - client.ReloadConfig(); - } - } - } -} -#endif \ No newline at end of file diff --git a/src/Greenshot/Components/GreenshotServer.cs b/src/Greenshot/Components/GreenshotServer.cs deleted file mode 100644 index 3ec322894..000000000 --- a/src/Greenshot/Components/GreenshotServer.cs +++ /dev/null @@ -1,178 +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 . - -#if !NETCOREAPP3_1 - -using System; -using System.IO; -using System.Linq; -using System.Security.Principal; -using System.ServiceModel; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using Dapplo.Addons; -using Dapplo.Log; -using Greenshot.Addons.Components; -using Greenshot.Addons.Core; -using Greenshot.Addons.Interfaces; -using Greenshot.Core.Enums; -using Greenshot.Forms; -using Greenshot.Helpers; -using Application = System.Windows.Application; - -namespace Greenshot.Components -{ - /// - /// This startup action starts the Greenshot "server", which allows to open files etc. - /// - [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] - [Service(nameof(GreenshotServerAction), nameof(MainFormStartup))] - public class GreenshotServerAction : IGreenshotContract, IStartupAsync, IShutdownAsync - { - private static readonly LogSource Log = new LogSource(); - private readonly ICoreConfiguration _coreConfiguration; - private readonly MainForm _mainForm; - private readonly HotkeyService _hotkeyService; - private readonly DestinationHolder _destinationHolder; - private ServiceHost _host; - private CaptureSupportInfo _captureSupportInfo; - - public static string Identity - { - get - { - var windowsIdentity = WindowsIdentity.GetCurrent(); - return windowsIdentity.User?.ToString(); - } - } - public static string EndPoint => $"net.pipe://localhost/Greenshot/Greenshot_{Identity}"; - - public GreenshotServerAction( - ICoreConfiguration coreConfiguration, - MainForm mainForm, - HotkeyService hotkeyService, - DestinationHolder destinationHolder, - CaptureSupportInfo captureSupportInfo) - { - _captureSupportInfo = captureSupportInfo; - _coreConfiguration = coreConfiguration; - _mainForm = mainForm; - _hotkeyService = hotkeyService; - _destinationHolder = destinationHolder; - } - - /// - public Task StartupAsync(CancellationToken cancellationToken = default) - { - // TODO: Test performance with Startup without async - Log.Debug().WriteLine("Starting Greenshot server"); - return Task.Run(() => { - _host = new ServiceHost(this, new Uri("net.pipe://localhost/Greenshot")); - _host.AddServiceEndpoint(typeof(IGreenshotContract), new NetNamedPipeBinding(), "Greenshot_" + Identity); - _host.Open(); - Log.Debug().WriteLine("Started Greenshot server"); - }, cancellationToken); - } - - public Task ShutdownAsync(CancellationToken cancellationToken = default) - { - Log.Debug().WriteLine("Stopping Greenshot server"); - - return Task.Factory.FromAsync((callback, stateObject) => _host.BeginClose(callback, stateObject), asyncResult => _host.EndClose(asyncResult), null); - } - - /// - public void Exit() - { - Application.Current.Shutdown(); - } - - /// - public void ReloadConfig() - { - Log.Info().WriteLine("Reload requested"); - try - { - // TODO: Fix - //IniConfig.Current?.ReloadAsync().Wait(); - _mainForm.Invoke((MethodInvoker)(() => - { - // Even update language when needed, this should be done automatically :) - _mainForm.UpdateUi(); - })); - } - catch (Exception ex) - { - Log.Warn().WriteLine(ex, "Exception while reloading configuration: "); - } - } - - /// - public void OpenFile(string filename) - { - Log.Debug().WriteLine("Open file requested: {0}", filename); - if (File.Exists(filename)) - { - CaptureHelper.CaptureFile(_captureSupportInfo, filename); - } - else - { - Log.Warn().WriteLine("No such file: {0}", filename); - } - } - - /// - public void Capture(string parameters) - { - - if (MainForm.Instance.InvokeRequired) - { - MainForm.Instance.Invoke((MethodInvoker)(() => Capture(parameters))); - return; - } - - Log.Info().WriteLine("Capture requested: {0}", parameters); - - string[] optionsArray = parameters.Split(','); - string captureMode = optionsArray[0]; - // Fallback-Destination - - var designation = _coreConfiguration.OutputDestinations.FirstOrDefault(); - var destination = _destinationHolder.SortedActiveDestinations.FirstOrDefault(d => d.Designation == designation); - - switch (captureMode.ToLower()) - { - case "region": - CaptureHelper.CaptureRegion(_captureSupportInfo, false, destination); - break; - case "window": - CaptureHelper.CaptureWindow(_captureSupportInfo, false, destination); - break; - case "fullscreen": - CaptureHelper.CaptureFullscreen(_captureSupportInfo, false, ScreenCaptureMode.FullScreen, destination); - break; - default: - Log.Warn().WriteLine("Unknown capture option"); - break; - } - } - } -} -#endif \ No newline at end of file diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj index 024cae4c8..1fec2a640 100644 --- a/src/Greenshot/Greenshot.csproj +++ b/src/Greenshot/Greenshot.csproj @@ -1,8 +1,8 @@ - + WinExe - netcoreapp3.1 + net5.0-windows latest icons\applicationIcon\icon.ico True @@ -42,8 +42,8 @@ - - + + diff --git a/src/global.json b/src/global.json index e6509422e..b1eee6215 100644 --- a/src/global.json +++ b/src/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.100", + "version": "5.0.0", "rollForward": "latestMajor", "allowPrerelease": true }