From f7c73932f289f56d1e03e0c0c3fbb4a3dbb2dada Mon Sep 17 00:00:00 2001 From: RKrom Date: Tue, 15 Jan 2013 15:56:16 +0000 Subject: [PATCH] Fixed Context-Menu issues with the sub-menu arriving on the second screen, this is only a work-around (cutting the string to max 25 characters). Also added an icon for the "capture IE from list", as this might have different applications available. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2430 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Forms/MainForm.cs | 34 ++++++++++++++++------- GreenshotPlugin/Core/CoreConfiguration.cs | 3 ++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index a14d6099d..c74d9b49a 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -677,13 +677,21 @@ namespace Greenshot { Dictionary counter = new Dictionary(); foreach(KeyValuePair tabData in tabs) { - ToolStripMenuItem captureIETabItem = new ToolStripMenuItem(tabData.Value); + string title = tabData.Value; + if (title == null) { + continue; + } + if (title.Length > conf.MaxMenuItemLength) { + title = title.Substring(0, Math.Min(title.Length, conf.MaxMenuItemLength)); + } + ToolStripItem captureIETabItem = contextmenu_captureiefromlist.DropDownItems.Add(title); int index; if (counter.ContainsKey(tabData.Key)) { index = counter[tabData.Key]; } else { index = 0; } + captureIETabItem.Image = tabData.Key.DisplayIcon; captureIETabItem.Tag = new KeyValuePair(tabData.Key, index++); captureIETabItem.Click += new System.EventHandler(Contextmenu_captureiefromlist_Click); this.contextmenu_captureiefromlist.DropDownItems.Add(captureIETabItem); @@ -809,16 +817,22 @@ namespace Greenshot { List windows = WindowDetails.GetTopLevelWindows(); foreach(WindowDetails window in windows) { - ToolStripMenuItem captureWindowItem = new ToolStripMenuItem(window.Text); - captureWindowItem.Tag = window; - captureWindowItem.Image = window.DisplayIcon; - captureWindowItem.Click += new System.EventHandler(eventHandler); - // Only show preview when enabled - if (thumbnailPreview) { - captureWindowItem.MouseEnter += new System.EventHandler(ShowThumbnailOnEnter); - captureWindowItem.MouseLeave += new System.EventHandler(HideThumbnailOnLeave); + + string title = window.Text; + if (title != null) { + if (title.Length > conf.MaxMenuItemLength) { + title = title.Substring(0, Math.Min(title.Length, conf.MaxMenuItemLength)); + } + ToolStripItem captureWindowItem = menuItem.DropDownItems.Add(title); + captureWindowItem.Tag = window; + captureWindowItem.Image = window.DisplayIcon; + captureWindowItem.Click += new System.EventHandler(eventHandler); + // Only show preview when enabled + if (thumbnailPreview) { + captureWindowItem.MouseEnter += new System.EventHandler(ShowThumbnailOnEnter); + captureWindowItem.MouseLeave += new System.EventHandler(HideThumbnailOnLeave); + } } - menuItem.DropDownItems.Add(captureWindowItem); } } diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index d58ccfaf3..40c232279 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -219,6 +219,9 @@ namespace GreenshotPlugin.Core { [IniProperty("ZoomerEnabled", Description = "Sets if the zoomer is enabled", DefaultValue = "True")] public bool ZoomerEnabled; + [IniProperty("MaxMenuItemLength", Description = "Maximum length of submenu items in the context menu, making this longer might cause context menu issues on dual screen systems.", DefaultValue = "25")] + public int MaxMenuItemLength; + // Specifies what THIS build is public BuildStates BuildState = BuildStates.UNSTABLE;