mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
This change should make the UI Icon Size setting dynamic, clearing all cached icons when the size changes (in the settings UI) so if they have a dynamic size the best is selected.
This commit is contained in:
parent
c50e5fa5ab
commit
61c2921b2a
16 changed files with 140 additions and 123 deletions
|
@ -7,29 +7,21 @@ using GreenshotPlugin.Core;
|
|||
|
||||
namespace ExternalCommand {
|
||||
public static class IconCache {
|
||||
private static Dictionary<string, Image> iconCache = new Dictionary<string, Image>();
|
||||
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue