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;