diff --git a/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs b/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
index 738d277ea..5418ecdaa 100644
--- a/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
+++ b/Greenshot/Controls/ContextMenuToolStripProfessionalRenderer.cs
@@ -34,7 +34,10 @@ namespace Greenshot.Controls {
private static Image scaledCheckbox;
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {
- if (scaledCheckbox == null) {
+ if (scaledCheckbox == null || scaledCheckbox.Size != coreConfiguration.IconSize) {
+ if (scaledCheckbox != null) {
+ scaledCheckbox.Dispose();
+ }
scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, coreConfiguration.IconSize.Width, coreConfiguration.IconSize.Height, null);
}
Rectangle old = e.ImageRectangle;
diff --git a/Greenshot/Controls/CustomToolStripProfessionalRenderer.cs b/Greenshot/Controls/CustomToolStripProfessionalRenderer.cs
index ac996cf3b..c2780b525 100644
--- a/Greenshot/Controls/CustomToolStripProfessionalRenderer.cs
+++ b/Greenshot/Controls/CustomToolStripProfessionalRenderer.cs
@@ -1,22 +1,22 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2014 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 .
+/*
+ * Greenshot - a free and open source screenshot tool
+ * Copyright (C) 2007-2014 Thomas Braun, Jens Klingen, Robin Krom
+ *
+ * For more information see: http://getgreenshot.org/
+ * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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;
diff --git a/Greenshot/Forms/MainForm.Designer.cs b/Greenshot/Forms/MainForm.Designer.cs
index b1ada93df..615996a1a 100644
--- a/Greenshot/Forms/MainForm.Designer.cs
+++ b/Greenshot/Forms/MainForm.Designer.cs
@@ -105,7 +105,6 @@ namespace Greenshot {
this.contextMenu.Name = "contextMenu";
this.contextMenu.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.ContextMenuClosing);
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuOpening);
- this.contextMenu.ImageScalingSize = coreConfiguration.IconSize;
this.contextMenu.Renderer = new Greenshot.Controls.ContextMenuToolStripProfessionalRenderer();
//
// contextmenu_capturearea
diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs
index 1eaa229bc..3249482d6 100644
--- a/Greenshot/Forms/MainForm.cs
+++ b/Greenshot/Forms/MainForm.cs
@@ -336,7 +336,7 @@ namespace Greenshot {
public MainForm(CopyDataTransport dataTransport) {
_instance = this;
-
+
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
@@ -388,6 +388,8 @@ namespace Greenshot {
}
SoundHelper.Initialize();
+ MainForm.ResetImageScalingSize();
+
// Set the Greenshot icon visibility depending on the configuration. (Added for feature #3521446)
// Setting it to true this late prevents Problems with the context menu
notifyIcon.Visible = !_conf.HideTrayicon;
@@ -549,6 +551,15 @@ namespace Greenshot {
}
}
+ ///
+ /// Reset ImageScalingSize
+ ///
+ /// Used for fixing scaling issues
+ public static void ResetImageScalingSize() {
+ MainForm thisForm = MainForm.Instance;
+ thisForm.contextMenu.ImageScalingSize = coreConfiguration.IconSize;
+ }
+
///
/// Registers all hotkeys as configured, displaying a dialog in case of hotkey conflicts with other tools.
///
diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs
index 99ba276e4..cbbb61b8a 100644
--- a/Greenshot/Forms/SettingsForm.cs
+++ b/Greenshot/Forms/SettingsForm.cs
@@ -414,7 +414,14 @@ namespace Greenshot {
coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor;
coreConfiguration.UpdateCheckInterval = (int)numericUpDown_daysbetweencheck.Value;
+ Size previousValue = coreConfiguration.IconSize;
coreConfiguration.IconSize = new Size((int)numericUpdownIconSize.Value, (int)numericUpdownIconSize.Value);
+
+ // Clear caches when changing the settings
+ if (previousValue != coreConfiguration.IconSize) {
+ PluginUtils.ClearExeIconCache();
+ MainForm.ResetImageScalingSize();
+ }
coreConfiguration.FixIconSize();
try {
if (checkbox_autostartshortcut.Checked) {
diff --git a/Greenshot/Forms/ToolStripMenuSelectList.cs b/Greenshot/Forms/ToolStripMenuSelectList.cs
index 3d2b0db53..1b84ce7fa 100644
--- a/Greenshot/Forms/ToolStripMenuSelectList.cs
+++ b/Greenshot/Forms/ToolStripMenuSelectList.cs
@@ -35,7 +35,8 @@ namespace Greenshot.Forms {
private static CoreConfiguration coreConfiguration = IniConfig.GetIniSection();
private bool multiCheckAllowed = false;
private bool updateInProgress = false;
- private static Image defaultImage = ImageHelper.CreateEmpty(coreConfiguration.IconSize.Width, coreConfiguration.IconSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb, Color.Transparent, 96f, 96f);
+ private static Image defaultImage;
+
///
/// Occurs when one of the list's child element's Checked state changes.
///
@@ -49,10 +50,16 @@ namespace Greenshot.Forms {
Identifier = identifier;
CheckOnClick = false;
multiCheckAllowed = allowMultiCheck;
+ if (defaultImage == null || defaultImage.Size != coreConfiguration.IconSize) {
+ if (defaultImage != null) {
+ defaultImage.Dispose();
+ }
+ defaultImage = ImageHelper.CreateEmpty(coreConfiguration.IconSize.Width, coreConfiguration.IconSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb, Color.Transparent, 96f, 96f);
+ }
Image = defaultImage;
}
public ToolStripMenuSelectList() : this(null,false) {}
- public ToolStripMenuSelectList(Object identifier) : this(identifier,false) {}
+ public ToolStripMenuSelectList(object identifier) : this(identifier,false) {}
///
/// gets or sets the currently checked item
diff --git a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
index 6e7d6cb05..fd692ca33 100644
--- a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
+++ b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs
@@ -126,7 +126,7 @@ namespace ExternalCommand {
try {
string exePath = PluginUtils.GetExePath("cmd.exe");
if (exePath != null && File.Exists(exePath)) {
- itemPlugInRoot.Image = PluginUtils.GetExeIcon(exePath, 0);
+ itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
}
} catch (Exception ex) {
LOG.Warn("Couldn't get the cmd.exe image", ex);
diff --git a/GreenshotExternalCommandPlugin/IconCache.cs b/GreenshotExternalCommandPlugin/IconCache.cs
index fab1b4c5d..c3e3f16bd 100644
--- a/GreenshotExternalCommandPlugin/IconCache.cs
+++ b/GreenshotExternalCommandPlugin/IconCache.cs
@@ -7,29 +7,21 @@ using GreenshotPlugin.Core;
namespace ExternalCommand {
public static class IconCache {
- private static Dictionary iconCache = new Dictionary();
private static ExternalCommandConfiguration config = IniConfig.GetIniSection();
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
public static Image IconForCommand(string commandName) {
+ Image icon = null;
if (commandName != null) {
- if (!iconCache.ContainsKey(commandName)) {
- Image icon = null;
- if (config.commandlines.ContainsKey(commandName) && File.Exists(config.commandlines[commandName])) {
- try {
- icon = PluginUtils.GetExeIcon(config.commandlines[commandName], 0);
- } catch (Exception ex) {
- LOG.Warn("Problem loading icon for " + config.commandlines[commandName], ex);
- }
+ if (config.commandlines.ContainsKey(commandName) && File.Exists(config.commandlines[commandName])) {
+ try {
+ icon = PluginUtils.GetCachedExeIcon(config.commandlines[commandName], 0);
+ } catch (Exception ex) {
+ LOG.Warn("Problem loading icon for " + config.commandlines[commandName], ex);
}
- // Also add null to the cache if nothing is found
- iconCache.Add(commandName, icon);
- }
- if (iconCache.ContainsKey(commandName)) {
- return iconCache[commandName];
}
}
- return null;
+ return icon;
}
}
}
diff --git a/GreenshotOCRPlugin/OCRDestination.cs b/GreenshotOCRPlugin/OCRDestination.cs
index 15491f5f8..fe53c5d46 100644
--- a/GreenshotOCRPlugin/OCRDestination.cs
+++ b/GreenshotOCRPlugin/OCRDestination.cs
@@ -33,16 +33,8 @@ namespace GreenshotOCR {
private static OCRConfiguration config = IniConfig.GetIniSection();
private const int MIN_WIDTH = 130;
private const int MIN_HEIGHT = 130;
- private static Image icon = null;
private OcrPlugin plugin;
- static OCRDestination() {
- string exePath = PluginUtils.GetExePath("MSPVIEW.EXE");
- if (exePath != null && File.Exists(exePath)) {
- icon = PluginUtils.GetExeIcon(exePath, 0);
- }
- }
-
public override string Designation {
get {
return "OCR";
@@ -57,7 +49,11 @@ namespace GreenshotOCR {
public override Image DisplayIcon {
get {
- return icon;
+ string exePath = PluginUtils.GetExePath("MSPVIEW.EXE");
+ if (exePath != null && File.Exists(exePath)) {
+ return PluginUtils.GetCachedExeIcon(exePath, 0);
+ }
+ return null;
}
}
diff --git a/GreenshotOfficePlugin/Destinations/ExcelDestination.cs b/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
index 447aa00db..b78f48b1e 100644
--- a/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/ExcelDestination.cs
@@ -36,16 +36,14 @@ namespace GreenshotOfficePlugin {
///
public class ExcelDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelDestination));
+ private const int ICON_APPLICATION = 0;
+ private const int ICON_WORKBOOK = 1;
private static string exePath = null;
- private static Image applicationIcon = null;
- private static Image workbookIcon = null;
private string workbookName = null;
static ExcelDestination() {
exePath = PluginUtils.GetExePath("EXCEL.EXE");
if (exePath != null && File.Exists(exePath)) {
- applicationIcon = PluginUtils.GetExeIcon(exePath, 0);
- workbookIcon = PluginUtils.GetExeIcon(exePath, 1);
WindowDetails.AddProcessToExcludeFromFreeze("excel");
} else {
exePath = null;
@@ -96,9 +94,9 @@ namespace GreenshotOfficePlugin {
public override Image DisplayIcon {
get {
if (!string.IsNullOrEmpty(workbookName)) {
- return workbookIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_WORKBOOK);
}
- return applicationIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_APPLICATION);
}
}
diff --git a/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs b/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
index 8b2f96ffe..c335e68a6 100644
--- a/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
@@ -18,32 +18,26 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
+using Greenshot.Interop.Office;
+using Greenshot.Plugin;
+using GreenshotPlugin.Core;
using System;
using System.Collections.Generic;
using System.Drawing;
-using System.Drawing.Imaging;
using System.IO;
-using System.Windows.Forms;
-
-using GreenshotPlugin.Core;
-using Greenshot.Plugin;
-using Greenshot.Interop.Office;
-using Greenshot.IniFile;
namespace GreenshotOfficePlugin {
public class OneNoteDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
+ private const int ICON_APPLICATION = 0;
public const string DESIGNATION = "OneNote";
private static string exePath = null;
- private static Image applicationIcon = null;
- private static Image notebookIcon = null;
private OneNotePage page = null;
static OneNoteDestination() {
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
if (exePath != null && File.Exists(exePath)) {
- applicationIcon = PluginUtils.GetExeIcon(exePath, 0);
- notebookIcon = PluginUtils.GetExeIcon(exePath, 0);
WindowDetails.AddProcessToExcludeFromFreeze("onenote");
} else {
exePath = null;
@@ -94,10 +88,7 @@ namespace GreenshotOfficePlugin {
public override Image DisplayIcon {
get {
- if (page != null) {
- return notebookIcon;
- }
- return applicationIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_APPLICATION);
}
}
diff --git a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
index c3bf5e445..8b4c3c667 100644
--- a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
@@ -18,29 +18,29 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-using System;
+
+using Greenshot.IniFile;
+using Greenshot.Interop.Office;
+using Greenshot.Plugin;
+using GreenshotPlugin.Core;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
-using Greenshot.Interop.Office;
-using Greenshot.Plugin;
-using GreenshotPlugin.Core;
-using Greenshot.IniFile;
-
namespace GreenshotOfficePlugin {
///
/// Description of OutlookDestination.
///
public class OutlookDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookDestination));
+ private const int ICON_APPLICATION = 0;
+ private const int ICON_MEETING = 2;
+
+ private static Image mailIcon = GreenshotPlugin.Core.GreenshotResources.getImage("Email.Image");
private static OfficeConfiguration conf = IniConfig.GetIniSection();
private static string exePath = null;
- private static Image applicationIcon = null;
- private static Image mailIcon = GreenshotPlugin.Core.GreenshotResources.getImage("Email.Image");
- private static Image meetingIcon = null;
private static bool isActiveFlag = false;
private static string mapiClient = "Microsoft Outlook";
public const string DESIGNATION = "Outlook";
@@ -53,11 +53,7 @@ namespace GreenshotOfficePlugin {
}
exePath = PluginUtils.GetExePath("OUTLOOK.EXE");
if (exePath != null && File.Exists(exePath)) {
- applicationIcon = PluginUtils.GetExeIcon(exePath, 0);
WindowDetails.AddProcessToExcludeFromFreeze("outlook");
- if (conf.OutlookAllowExportInMeetings) {
- meetingIcon = PluginUtils.GetExeIcon(exePath, 2);
- }
} else {
exePath = null;
}
@@ -119,15 +115,12 @@ namespace GreenshotOfficePlugin {
if (outlookInspectorCaption != null) {
if (OlObjectClass.olAppointment.Equals(outlookInspectorType)) {
// Make sure we loaded the icon, maybe the configuration has been changed!
- if (meetingIcon == null) {
- meetingIcon = PluginUtils.GetExeIcon(exePath, 2);
- }
- return meetingIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_MEETING);
} else {
return mailIcon;
}
} else {
- return applicationIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_APPLICATION);
}
}
}
diff --git a/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs b/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
index ca0a88c41..c8330f1a9 100644
--- a/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
@@ -36,16 +36,15 @@ namespace GreenshotOfficePlugin {
///
public class PowerpointDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PowerpointDestination));
+ private const int ICON_APPLICATION = 0;
+ private const int ICON_PRESENTATION = 1;
+
private static string exePath = null;
- private static Image applicationIcon = null;
- private static Image presentationIcon = null;
private string presentationName = null;
static PowerpointDestination() {
exePath = PluginUtils.GetExePath("POWERPNT.EXE");
if (exePath != null && File.Exists(exePath)) {
- applicationIcon = PluginUtils.GetExeIcon(exePath, 0);
- presentationIcon = PluginUtils.GetExeIcon(exePath, 1);
WindowDetails.AddProcessToExcludeFromFreeze("powerpnt");
} else {
exePath = null;
@@ -96,10 +95,10 @@ namespace GreenshotOfficePlugin {
public override Image DisplayIcon {
get {
if (!string.IsNullOrEmpty(presentationName)) {
- return presentationIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_PRESENTATION);
}
- return applicationIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_APPLICATION);
}
}
diff --git a/GreenshotOfficePlugin/Destinations/WordDestination.cs b/GreenshotOfficePlugin/Destinations/WordDestination.cs
index 5ec0ea6cf..38635ad17 100644
--- a/GreenshotOfficePlugin/Destinations/WordDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/WordDestination.cs
@@ -18,17 +18,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
+using Greenshot.Interop.Office;
+using Greenshot.Plugin;
+using GreenshotPlugin.Core;
using System;
using System.Collections.Generic;
using System.Drawing;
-using System.Drawing.Imaging;
using System.IO;
-using System.Windows.Forms;
-
-using GreenshotPlugin.Core;
-using Greenshot.Plugin;
-using Greenshot.Interop.Office;
-using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
@@ -37,17 +34,14 @@ namespace GreenshotOfficePlugin {
///
public class WordDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
+ private const int ICON_APPLICATION = 0;
+ private const int ICON_DOCUMENT = 1;
private static string exePath = null;
- private static Image applicationIcon = null;
- private static Image documentIcon = null;
private string documentCaption = null;
static WordDestination() {
exePath = PluginUtils.GetExePath("WINWORD.EXE");
- if (exePath != null && File.Exists(exePath)) {
- applicationIcon = PluginUtils.GetExeIcon(exePath, 0);
- documentIcon = PluginUtils.GetExeIcon(exePath, 1);
- } else {
+ if (exePath != null && !File.Exists(exePath)) {
exePath = null;
}
}
@@ -97,9 +91,9 @@ namespace GreenshotOfficePlugin {
public override Image DisplayIcon {
get {
if (!string.IsNullOrEmpty(documentCaption)) {
- return documentIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_DOCUMENT);
}
- return applicationIcon;
+ return PluginUtils.GetCachedExeIcon(exePath, ICON_APPLICATION);
}
}
diff --git a/GreenshotPlugin/Core/PluginUtils.cs b/GreenshotPlugin/Core/PluginUtils.cs
index 183a345ad..3eefcf11b 100644
--- a/GreenshotPlugin/Core/PluginUtils.cs
+++ b/GreenshotPlugin/Core/PluginUtils.cs
@@ -25,6 +25,7 @@ using GreenshotPlugin.UnmanagedHelpers;
using log4net;
using Microsoft.Win32;
using System;
+using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
@@ -37,6 +38,7 @@ namespace GreenshotPlugin.Core {
private static readonly ILog LOG = LogManager.GetLogger(typeof(PluginUtils));
private static CoreConfiguration conf = IniConfig.GetIniSection();
private const string PATH_KEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
+ private static IDictionary exeIconCache = new Dictionary();
///
/// Simple global property to get the Greenshot host
@@ -46,6 +48,21 @@ namespace GreenshotPlugin.Core {
set;
}
+ public static void ClearExeIconCache() {
+ List cachedImages = new List();
+ lock (exeIconCache) {
+ foreach (string key in exeIconCache.Keys) {
+ cachedImages.Add(exeIconCache[key]);
+ }
+ exeIconCache.Clear();
+ }
+ foreach (Image cachedImage in cachedImages) {
+ if (cachedImage != null) {
+ cachedImage.Dispose();
+ }
+ }
+ }
+
///
/// Get the path of an executable
///
@@ -70,6 +87,28 @@ namespace GreenshotPlugin.Core {
}
return null;
}
+
+ ///
+ /// Get icon for executable, from the cache
+ ///
+ /// path to the exe or dll
+ /// index of the icon
+ /// Bitmap with the icon or null if something happended
+ public static Image GetCachedExeIcon(string path, int index) {
+ string cacheKey = string.Format("{0}:{1}", path, index);
+ Image returnValue;
+ if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
+ lock (exeIconCache) {
+ if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
+ returnValue = GetExeIcon(path, index);
+ if (returnValue != null) {
+ exeIconCache.Add(cacheKey, returnValue);
+ }
+ }
+ }
+ }
+ return returnValue;
+ }
///
/// Get icon for executable
@@ -77,7 +116,7 @@ namespace GreenshotPlugin.Core {
/// path to the exe or dll
/// index of the icon
/// Bitmap with the icon or null if something happended
- public static Bitmap GetExeIcon(string path, int index) {
+ private static Bitmap GetExeIcon(string path, int index) {
if (!File.Exists(path)) {
return null;
}
diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs
index d50ddadeb..0998ef253 100644
--- a/GreenshotPlugin/Core/WindowsHelper.cs
+++ b/GreenshotPlugin/Core/WindowsHelper.cs
@@ -170,7 +170,6 @@ namespace GreenshotPlugin.Core {
private static Dictionary> classnameTree = new Dictionary>();
private static CoreConfiguration conf = IniConfig.GetIniSection();
private static List ignoreHandles = new List();
- private static Dictionary iconCache = new Dictionary();
private static List excludeProcessesFromFreeze = new List();
private static IAppVisibility appVisibility = null;
@@ -204,7 +203,6 @@ namespace GreenshotPlugin.Core {
}
}
-
public bool isGutter {
get {
return METRO_GUTTER_CLASS.Equals(ClassName);
@@ -307,17 +305,7 @@ namespace GreenshotPlugin.Core {
return null;
}
try {
- string filename = ProcessPath;
- if (!iconCache.ContainsKey(filename)) {
- Image icon = null;
- using (Icon appIcon = Shell32.ExtractAssociatedIcon(filename)) {
- if (appIcon != null) {
- icon = appIcon.ToBitmap();
- }
- }
- iconCache.Add(filename, icon);
- }
- return iconCache[filename];
+ return PluginUtils.GetCachedExeIcon(ProcessPath, 0);
} catch (Exception ex) {
LOG.WarnFormat("Couldn't get icon for window {0} due to: {1}", Text, ex.Message);
LOG.Warn(ex);