mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Improved differentiating office icons, the actual application has a different icon as the "document". For Outlook this is even different for the email & meeting.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1666 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
9bf9c0b8d3
commit
be0569bb21
8 changed files with 117 additions and 47 deletions
|
@ -40,12 +40,15 @@ namespace Greenshot.Destinations {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(EmailDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(EmailDestination));
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static string exePath = null;
|
private static string exePath = null;
|
||||||
private static Image icon = null;
|
private static Image applicationIcon = null;
|
||||||
|
private static Image mailIcon = null;
|
||||||
|
private static Image meetingIcon = null;
|
||||||
private static bool isActiveFlag = false;
|
private static bool isActiveFlag = false;
|
||||||
private static bool isOutlookUsed = false;
|
private static bool isOutlookUsed = false;
|
||||||
private static string mapiClient = null;
|
private static string mapiClient = null;
|
||||||
public const string DESIGNATION = "EMail";
|
public const string DESIGNATION = "EMail";
|
||||||
private string outlookInspectorCaption = null;
|
private string outlookInspectorCaption;
|
||||||
|
private OlObjectClass outlookInspectorType;
|
||||||
private ILanguage lang = Language.GetInstance();
|
private ILanguage lang = Language.GetInstance();
|
||||||
|
|
||||||
static EmailDestination() {
|
static EmailDestination() {
|
||||||
|
@ -63,11 +66,15 @@ namespace Greenshot.Destinations {
|
||||||
isActiveFlag = true;
|
isActiveFlag = true;
|
||||||
isOutlookUsed = true;
|
isOutlookUsed = true;
|
||||||
}
|
}
|
||||||
|
// Use default email icon
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
|
||||||
|
mailIcon = ((System.Drawing.Image)(resources.GetObject("btnEmail.Image")));
|
||||||
|
|
||||||
if (isOutlookUsed) {
|
if (isOutlookUsed) {
|
||||||
exePath = GetExePath("OUTLOOK.EXE");
|
exePath = GetExePath("OUTLOOK.EXE");
|
||||||
if (exePath != null && File.Exists(exePath)) {
|
if (exePath != null && File.Exists(exePath)) {
|
||||||
icon = GetExeIcon(exePath);
|
applicationIcon = GetExeIcon(exePath, 0);
|
||||||
|
meetingIcon = GetExeIcon(exePath, 2);
|
||||||
} else {
|
} else {
|
||||||
exePath = null;
|
exePath = null;
|
||||||
}
|
}
|
||||||
|
@ -80,16 +87,16 @@ namespace Greenshot.Destinations {
|
||||||
}
|
}
|
||||||
if (isActiveFlag && !isOutlookUsed) {
|
if (isActiveFlag && !isOutlookUsed) {
|
||||||
// Use default email icon
|
// Use default email icon
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
|
applicationIcon = mailIcon;
|
||||||
icon = ((System.Drawing.Image)(resources.GetObject("btnEmail.Image")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmailDestination() {
|
public EmailDestination() {
|
||||||
|
|
||||||
}
|
}
|
||||||
public EmailDestination(string outlookInspectorCaption) {
|
public EmailDestination(string outlookInspectorCaption, OlObjectClass outlookInspectorType) {
|
||||||
this.outlookInspectorCaption = outlookInspectorCaption;
|
this.outlookInspectorCaption = outlookInspectorCaption;
|
||||||
|
this.outlookInspectorType = outlookInspectorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Designation {
|
public override string Designation {
|
||||||
|
@ -108,7 +115,7 @@ namespace Greenshot.Destinations {
|
||||||
if (outlookInspectorCaption == null) {
|
if (outlookInspectorCaption == null) {
|
||||||
return mapiClient;
|
return mapiClient;
|
||||||
} else {
|
} else {
|
||||||
return mapiClient + " - " + outlookInspectorCaption;
|
return outlookInspectorCaption;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +146,15 @@ namespace Greenshot.Destinations {
|
||||||
|
|
||||||
public override Image DisplayIcon {
|
public override Image DisplayIcon {
|
||||||
get {
|
get {
|
||||||
return icon;
|
if (isOutlookUsed && outlookInspectorCaption != null) {
|
||||||
|
if (OlObjectClass.olAppointment.Equals(outlookInspectorType)) {
|
||||||
|
return meetingIcon;
|
||||||
|
} else {
|
||||||
|
return mailIcon;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return applicationIcon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,10 +162,10 @@ namespace Greenshot.Destinations {
|
||||||
if (!isOutlookUsed) {
|
if (!isOutlookUsed) {
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
List<string> inspectorCaptions = OutlookExporter.RetrievePossibleTargets();
|
Dictionary<string, OlObjectClass> inspectorCaptions = OutlookExporter.RetrievePossibleTargets();
|
||||||
if (inspectorCaptions != null) {
|
if (inspectorCaptions != null) {
|
||||||
foreach (string inspectorCaption in inspectorCaptions) {
|
foreach (string inspectorCaption in inspectorCaptions.Keys) {
|
||||||
yield return new EmailDestination(inspectorCaption);
|
yield return new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,14 +39,16 @@ namespace Greenshot.Destinations {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelDestination));
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static string exePath = null;
|
private static string exePath = null;
|
||||||
private static Image icon = null;
|
private static Image applicationIcon = null;
|
||||||
|
private static Image workbookIcon = null;
|
||||||
private ILanguage lang = Language.GetInstance();
|
private ILanguage lang = Language.GetInstance();
|
||||||
private string workbookName = null;
|
private string workbookName = null;
|
||||||
|
|
||||||
static ExcelDestination() {
|
static ExcelDestination() {
|
||||||
exePath = GetExePath("EXCEL.EXE");
|
exePath = GetExePath("EXCEL.EXE");
|
||||||
if (exePath != null && File.Exists(exePath)) {
|
if (exePath != null && File.Exists(exePath)) {
|
||||||
icon = GetExeIcon(exePath);
|
applicationIcon = GetExeIcon(exePath, 0);
|
||||||
|
workbookIcon = GetExeIcon(exePath, 1);
|
||||||
} else {
|
} else {
|
||||||
exePath = null;
|
exePath = null;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +72,7 @@ namespace Greenshot.Destinations {
|
||||||
if (workbookName == null) {
|
if (workbookName == null) {
|
||||||
return "Microsoft Excel";
|
return "Microsoft Excel";
|
||||||
} else {
|
} else {
|
||||||
return "Microsoft Excel - " + workbookName;
|
return workbookName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +97,10 @@ namespace Greenshot.Destinations {
|
||||||
|
|
||||||
public override Image DisplayIcon {
|
public override Image DisplayIcon {
|
||||||
get {
|
get {
|
||||||
return icon;
|
if (!string.IsNullOrEmpty(workbookName)) {
|
||||||
|
return workbookIcon;
|
||||||
|
}
|
||||||
|
return applicationIcon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,16 @@ namespace Greenshot.Destinations {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PowerpointDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PowerpointDestination));
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static string exePath = null;
|
private static string exePath = null;
|
||||||
private static Image icon = null;
|
private static Image applicationIcon = null;
|
||||||
|
private static Image presentationIcon = null;
|
||||||
private ILanguage lang = Language.GetInstance();
|
private ILanguage lang = Language.GetInstance();
|
||||||
private string presentationName = null;
|
private string presentationName = null;
|
||||||
|
|
||||||
static PowerpointDestination() {
|
static PowerpointDestination() {
|
||||||
exePath = GetExePath("POWERPNT.EXE");
|
exePath = GetExePath("POWERPNT.EXE");
|
||||||
if (exePath != null && File.Exists(exePath)) {
|
if (exePath != null && File.Exists(exePath)) {
|
||||||
icon = GetExeIcon(exePath);
|
applicationIcon = GetExeIcon(exePath, 0);
|
||||||
|
presentationIcon = GetExeIcon(exePath, 1);
|
||||||
} else {
|
} else {
|
||||||
exePath = null;
|
exePath = null;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +72,7 @@ namespace Greenshot.Destinations {
|
||||||
if (presentationName == null) {
|
if (presentationName == null) {
|
||||||
return "Microsoft Powerpoint";
|
return "Microsoft Powerpoint";
|
||||||
} else {
|
} else {
|
||||||
return "Microsoft Powerpoint - " + presentationName;
|
return presentationName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +97,11 @@ namespace Greenshot.Destinations {
|
||||||
|
|
||||||
public override Image DisplayIcon {
|
public override Image DisplayIcon {
|
||||||
get {
|
get {
|
||||||
return icon;
|
if (!string.IsNullOrEmpty(presentationName)) {
|
||||||
|
return presentationIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
return applicationIcon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,16 @@ namespace Greenshot.Destinations {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static string exePath = null;
|
private static string exePath = null;
|
||||||
private static Image icon = null;
|
private static Image applicationIcon = null;
|
||||||
|
private static Image documentIcon = null;
|
||||||
private ILanguage lang = Language.GetInstance();
|
private ILanguage lang = Language.GetInstance();
|
||||||
private string wordCaption = null;
|
private string documentCaption = null;
|
||||||
|
|
||||||
static WordDestination() {
|
static WordDestination() {
|
||||||
exePath = GetExePath("WINWORD.EXE");
|
exePath = GetExePath("WINWORD.EXE");
|
||||||
if (exePath != null && File.Exists(exePath)) {
|
if (exePath != null && File.Exists(exePath)) {
|
||||||
icon = GetExeIcon(exePath);
|
applicationIcon = GetExeIcon(exePath, 0);
|
||||||
|
documentIcon = GetExeIcon(exePath, 1);
|
||||||
} else {
|
} else {
|
||||||
exePath = null;
|
exePath = null;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +60,7 @@ namespace Greenshot.Destinations {
|
||||||
}
|
}
|
||||||
|
|
||||||
public WordDestination(string wordCaption) {
|
public WordDestination(string wordCaption) {
|
||||||
this.wordCaption = wordCaption;
|
this.documentCaption = wordCaption;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Designation {
|
public override string Designation {
|
||||||
|
@ -69,10 +71,10 @@ namespace Greenshot.Destinations {
|
||||||
|
|
||||||
public override string Description {
|
public override string Description {
|
||||||
get {
|
get {
|
||||||
if (wordCaption == null) {
|
if (documentCaption == null) {
|
||||||
return "Microsoft Word";
|
return "Microsoft Word";
|
||||||
} else {
|
} else {
|
||||||
return "Microsoft Word - " + wordCaption;
|
return documentCaption;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +99,10 @@ namespace Greenshot.Destinations {
|
||||||
|
|
||||||
public override Image DisplayIcon {
|
public override Image DisplayIcon {
|
||||||
get {
|
get {
|
||||||
return icon;
|
if (!string.IsNullOrEmpty(documentCaption)) {
|
||||||
|
return documentIcon;
|
||||||
|
}
|
||||||
|
return applicationIcon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +119,8 @@ namespace Greenshot.Destinations {
|
||||||
tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality);
|
tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wordCaption != null) {
|
if (documentCaption != null) {
|
||||||
WordExporter.InsertIntoExistingDocument(wordCaption, tmpFile);
|
WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
|
||||||
} else {
|
} else {
|
||||||
WordExporter.InsertIntoNewDocument(tmpFile);
|
WordExporter.InsertIntoNewDocument(tmpFile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ namespace Greenshot.Helpers.OfficeInterop {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="outlookApplication">IOutlookApplication</param>
|
/// <param name="outlookApplication">IOutlookApplication</param>
|
||||||
/// <returns>List<string> with inspector captions (window title)</returns>
|
/// <returns>List<string> with inspector captions (window title)</returns>
|
||||||
public static List<string> RetrievePossibleTargets() {
|
public static Dictionary<string, OlObjectClass> RetrievePossibleTargets() {
|
||||||
List<string> inspectorCaptions = new List<string>();
|
Dictionary<string, OlObjectClass> inspectorCaptions = new Dictionary<string, OlObjectClass>();
|
||||||
try {
|
try {
|
||||||
using ( IOutlookApplication outlookApplication = GetOutlookApplication()) {
|
using ( IOutlookApplication outlookApplication = GetOutlookApplication()) {
|
||||||
if (outlookApplication == null) {
|
if (outlookApplication == null) {
|
||||||
|
@ -124,7 +124,9 @@ namespace Greenshot.Helpers.OfficeInterop {
|
||||||
for(int i=1; i <= inspectors.Count; i++) {
|
for(int i=1; i <= inspectors.Count; i++) {
|
||||||
Inspector inspector = outlookApplication.Inspectors[i];
|
Inspector inspector = outlookApplication.Inspectors[i];
|
||||||
if (canExportToInspector(inspector)) {
|
if (canExportToInspector(inspector)) {
|
||||||
inspectorCaptions.Add(inspector.Caption);
|
Item currentItem = inspector.CurrentItem;
|
||||||
|
OlObjectClass currentItemClass = currentItem.Class;
|
||||||
|
inspectorCaptions.Add(inspector.Caption, currentItemClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +152,7 @@ namespace Greenshot.Helpers.OfficeInterop {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (outlookVersion.Major >=12 && OlObjectClass.olAppointment.Equals(currentItemClass)) {
|
} else if (outlookVersion.Major >=12 && OlObjectClass.olAppointment.Equals(currentItemClass)) {
|
||||||
if (currentUser != null && currentUser.Equals(currentItem.Organizer)) {
|
if (string.IsNullOrEmpty(currentItem.Organizer) || (currentUser == null && currentUser.Equals(currentItem.Organizer))) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LOG.DebugFormat("Not exporting to {0}, as organizer is {1} and currentuser {2}", inspector.Caption, currentItem.Organizer, currentUser);
|
LOG.DebugFormat("Not exporting to {0}, as organizer is {1} and currentuser {2}", inspector.Caption, currentItem.Organizer, currentUser);
|
||||||
|
|
|
@ -3,7 +3,7 @@ Greenshot: A screenshot tool optimized for productivity. Save a screenshot or a
|
||||||
|
|
||||||
CHANGE LOG:
|
CHANGE LOG:
|
||||||
|
|
||||||
0.9.0 Build 1660
|
0.9.0 Build 1667
|
||||||
|
|
||||||
We changed the version to 0.9.0 as the amount of features in 0.8.1 was more than planned.
|
We changed the version to 0.9.0 as the amount of features in 0.8.1 was more than planned.
|
||||||
|
|
||||||
|
|
|
@ -51,19 +51,21 @@ namespace GreenshotPlugin.Core {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internaly used to create an icon
|
/// Internaly used to create an icon
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path"></param>
|
/// <param name="path">path to the exe or dll</param>
|
||||||
/// <returns></returns>
|
/// <param name="index">index of the icon</param>
|
||||||
public static Bitmap GetExeIcon(string path) {
|
/// <returns>Bitmap with the icon or null if something happended</returns>
|
||||||
|
public static Bitmap GetExeIcon(string path, int index) {
|
||||||
if (!File.Exists(path)) {
|
if (!File.Exists(path)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
using (Icon appIcon = Icon.ExtractAssociatedIcon(path)) {
|
using (Icon appIcon = ImageHelper.ExtractAssociatedIcon(path, index, false)) {
|
||||||
if (appIcon != null) {
|
if (appIcon != null) {
|
||||||
return appIcon.ToBitmap();
|
return appIcon.ToBitmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (Exception exIcon) {
|
||||||
|
LOG.Error("error retrieving icon: ", exIcon);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,20 +268,55 @@ namespace GreenshotPlugin.Core {
|
||||||
return bmpPngExtracted;
|
return bmpPngExtracted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Icon ExtractAssociatedIcon(this Icon icon, string location) {
|
/// <summary>
|
||||||
|
/// See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms648069%28v=vs.85%29.aspx
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="icon">The icon to </param>
|
||||||
|
/// <param name="location">The file (EXE or DLL) to get the icon from</param>
|
||||||
|
/// <param name="index">Index of the icon</param>
|
||||||
|
/// <param name="takeLarge">true if the large icon is wanted</param>
|
||||||
|
/// <returns>Icon</returns>
|
||||||
|
public static Icon ExtractAssociatedIcon(string location, int index, bool takeLarge) {
|
||||||
IntPtr large;
|
IntPtr large;
|
||||||
IntPtr small;
|
IntPtr small;
|
||||||
Shell32.ExtractIconEx(location, 0, out large, out small, 1);
|
Shell32.ExtractIconEx(location, index, out large, out small, 1);
|
||||||
Icon returnIcon = Icon.FromHandle(small);
|
Icon returnIcon = null;
|
||||||
if (!IntPtr.Zero.Equals(small)){
|
bool isLarge = false;
|
||||||
User32.DestroyIcon(small);
|
bool isSmall = false;
|
||||||
}
|
try {
|
||||||
if (!IntPtr.Zero.Equals(large)){
|
if (takeLarge && !IntPtr.Zero.Equals(large)) {
|
||||||
User32.DestroyIcon(large);
|
returnIcon = Icon.FromHandle(large);
|
||||||
|
isLarge = true;
|
||||||
|
} else if (!IntPtr.Zero.Equals(small)) {
|
||||||
|
returnIcon = Icon.FromHandle(small);
|
||||||
|
isSmall = true;
|
||||||
|
} else if (!IntPtr.Zero.Equals(large)) {
|
||||||
|
returnIcon = Icon.FromHandle(large);
|
||||||
|
isLarge = true;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (isLarge && !IntPtr.Zero.Equals(small)) {
|
||||||
|
User32.DestroyIcon(small);
|
||||||
|
}
|
||||||
|
if (isSmall && !IntPtr.Zero.Equals(large)) {
|
||||||
|
User32.DestroyIcon(large);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return returnIcon;
|
return returnIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the number of icon in the file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="icon"></param>
|
||||||
|
/// <param name="location">Location of the EXE or DLL</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int CountAssociatedIcons(string location) {
|
||||||
|
IntPtr large = IntPtr.Zero;
|
||||||
|
IntPtr small = IntPtr.Zero;
|
||||||
|
return Shell32.ExtractIconEx(location, -1, out large, out small, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make the picture look like it's torn
|
/// Make the picture look like it's torn
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue