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:
RKrom 2014-11-11 13:23:59 +01:00
commit 61c2921b2a
16 changed files with 140 additions and 123 deletions

View file

@ -36,16 +36,14 @@ namespace GreenshotOfficePlugin {
/// </summary>
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);
}
}

View file

@ -18,32 +18,26 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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);
}
}

View file

@ -18,29 +18,29 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 {
/// <summary>
/// Description of OutlookDestination.
/// </summary>
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<OfficeConfiguration>();
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);
}
}
}

View file

@ -36,16 +36,15 @@ namespace GreenshotOfficePlugin {
/// </summary>
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);
}
}

View file

@ -18,17 +18,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 {
/// </summary>
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);
}
}