mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 03:30:02 -07:00
ContextMenu changes for the IE capture and plug-ins
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1997 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
e5e6b3bd43
commit
0ee25e8cac
4 changed files with 24 additions and 13 deletions
|
@ -649,9 +649,12 @@ namespace Greenshot {
|
||||||
/// Build a selectable list of IE tabs when we enter the menu item
|
/// Build a selectable list of IE tabs when we enter the menu item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void CaptureIEMenuDropDownOpening(object sender, EventArgs e) {
|
void CaptureIEMenuDropDownOpening(object sender, EventArgs e) {
|
||||||
|
if (!conf.IECapture) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
List<KeyValuePair<WindowDetails, string>> tabs = IECaptureHelper.GetTabList();
|
List<KeyValuePair<WindowDetails, string>> tabs = IECaptureHelper.GetTabList();
|
||||||
this.contextmenu_captureie.DropDownItems.Clear();
|
this.contextmenu_captureiefromlist.DropDownItems.Clear();
|
||||||
if (tabs.Count > 0) {
|
if (tabs.Count > 0) {
|
||||||
this.contextmenu_captureie.Enabled = true;
|
this.contextmenu_captureie.Enabled = true;
|
||||||
this.contextmenu_captureiefromlist.Enabled = true;
|
this.contextmenu_captureiefromlist.Enabled = true;
|
||||||
|
@ -667,7 +670,7 @@ namespace Greenshot {
|
||||||
}
|
}
|
||||||
captureIETabItem.Tag = new KeyValuePair<WindowDetails, int>(tabData.Key, index++);
|
captureIETabItem.Tag = new KeyValuePair<WindowDetails, int>(tabData.Key, index++);
|
||||||
captureIETabItem.Click += new System.EventHandler(Contextmenu_captureiefromlist_Click);
|
captureIETabItem.Click += new System.EventHandler(Contextmenu_captureiefromlist_Click);
|
||||||
this.contextmenu_captureie.DropDownItems.Add(captureIETabItem);
|
this.contextmenu_captureiefromlist.DropDownItems.Add(captureIETabItem);
|
||||||
if (counter.ContainsKey(tabData.Key)) {
|
if (counter.ContainsKey(tabData.Key)) {
|
||||||
counter[tabData.Key] = index;
|
counter[tabData.Key] = index;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -82,6 +82,9 @@ namespace Greenshot.Helpers {
|
||||||
/// <param name="someWindow"></param>
|
/// <param name="someWindow"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool IsIEWindow(WindowDetails someWindow) {
|
public static bool IsIEWindow(WindowDetails someWindow) {
|
||||||
|
if ("IEFrame".Equals(someWindow.ClassName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return someWindow.GetChild("Internet Explorer_Server") != null;
|
return someWindow.GetChild("Internet Explorer_Server") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +92,7 @@ namespace Greenshot.Helpers {
|
||||||
/// Get Windows displaying an IE
|
/// Get Windows displaying an IE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>List<WindowDetails></returns>
|
/// <returns>List<WindowDetails></returns>
|
||||||
public static List<WindowDetails> GetIEWindows() {
|
public static IEnumerable<WindowDetails> GetIEWindows() {
|
||||||
List<WindowDetails> ieWindows = new List<WindowDetails>();
|
|
||||||
foreach (WindowDetails possibleIEWindow in WindowDetails.GetAllWindows()) {
|
foreach (WindowDetails possibleIEWindow in WindowDetails.GetAllWindows()) {
|
||||||
if (possibleIEWindow.Text.Length == 0) {
|
if (possibleIEWindow.Text.Length == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -99,10 +101,9 @@ namespace Greenshot.Helpers {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (IsIEWindow(possibleIEWindow)) {
|
if (IsIEWindow(possibleIEWindow)) {
|
||||||
ieWindows.Add(possibleIEWindow);
|
yield return possibleIEWindow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ieWindows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -110,7 +111,10 @@ namespace Greenshot.Helpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>bool</returns>
|
/// <returns>bool</returns>
|
||||||
public static bool IsIERunning() {
|
public static bool IsIERunning() {
|
||||||
return GetIEWindows().Count > 0;
|
foreach (WindowDetails ieWindow in GetIEWindows()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -122,8 +126,7 @@ namespace Greenshot.Helpers {
|
||||||
Dictionary<WindowDetails, List<string>> browserWindows = new Dictionary<WindowDetails, List<string>>();
|
Dictionary<WindowDetails, List<string>> browserWindows = new Dictionary<WindowDetails, List<string>>();
|
||||||
|
|
||||||
// Find the IE windows
|
// Find the IE windows
|
||||||
List<WindowDetails> ieWindows = GetIEWindows();
|
foreach (WindowDetails ieWindow in GetIEWindows()) {
|
||||||
foreach (WindowDetails ieWindow in ieWindows) {
|
|
||||||
try {
|
try {
|
||||||
if (!ieHandleList.Contains(ieWindow.Handle)) {
|
if (!ieHandleList.Contains(ieWindow.Handle)) {
|
||||||
WindowDetails directUIWD = IEHelper.GetDirectUI(ieWindow);
|
WindowDetails directUIWD = IEHelper.GetDirectUI(ieWindow);
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace Greenshot.Helpers.IEInterop {
|
||||||
private static CoreConfiguration configuration = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration configuration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static readonly List<string> CAPTURE_TAGS = new List<string>();
|
private static readonly List<string> CAPTURE_TAGS = new List<string>();
|
||||||
private const int E_ACCESSDENIED = unchecked((int)0x80070005L);
|
private const int E_ACCESSDENIED = unchecked((int)0x80070005L);
|
||||||
private static Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
|
private static readonly Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
|
||||||
private static Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E");
|
private static readonly Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E");
|
||||||
private static int counter = 0;
|
private static int counter = 0;
|
||||||
private int id = counter++;
|
private int id = counter++;
|
||||||
private IHTMLDocument2 document2;
|
private IHTMLDocument2 document2;
|
||||||
|
@ -189,7 +189,6 @@ namespace Greenshot.Helpers.IEInterop {
|
||||||
LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY);
|
LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.Warn("Can't get certain properties for documents, using default. due to: ", e);
|
LOG.Warn("Can't get certain properties for documents, using default. due to: ", e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,6 +199,7 @@ namespace Greenshot.Helpers.IEInterop {
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
url = document2.url;
|
url = document2.url;
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -311,7 +311,9 @@ namespace Greenshot.Helpers.IEInterop {
|
||||||
|
|
||||||
// Use IServiceProvider.QueryService to get IWebBrowser2 object.
|
// Use IServiceProvider.QueryService to get IWebBrowser2 object.
|
||||||
Object brws = null;
|
Object brws = null;
|
||||||
sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out brws);
|
Guid webBrowserApp = IID_IWebBrowserApp.Clone();
|
||||||
|
Guid webBrowser2 = IID_IWebBrowser2.Clone();
|
||||||
|
sp.QueryService(ref webBrowserApp, ref webBrowser2, out brws);
|
||||||
|
|
||||||
// Get the document from IWebBrowser2.
|
// Get the document from IWebBrowser2.
|
||||||
IWebBrowser2 browser = (IWebBrowser2)(brws);
|
IWebBrowser2 browser = (IWebBrowser2)(brws);
|
||||||
|
|
|
@ -105,8 +105,11 @@ namespace GreenshotPlugin.Core {
|
||||||
// Check if we need to add a new separator, which is done if the first found has a Tag with the value "PluginsAreAddedBefore"
|
// Check if we need to add a new separator, which is done if the first found has a Tag with the value "PluginsAreAddedBefore"
|
||||||
if ("PluginsAreAddedBefore".Equals(contextMenu.Items[i].Tag)) {
|
if ("PluginsAreAddedBefore".Equals(contextMenu.Items[i].Tag)) {
|
||||||
ToolStripSeparator separator = new ToolStripSeparator();
|
ToolStripSeparator separator = new ToolStripSeparator();
|
||||||
|
separator.Tag = "PluginsAreAddedAfter";
|
||||||
separator.Size = new Size(305, 6);
|
separator.Size = new Size(305, 6);
|
||||||
contextMenu.Items.Insert(i, separator);
|
contextMenu.Items.Insert(i, separator);
|
||||||
|
} else if (!"PluginsAreAddedAfter".Equals(contextMenu.Items[i].Tag)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
contextMenu.Items.Insert(i + 1, item);
|
contextMenu.Items.Insert(i + 1, item);
|
||||||
addedItem = true;
|
addedItem = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue