From f2649a1feb7e3c84a9dc4d49a2a7ae2dbe11b680 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 2 Oct 2016 16:08:22 +0200 Subject: [PATCH] Added the Win10 plugin to the Greenshot installer. --- .../releases/innosetup/setup.iss.template | 33 +++++++++++++++++-- GreenshotPlugin/Core/FilenameHelper.cs | 2 +- .../Core/OperatingSystemExtensions.cs | 10 ++++++ GreenshotPlugin/Core/PluginUtils.cs | 5 +-- GreenshotWin10Plugin/Win10OcrDestination.cs | 9 +++-- GreenshotWin10Plugin/Win10Plugin.cs | 2 +- GreenshotWin10Plugin/Win10ShareDestination.cs | 8 ++++- 7 files changed, 59 insertions(+), 10 deletions(-) diff --git a/Greenshot/releases/innosetup/setup.iss.template b/Greenshot/releases/innosetup/setup.iss.template index c89aaf6d0..5aefcccad 100644 --- a/Greenshot/releases/innosetup/setup.iss.template +++ b/Greenshot/releases/innosetup/setup.iss.template @@ -101,8 +101,8 @@ Source: ..\..\bin\Release\Languages\Plugins\GreenshotConfluencePlugin\*; DestDir ;ExternalCommand Plugin Source: ..\..\bin\Release\Plugins\GreenshotExternalCommandPlugin\GreenshotExternalCommandPlugin.gsp; DestDir: {app}\Plugins\GreenshotExternalCommandPlugin; Components: plugins\externalcommand; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion; Source: ..\..\bin\Release\Languages\Plugins\GreenshotExternalCommandPlugin\*; DestDir: {app}\Languages\Plugins\GreenshotExternalCommandPlugin; Components: plugins\externalcommand; Flags: overwritereadonly ignoreversion replacesameversion; -;Network Import Plugin -;Source: ..\..\bin\Release\Plugins\GreenshotNetworkImportPlugin\*; DestDir: {app}\Plugins\GreenshotNetworkImportPlugin; Components: plugins\networkimport; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion; +;Win 10 Plugin +Source: ..\..\bin\Release\Plugins\GreenshotWin10Plugin\GreenshotWin10Plugin.gsp; DestDir: {app}\Plugins\GreenshotWin10Plugin; Components: plugins\win10; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion; [Setup] ; changes associations is used when the installer installs new extensions, it clears the explorer icon cache ChangesAssociations=yes @@ -211,6 +211,7 @@ de.ocr=OCR Plug-in (benötigt Microsoft Office Document Imaging (MODI)) de.optimize=Optimierung der Leistung, kann etwas dauern. de.startgreenshot={#ExeName} starten de.startup={#ExeName} starten wenn Windows hochfährt +de.win10=Windows 10 Plug-in en.confluence=Confluence plug-in en.default=Default installation @@ -223,6 +224,7 @@ en.ocr=OCR plug-in (needs Microsoft Office Document Imaging (MODI)) en.optimize=Optimizing performance, this may take a while. en.startgreenshot=Start {#ExeName} en.startup=Start {#ExeName} with Windows start +en.win10=Windows 10 plug-in es.confluence=Extensión para Confluence es.default=${default} @@ -234,6 +236,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 fi.confluence=Confluence-liitännäinen fi.default=${default} @@ -246,6 +249,7 @@ fi.ocr=OCR-liitännäinen (Tarvitaan: Microsoft Office Document Imaging (MODI)) fi.optimize=Optimoidaan suorituskykyä, tämä voi kestää hetken. fi.startgreenshot=Käynnistä {#ExeName} fi.startup=Käynnistä {#ExeName} Windowsin käynnistyessä +fi.win10=Windows 10-liitännäinen fr.confluence=Greffon Confluence fr.default=${default} @@ -258,6 +262,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 lt.confluence=Confluence spraudnis lt.default=${default} @@ -270,6 +275,7 @@ lt.ocr=OCR spraudnis (nepieciešams Microsoft Office Document Imaging (MODI)) lt.optimize=Uzlaboju veikstpēju, tas prasīs kādu laiciņu. lt.startgreenshot=Palaist {#ExeName} lt.startup=Palaist {#ExeName} uzsākot darbus +lt.win10=Windows 10 spraudnis nl.confluence=Confluence plug-in nl.default=Default installation @@ -282,6 +288,7 @@ nl.ocr=OCR plug-in (heeft Microsoft Office Document Imaging (MODI) nodig) nl.optimize=Prestaties verbeteren, kan even duren. nl.startgreenshot=Start {#ExeName} nl.startup=Start {#ExeName} wanneer Windows opstart +nl.win10=Windows 10 plug-in nn.confluence=Confluence-tillegg nn.default=Default installation @@ -294,6 +301,7 @@ nn.ocr=OCR-tillegg (krev Microsoft Office Document Imaging (MODI)) nn.optimize=Optimaliserar ytelse, dette kan ta litt tid... nn.startgreenshot=Start {#ExeName} nn.startup=Start {#ExeName} når Windows startar +nn.win10=Windows 10 Tillegg sr.confluence=Прикључак за Конфлуенс sr.default=${default} @@ -305,6 +313,7 @@ sr.ocr=OCR прикључак (захтева Microsoft Office Document Imaging sr.optimize=Оптимизујем перформансе… sr.startgreenshot=Покрени Гриншот sr.startup=Покрени програм са системом +sr.win10=Прикључак за Windows 10 sv.startup=Starta {#ExeName} med Windows sv.startgreenshot=Starta {#ExeName} @@ -315,6 +324,7 @@ sv.ocr=OCR-insticksprogram (kräver Microsoft Office Document Imaging (MODI)) sv.imgur=Imgur-insticksprogram (Se: http://imgur.com) sv.language=Ytterligare språk sv.optimize=Optimerar prestanda, detta kan ta en stund. +sv.win10=Windows 10-insticksprogram uk.confluence=Плагін Confluence uk.default=${default} @@ -326,6 +336,7 @@ uk.ocr=Плагін OCR (потребує Microsoft Office Document Imaging (MOD uk.optimize=Оптимізація продуктивності, це може забрати час. uk.startgreenshot=Запустити {#ExeName} uk.startup=Запускати {#ExeName} під час запуску Windows +uk.win10=Плагін Windows 10 cn.confluence=Confluence插件 cn.default=${default} @@ -337,7 +348,7 @@ cn.ocr=OCR插件(需要Microsoft Office Document Imaging (MODI)的支持) cn.optimize=正在优化性能,这可能需要一点时间。 cn.startgreenshot=启动{#ExeName} cn.startup=让{#ExeName}随Windows一起启动 - +cn.win10=Windows 10插件 [Types] Name: "default"; Description: "{cm:default}" @@ -359,6 +370,7 @@ Name: "plugins\dropbox"; Description: "Dropbox Plugin"; Types: full custom; Flag 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: 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\csCZ"; Description: "Ceština"; Types: full custom; Flags: disablenouninstallwarning; Check: hasLanguageGroup('1') @@ -616,6 +628,21 @@ begin end; Result := true; end; + +function IsWindowsVersionOrNewer(Major, Minor: Integer): Boolean; +var + Version: TWindowsVersion; +begin + GetWindowsVersionEx(Version); + Result := + (Version.Major > Major) or + ((Version.Major = Major) and (Version.Minor >= Minor)); +end; + +function IsWindows10OrNewer: Boolean; +begin + Result := IsWindowsVersionOrNewer(10, 0); +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 diff --git a/GreenshotPlugin/Core/FilenameHelper.cs b/GreenshotPlugin/Core/FilenameHelper.cs index b3ed50181..2016c27af 100644 --- a/GreenshotPlugin/Core/FilenameHelper.cs +++ b/GreenshotPlugin/Core/FilenameHelper.cs @@ -406,7 +406,7 @@ namespace GreenshotPlugin.Core { /// String with pattern %var% /// true to make sure everything is filenamesafe /// Filled string - public static string FillCmdVariables(string pattern, bool filenameSafeMode) + public static string FillCmdVariables(string pattern, bool filenameSafeMode = true) { IDictionary processVars = null; IDictionary userVars = null; diff --git a/GreenshotPlugin/Core/OperatingSystemExtensions.cs b/GreenshotPlugin/Core/OperatingSystemExtensions.cs index ffe07bc6f..678a65058 100644 --- a/GreenshotPlugin/Core/OperatingSystemExtensions.cs +++ b/GreenshotPlugin/Core/OperatingSystemExtensions.cs @@ -38,6 +38,16 @@ namespace GreenshotPlugin.Core return operatingSystem.Version.Major == 10; } + /// + /// Test if the current OS is Windows 10 or later + /// + /// OperatingSystem from Environment.OSVersion + /// true if we are running on Windows 10 or later + public static bool IsWindows10OrLater(this OperatingSystem operatingSystem) + { + return operatingSystem.Version.Major >= 10; + } + /// /// Test if the current OS is Windows 8(.1) /// diff --git a/GreenshotPlugin/Core/PluginUtils.cs b/GreenshotPlugin/Core/PluginUtils.cs index 78d0f1cd5..4ef0fd8ee 100644 --- a/GreenshotPlugin/Core/PluginUtils.cs +++ b/GreenshotPlugin/Core/PluginUtils.cs @@ -99,9 +99,10 @@ namespace GreenshotPlugin.Core { } return null; } - + /// - /// Get icon for executable, from the cache + /// Get icon from resource files, from the cache. + /// Examples can be found here: https://diymediahome.org/windows-icons-reference-list-with-details-locations-images/ /// /// path to the exe or dll /// index of the icon diff --git a/GreenshotWin10Plugin/Win10OcrDestination.cs b/GreenshotWin10Plugin/Win10OcrDestination.cs index e12bcf0fc..52e8b7fef 100644 --- a/GreenshotWin10Plugin/Win10OcrDestination.cs +++ b/GreenshotWin10Plugin/Win10OcrDestination.cs @@ -20,6 +20,7 @@ */ using System; +using System.Drawing; using System.IO; using System.Threading.Tasks; using Windows.Graphics.Imaging; @@ -36,9 +37,14 @@ namespace GreenshotWin10Plugin { private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(Win10OcrDestination)); - public override string Designation { get; } = "OCR"; + public override string Designation { get; } = "WIN10OCR"; public override string Description { get; } = "Windows 10 OCR"; + /// + /// Icon for the OCR function, the icon was found via: http://help4windows.com/windows_8_imageres_dll.shtml + /// + public override Image DisplayIcon=> PluginUtils.GetCachedExeIcon(FilenameHelper.FillCmdVariables(@"%windir%\system32\imageres.dll"), 97); + /// /// Constructor, this is only debug information /// @@ -49,7 +55,6 @@ namespace GreenshotWin10Plugin { Log.DebugFormat("Found language {0} {1}", language.NativeName, language.LanguageTag); } - } /// diff --git a/GreenshotWin10Plugin/Win10Plugin.cs b/GreenshotWin10Plugin/Win10Plugin.cs index 527411d8f..507b7d058 100644 --- a/GreenshotWin10Plugin/Win10Plugin.cs +++ b/GreenshotWin10Plugin/Win10Plugin.cs @@ -55,7 +55,7 @@ namespace GreenshotWin10Plugin /// IEnumerable with the destinations public IEnumerable Destinations() { - if (!Environment.OSVersion.IsWindows10()) + if (!Environment.OSVersion.IsWindows10OrLater()) { yield break; } diff --git a/GreenshotWin10Plugin/Win10ShareDestination.cs b/GreenshotWin10Plugin/Win10ShareDestination.cs index ac790b50c..c96ca7394 100644 --- a/GreenshotWin10Plugin/Win10ShareDestination.cs +++ b/GreenshotWin10Plugin/Win10ShareDestination.cs @@ -29,6 +29,7 @@ using System.Threading.Tasks; using Windows.Storage; using Color = Windows.UI.Color; using System.Collections.Generic; +using System.Drawing; namespace GreenshotWin10Plugin { @@ -39,9 +40,14 @@ namespace GreenshotWin10Plugin { private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(Win10ShareDestination)); - public override string Designation { get; } = "Share"; + public override string Designation { get; } = "WIN10Share"; public override string Description { get; } = "Windows 10 share"; + /// + /// Icon for the App-share, the icon was found via: http://help4windows.com/windows_8_shell32_dll.shtml + /// + public override Image DisplayIcon => PluginUtils.GetCachedExeIcon(FilenameHelper.FillCmdVariables(@"%windir%\system32\shell32.dll"), 238); + /// /// Share the screenshot with a windows app ///