From 7e99478b864da3d616cccb8c36ce7173d834c2c4 Mon Sep 17 00:00:00 2001 From: Robin Krom Date: Wed, 19 Feb 2020 22:01:56 +0100 Subject: [PATCH] Removed ngen from the installer Moved the SvgImage to GreenshotPlugin, so it's available everywhere Upgraded Dapplo.Jira to a more modern version, but still far from current. --- Greenshot/releases/innosetup/setup.iss | 53 ++-- GreenshotJiraPlugin/Forms/JiraForm.cs | 8 +- .../GreenshotJiraPlugin.csproj | 3 +- GreenshotJiraPlugin/JiraPlugin.cs | 17 +- GreenshotPlugin/Core/ImageHelper.cs | 17 +- GreenshotPlugin/Core/NetworkHelper.cs | 28 +-- .../Core}/SvgImage.cs | 235 +++++++++--------- GreenshotPlugin/GreenshotPlugin.csproj | 1 + 8 files changed, 172 insertions(+), 190 deletions(-) rename {GreenshotJiraPlugin => GreenshotPlugin/Core}/SvgImage.cs (91%) diff --git a/Greenshot/releases/innosetup/setup.iss b/Greenshot/releases/innosetup/setup.iss index 74c2983fe..a75244ebb 100644 --- a/Greenshot/releases/innosetup/setup.iss +++ b/Greenshot/releases/innosetup/setup.iss @@ -19,7 +19,7 @@ Source: {#ReleaseDir}\Greenshot.exe; DestDir: {app}; Components: greenshot; Flag Source: {#ReleaseDir}\GreenshotPlugin.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion Source: {#ReleaseDir}\Greenshot.exe.config; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion Source: {#ReleaseDir}\log4net.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: ..\greenshot-defaults.ini; DestDir: {app}; Flags: overwritereadonly ignoreversion replacesameversion Source: ..\additional_files\installer.txt; DestDir: {app}; Components: greenshot; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion @@ -240,7 +240,7 @@ es.ocr=Extensión para OCR (necesita Microsoft Office Document Imaging (MODI)) es.optimize=Optimizando rendimiento; por favor, espera. es.startgreenshot=Lanzar {#ExeName} es.startup=Lanzar {#ExeName} al iniciarse Windows -es.win10=Extensión para Windows 10 +es.win10=Extensión para Windows 10 fi.confluence=Confluence-liitännäinen fi.default=${default} @@ -266,7 +266,7 @@ fr.ocr=Greffon OCR (nécessite Document Imaging de Microsoft Office [MODI]) fr.optimize=Optimisation des performances, Ceci peut prendre un certain temps. fr.startgreenshot=Démarrer {#ExeName} fr.startup=Lancer {#ExeName} au démarrage de Windows -fr.win10=Greffon Windows 10 +fr.win10=Greffon Windows 10 lt.confluence=Confluence spraudnis lt.default=${default} @@ -295,7 +295,7 @@ nl.startup={#ExeName} automatisch starten met Windows nl.win10=Windows 10 plug-in nn.confluence=Confluence-tillegg -nn.default=Default installation +nn.default=Default installation nn.office=Microsoft Office Tillegg nn.externalcommand=Tillegg for å opne med ekstern kommando nn.imgur=Imgur-tillegg (sjå http://imgur.com) @@ -362,19 +362,19 @@ Name: "custom"; Description: "{code:CustomInstall}"; Flags: iscustom [Components] Name: "greenshot"; Description: "Greenshot"; Types: default full compact custom; Flags: fixed -Name: "plugins\office"; Description: {cm:office}; Types: default full custom; Flags: disablenouninstallwarning -Name: "plugins\ocr"; Description: {cm:ocr}; Types: default full custom; Flags: disablenouninstallwarning +Name: "plugins\office"; Description: {cm:office}; Types: default full custom; Flags: disablenouninstallwarning +Name: "plugins\ocr"; Description: {cm:ocr}; Types: default full custom; Flags: disablenouninstallwarning Name: "plugins\jira"; Description: {cm:jira}; Types: full custom; Flags: disablenouninstallwarning -Name: "plugins\imgur"; Description: {cm:imgur}; Types: default full custom; Flags: disablenouninstallwarning +Name: "plugins\imgur"; Description: {cm:imgur}; Types: default full custom; Flags: disablenouninstallwarning Name: "plugins\confluence"; Description: {cm:confluence}; Types: full custom; Flags: disablenouninstallwarning -Name: "plugins\externalcommand"; Description: {cm:externalcommand}; Types: default full custom; Flags: disablenouninstallwarning +Name: "plugins\externalcommand"; Description: {cm:externalcommand}; Types: default full custom; Flags: disablenouninstallwarning ;Name: "plugins\networkimport"; Description: "Network Import Plugin"; Types: full Name: "plugins\box"; Description: "Box Plugin"; Types: full custom; Flags: disablenouninstallwarning Name: "plugins\dropbox"; Description: "Dropbox Plugin"; Types: full custom; Flags: disablenouninstallwarning -Name: "plugins\flickr"; Description: "Flickr Plugin"; Types: full custom; Flags: disablenouninstallwarning -Name: "plugins\picasa"; Description: "Picasa Plugin"; Types: full custom; Flags: disablenouninstallwarning -Name: "plugins\photobucket"; Description: "Photobucket Plugin"; Types: full custom; Flags: disablenouninstallwarning -;Name: "plugins\win10"; Description: "Windows 10 Plugin"; Types: default full custom; Flags: disablenouninstallwarning; Check: IsWindows10OrNewer() +Name: "plugins\flickr"; Description: "Flickr Plugin"; Types: full custom; Flags: disablenouninstallwarning +Name: "plugins\picasa"; Description: "Picasa Plugin"; Types: full custom; Flags: disablenouninstallwarning +Name: "plugins\photobucket"; Description: "Photobucket Plugin"; Types: full custom; Flags: disablenouninstallwarning +;Name: "plugins\win10"; Description: "Windows 10 Plugin"; Types: default full custom; Flags: disablenouninstallwarning; Check: IsWindows10OrNewer() Name: "languages"; Description: {cm:language}; Types: full custom; Flags: disablenouninstallwarning Name: "languages\arSY"; Description: "العربية"; Types: full custom; Flags: disablenouninstallwarning; Check: hasLanguageGroup('d') Name: "languages\caCA"; Description: "Català"; Types: full custom; Flags: disablenouninstallwarning; Check: hasLanguageGroup('1') @@ -427,7 +427,7 @@ begin else Result := ExpandConstant('{pf}') end; - + function FullInstall(Param : String) : String; begin @@ -458,7 +458,7 @@ begin sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); sUnInstallString := ''; index := 0; - + // Retrieve uninstall string from HKLM32 or HKCU32 if RegQueryStringValue(HKLM32, sUnInstPath, 'UninstallString', sUnInstallString) then begin @@ -473,7 +473,7 @@ begin asUninstallStrings[index] := sUnInstallString; index := index +1; end; - + // Only for Windows with 64 bit support: Retrieve uninstall string from HKLM64 or HKCU64 if IsWin64 then begin @@ -544,7 +544,7 @@ begin foundStart := false; for i:= 0 to ParamCount() do begin currentParameter := ParamStr(i); - + // check if norun is supplied if Lowercase(currentParameter) = '/norun' then begin foundNoRun := true; @@ -595,19 +595,6 @@ begin Result := netfxspversion(NetFx4x, '') >= 71; end; -function getNGENPath(argument: String) : String; -var - installPath: string; -begin - if not RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'InstallPath', installPath) then begin - if not RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client', 'InstallPath', installPath) then begin - // 3.5 doesn't have NGEN and is using the .net 2.0 installation - installPath := ExpandConstant('{dotnet20}'); - end; - end; - Result := installPath; -end; - // Initialize the setup function InitializeSetup(): Boolean; begin @@ -617,7 +604,7 @@ begin // Enhance installer, if needed, otherwise .NET installations won't work msi20('2.0'); msi31('3.0'); - + //install .net 4.7.1 dotnetfx47(71); end; @@ -640,14 +627,8 @@ begin end; [Run] -Filename: "{code:getNGENPath}\ngen.exe"; Parameters: "install ""{app}\{#ExeName}.exe"""; StatusMsg: "{cm:optimize}"; Flags: runhidden runasoriginaluser -Filename: "{code:getNGENPath}\ngen.exe"; Parameters: "install ""{app}\GreenshotPlugin.dll"""; StatusMsg: "{cm:optimize}"; Flags: runhidden runasoriginaluser Filename: "{app}\{#ExeName}.exe"; Description: "{cm:startgreenshot}"; Parameters: "{code:GetParamsForGS}"; WorkingDir: "{app}"; Flags: nowait postinstall runasoriginaluser Filename: "http://getgreenshot.org/thank-you/?language={language}&version={#Version}"; Flags: shellexec runasoriginaluser [InstallDelete] Name: {app}; Type: dirifempty; - -[UninstallRun] -Filename: "{code:GetNGENPath}\ngen.exe"; Parameters: "uninstall ""{app}\{#ExeName}.exe"""; StatusMsg: "Cleanup"; Flags: runhidden -Filename: "{code:GetNGENPath}\ngen.exe"; Parameters: "uninstall ""{app}\GreenshotPlugin.dll"""; StatusMsg: "Cleanup"; Flags: runhidden diff --git a/GreenshotJiraPlugin/Forms/JiraForm.cs b/GreenshotJiraPlugin/Forms/JiraForm.cs index 22f401bee..9bf669083 100644 --- a/GreenshotJiraPlugin/Forms/JiraForm.cs +++ b/GreenshotJiraPlugin/Forms/JiraForm.cs @@ -20,12 +20,12 @@ */ using System; -using System.Globalization; using System.Windows.Forms; using Dapplo.Jira.Entities; using GreenshotPlugin.Controls; using GreenshotPlugin.Core; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading.Tasks; using GreenshotPlugin.IniFile; @@ -176,8 +176,10 @@ namespace GreenshotJiraPlugin.Forms { } item.SubItems.Add(issue.Key); - item.SubItems.Add(issue.Fields.Created.ToString("d", DateTimeFormatInfo.InvariantInfo)); - item.SubItems.Add(issue.Fields.Assignee?.DisplayName); + item.SubItems.Add(issue.Fields.Created.HasValue + ? issue.Fields.Created.Value.ToString("d", DateTimeFormatInfo.InvariantInfo) + : string.Empty); + item.SubItems.Add(issue.Fields.Assignee?.DisplayName); item.SubItems.Add(issue.Fields.Reporter?.DisplayName); item.SubItems.Add(issue.Fields.Summary); jiraListView.Items.Add(item); diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index 2d88e8b4a..551fbffbc 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -12,7 +12,6 @@ - - + \ No newline at end of file diff --git a/GreenshotJiraPlugin/JiraPlugin.cs b/GreenshotJiraPlugin/JiraPlugin.cs index f8a98354e..80fdce253 100644 --- a/GreenshotJiraPlugin/JiraPlugin.cs +++ b/GreenshotJiraPlugin/JiraPlugin.cs @@ -90,22 +90,7 @@ namespace GreenshotJiraPlugin { LogSettings.RegisterDefaultLogger(LogLevels.Fatal); } - // Add a SVG converter, although it doesn't fit to the Jira plugin there is currently no other way - ImageHelper.StreamConverters["svg"] = (stream, s) => - { - stream.Position = 0; - try - { - return SvgImage.FromStream(stream).Image; - } - catch (Exception ex) - { - Log.Error("Can't load SVG", ex); - } - return null; - }; - - return true; + return true; } public void Shutdown() { diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs index 1edb24c06..8c31eaf4c 100644 --- a/GreenshotPlugin/Core/ImageHelper.cs +++ b/GreenshotPlugin/Core/ImageHelper.cs @@ -60,7 +60,22 @@ namespace GreenshotPlugin.Core { return surface.GetImageForExport(); }; - static Image DefaultConverter(Stream stream, string s) + // Add a SVG converter + StreamConverters["svg"] = (stream, s) => + { + stream.Position = 0; + try + { + return SvgImage.FromStream(stream).Image; + } + catch (Exception ex) + { + Log.Error("Can't load SVG", ex); + } + return null; + }; + + static Image DefaultConverter(Stream stream, string s) { stream.Position = 0; using var tmpImage = Image.FromStream(stream, true, true); diff --git a/GreenshotPlugin/Core/NetworkHelper.cs b/GreenshotPlugin/Core/NetworkHelper.cs index b5160ae46..1b2378192 100644 --- a/GreenshotPlugin/Core/NetworkHelper.cs +++ b/GreenshotPlugin/Core/NetworkHelper.cs @@ -1,20 +1,20 @@ /* * 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 . */ @@ -71,7 +71,7 @@ namespace GreenshotPlugin.Core { /// An Uri to specify the download location /// string with the file content public static string GetAsString(Uri uri) { - return GetResponseAsString(CreateWebRequest(uri)); + return GetResponseAsString(CreateWebRequest(uri)); } /// @@ -133,8 +133,8 @@ namespace GreenshotPlugin.Core { extensions.AppendFormat(@"\.{0}|", extension); } extensions.Length--; - - var imageUrlRegex = new Regex($@"(http|https)://.*(?{extensions})"); + + var imageUrlRegex = new Regex($@"(http|https)://.*(?{extensions})"); var match = imageUrlRegex.Match(url); try { @@ -190,7 +190,7 @@ namespace GreenshotPlugin.Core { public static HttpWebRequest CreateWebRequest(string uri, HTTPMethod method) { return CreateWebRequest(new Uri(uri), method); } - + /// /// Helper method to create a web request with a lot of default settings /// @@ -254,7 +254,7 @@ namespace GreenshotPlugin.Core { } return proxyToUse; } - + /// /// UrlEncodes a string without the requirement for System.Web /// @@ -324,7 +324,7 @@ namespace GreenshotPlugin.Core { } return parameters; } - + /// /// Generate the query paramters /// @@ -462,7 +462,7 @@ namespace GreenshotPlugin.Core { } /// - /// + /// /// /// /// @@ -615,7 +615,7 @@ namespace GreenshotPlugin.Core { // Write the file data directly to the Stream, rather than serializing it to a string. dataStream.Write(_file, 0, _fileSize); } - + /// /// Upload the file to the webrequest /// @@ -754,7 +754,7 @@ namespace GreenshotPlugin.Core { string header = $"--{boundary}\r\nContent-Disposition: form-data; name=\"{name}\"; filename=\"{Filename ?? name}\";\r\nContent-Type: {ContentType}\r\n\r\n"; formDataStream.Write(Encoding.UTF8.GetBytes(header), 0, Encoding.UTF8.GetByteCount(header)); - ImageOutput.SaveToStream(_surface, formDataStream, _outputSettings); + ImageOutput.SaveToStream(_surface, formDataStream, _outputSettings); } /// @@ -765,7 +765,7 @@ namespace GreenshotPlugin.Core { // Write the file data directly to the Stream, rather than serializing it to a string. ImageOutput.SaveToStream(_surface, dataStream, _outputSettings); } - + /// /// Upload the Surface as image to the webrequest /// diff --git a/GreenshotJiraPlugin/SvgImage.cs b/GreenshotPlugin/Core/SvgImage.cs similarity index 91% rename from GreenshotJiraPlugin/SvgImage.cs rename to GreenshotPlugin/Core/SvgImage.cs index bde4d60d9..64111a7eb 100644 --- a/GreenshotJiraPlugin/SvgImage.cs +++ b/GreenshotPlugin/Core/SvgImage.cs @@ -1,118 +1,117 @@ -/* - * 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 System.Drawing.Imaging; -using System.IO; -using GreenshotPlugin.Core; -using Svg; - -namespace GreenshotJiraPlugin -{ - /// - /// Create an image look like of the SVG - /// - public class SvgImage : IImage - { - private readonly SvgDocument _svgDocument; - - private Image _imageClone; - - /// - /// Factory to create via a stream - /// - /// Stream - /// IImage - public static IImage FromStream(Stream stream) - { - return new SvgImage(stream); - } - - /// - /// Default constructor - /// - /// - public SvgImage(Stream stream) - { - _svgDocument = SvgDocument.Open(stream); - Height = (int)_svgDocument.ViewBox.Height; - Width = (int)_svgDocument.ViewBox.Width; - } - - /// - /// Height of the image, can be set to change - /// - public int Height { get; set; } - - /// - /// Width of the image, can be set to change. - /// - public int Width { get; set; } - - /// - /// Size of the image - /// - public Size Size => new Size(Width, Height); - - /// - /// Pixelformat of the underlying image - /// - public PixelFormat PixelFormat => Image.PixelFormat; - - /// - /// Horizontal resolution of the underlying image - /// - public float HorizontalResolution => Image.HorizontalResolution; - - /// - /// Vertical resolution of the underlying image - /// - public float VerticalResolution => Image.VerticalResolution; - - /// - /// Unterlying image, or an on demand rendered version with different attributes as the original - /// - public Image Image - { - get - { - if (_imageClone?.Height == Height && _imageClone?.Width == Width) - { - return _imageClone; - } - // Calculate new image clone - _imageClone?.Dispose(); - _imageClone = ImageHelper.CreateEmpty(Width, Height, PixelFormat.Format32bppArgb, Color.Transparent, 96, 96); - _svgDocument.Draw((Bitmap)_imageClone); - return _imageClone; - - } - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - _imageClone?.Dispose(); - } - } -} +/* + * 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 System.Drawing.Imaging; +using System.IO; +using Svg; + +namespace GreenshotPlugin.Core +{ + /// + /// Create an image look like of the SVG + /// + public sealed class SvgImage : IImage + { + private readonly SvgDocument _svgDocument; + + private Image _imageClone; + + /// + /// Factory to create via a stream + /// + /// Stream + /// IImage + public static IImage FromStream(Stream stream) + { + return new SvgImage(stream); + } + + /// + /// Default constructor + /// + /// + public SvgImage(Stream stream) + { + _svgDocument = SvgDocument.Open(stream); + Height = (int)_svgDocument.ViewBox.Height; + Width = (int)_svgDocument.ViewBox.Width; + } + + /// + /// Height of the image, can be set to change + /// + public int Height { get; set; } + + /// + /// Width of the image, can be set to change. + /// + public int Width { get; set; } + + /// + /// Size of the image + /// + public Size Size => new Size(Width, Height); + + /// + /// Pixelformat of the underlying image + /// + public PixelFormat PixelFormat => Image.PixelFormat; + + /// + /// Horizontal resolution of the underlying image + /// + public float HorizontalResolution => Image.HorizontalResolution; + + /// + /// Vertical resolution of the underlying image + /// + public float VerticalResolution => Image.VerticalResolution; + + /// + /// Underlying image, or an on demand rendered version with different attributes as the original + /// + public Image Image + { + get + { + if (_imageClone?.Height == Height && _imageClone?.Width == Width) + { + return _imageClone; + } + // Calculate new image clone + _imageClone?.Dispose(); + _imageClone = ImageHelper.CreateEmpty(Width, Height, PixelFormat.Format32bppArgb, Color.Transparent, 96, 96); + _svgDocument.Draw((Bitmap)_imageClone); + return _imageClone; + + } + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + _imageClone?.Dispose(); + } + } +} diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj index 3fc441c33..42b108e17 100644 --- a/GreenshotPlugin/GreenshotPlugin.csproj +++ b/GreenshotPlugin/GreenshotPlugin.csproj @@ -15,6 +15,7 @@ +