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:
RKrom 2012-08-16 16:03:32 +00:00
parent e5e6b3bd43
commit 0ee25e8cac
4 changed files with 24 additions and 13 deletions

View file

@ -649,9 +649,12 @@ namespace Greenshot {
/// Build a selectable list of IE tabs when we enter the menu item
/// </summary>
void CaptureIEMenuDropDownOpening(object sender, EventArgs e) {
if (!conf.IECapture) {
return;
}
try {
List<KeyValuePair<WindowDetails, string>> tabs = IECaptureHelper.GetTabList();
this.contextmenu_captureie.DropDownItems.Clear();
this.contextmenu_captureiefromlist.DropDownItems.Clear();
if (tabs.Count > 0) {
this.contextmenu_captureie.Enabled = true;
this.contextmenu_captureiefromlist.Enabled = true;
@ -667,7 +670,7 @@ namespace Greenshot {
}
captureIETabItem.Tag = new KeyValuePair<WindowDetails, int>(tabData.Key, index++);
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)) {
counter[tabData.Key] = index;
} else {

View file

@ -82,6 +82,9 @@ namespace Greenshot.Helpers {
/// <param name="someWindow"></param>
/// <returns></returns>
public static bool IsIEWindow(WindowDetails someWindow) {
if ("IEFrame".Equals(someWindow.ClassName)) {
return true;
}
return someWindow.GetChild("Internet Explorer_Server") != null;
}
@ -89,8 +92,7 @@ namespace Greenshot.Helpers {
/// Get Windows displaying an IE
/// </summary>
/// <returns>List<WindowDetails></returns>
public static List<WindowDetails> GetIEWindows() {
List<WindowDetails> ieWindows = new List<WindowDetails>();
public static IEnumerable<WindowDetails> GetIEWindows() {
foreach (WindowDetails possibleIEWindow in WindowDetails.GetAllWindows()) {
if (possibleIEWindow.Text.Length == 0) {
continue;
@ -99,10 +101,9 @@ namespace Greenshot.Helpers {
continue;
}
if (IsIEWindow(possibleIEWindow)) {
ieWindows.Add(possibleIEWindow);
yield return possibleIEWindow;
}
}
return ieWindows;
}
/// <summary>
@ -110,7 +111,10 @@ namespace Greenshot.Helpers {
/// </summary>
/// <returns>bool</returns>
public static bool IsIERunning() {
return GetIEWindows().Count > 0;
foreach (WindowDetails ieWindow in GetIEWindows()) {
return true;
}
return false;
}
/// <summary>
@ -122,8 +126,7 @@ namespace Greenshot.Helpers {
Dictionary<WindowDetails, List<string>> browserWindows = new Dictionary<WindowDetails, List<string>>();
// Find the IE windows
List<WindowDetails> ieWindows = GetIEWindows();
foreach (WindowDetails ieWindow in ieWindows) {
foreach (WindowDetails ieWindow in GetIEWindows()) {
try {
if (!ieHandleList.Contains(ieWindow.Handle)) {
WindowDetails directUIWD = IEHelper.GetDirectUI(ieWindow);

View file

@ -42,8 +42,8 @@ namespace Greenshot.Helpers.IEInterop {
private static CoreConfiguration configuration = IniConfig.GetIniSection<CoreConfiguration>();
private static readonly List<string> CAPTURE_TAGS = new List<string>();
private const int E_ACCESSDENIED = unchecked((int)0x80070005L);
private static 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_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
private static readonly Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E");
private static int counter = 0;
private int id = counter++;
private IHTMLDocument2 document2;
@ -189,7 +189,6 @@ namespace Greenshot.Helpers.IEInterop {
LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY);
} catch (Exception e) {
LOG.Warn("Can't get certain properties for documents, using default. due to: ", e);
}
@ -200,6 +199,7 @@ namespace Greenshot.Helpers.IEInterop {
}
} catch {
}
try {
url = document2.url;
} catch {
@ -311,7 +311,9 @@ namespace Greenshot.Helpers.IEInterop {
// Use IServiceProvider.QueryService to get IWebBrowser2 object.
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.
IWebBrowser2 browser = (IWebBrowser2)(brws);

View file

@ -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"
if ("PluginsAreAddedBefore".Equals(contextMenu.Items[i].Tag)) {
ToolStripSeparator separator = new ToolStripSeparator();
separator.Tag = "PluginsAreAddedAfter";
separator.Size = new Size(305, 6);
contextMenu.Items.Insert(i, separator);
} else if (!"PluginsAreAddedAfter".Equals(contextMenu.Items[i].Tag)) {
continue;
}
contextMenu.Items.Insert(i + 1, item);
addedItem = true;