Improved new IE logic a bit, fine-tuning...

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1976 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-08-07 15:02:09 +00:00
commit 7fa34e04e9
2 changed files with 50 additions and 44 deletions

View file

@ -678,7 +678,7 @@ namespace Greenshot.Helpers {
// 3) Otherwise use GDI (Screen might be also okay but might lose content) // 3) Otherwise use GDI (Screen might be also okay but might lose content)
if (isAutoMode) { if (isAutoMode) {
// TODO: Decided if this is smart, although we do consider a part of the window... // TODO: Decided if this is smart, although we do consider a part of the window...
if (conf.IECapture && IECaptureHelper.IsMostlyIEWindow(windowToCapture, 60)) { if (conf.IECapture && IECaptureHelper.IsMostlyIEWindow(windowToCapture, 75)) {
try { try {
ICapture ieCapture = IECaptureHelper.CaptureIE(captureForWindow, windowToCapture); ICapture ieCapture = IECaptureHelper.CaptureIE(captureForWindow, windowToCapture);
if (ieCapture != null) { if (ieCapture != null) {

View file

@ -56,55 +56,61 @@ namespace Greenshot.Helpers {
ieAccessible.ActivateIETab(tabIndex); ieAccessible.ActivateIETab(tabIndex);
} }
/// <summary> /// <summary>
/// Return true if the supplied window has a sub-window which covers more than the supplied percentage /// Return true if the supplied window has a sub-window which covers more than the supplied percentage
/// </summary> /// </summary>
/// <param name="someWindow">WindowDetails to check</param> /// <param name="someWindow">WindowDetails to check</param>
/// <param name="minimumPercentage">min percentage</param> /// <param name="minimumPercentage">min percentage</param>
/// <returns></returns> /// <returns></returns>
public static bool IsMostlyIEWindow(WindowDetails someWindow, int minimumPercentage) { public static bool IsMostlyIEWindow(WindowDetails someWindow, int minimumPercentage) {
WindowDetails ieWindow = someWindow.GetChild("Internet Explorer_Server"); WindowDetails ieWindow = someWindow.GetChild("Internet Explorer_Server");
if (ieWindow != null) { if (ieWindow != null) {
Rectangle wholeClient = someWindow.ClientRectangle; Rectangle wholeClient = someWindow.ClientRectangle;
Rectangle partClient = ieWindow.ClientRectangle; Rectangle partClient = ieWindow.ClientRectangle;
int percentage = (int)(100*((float)(partClient.Width * partClient.Height)) / ((float)(wholeClient.Width * wholeClient.Height))); int percentage = (int)(100*((float)(partClient.Width * partClient.Height)) / ((float)(wholeClient.Width * wholeClient.Height)));
LOG.InfoFormat("Window {0}, ie part {1}, percentage {2}", wholeClient, partClient, percentage); LOG.InfoFormat("Window {0}, ie part {1}, percentage {2}", wholeClient, partClient, percentage);
if (percentage > minimumPercentage) { if (percentage > minimumPercentage) {
return true; return true;
} }
} }
return false; return false;
} }
/// <summary> /// <summary>
/// Does the supplied window have a IE part? /// Does the supplied window have a IE part?
/// </summary> /// </summary>
/// <param name="someWindow"></param> /// <param name="someWindow"></param>
/// <returns></returns> /// <returns></returns>
public static bool IsIEWindow(WindowDetails someWindow) { public static bool IsIEWindow(WindowDetails someWindow) {
return someWindow.GetChild("Internet Explorer_Server") != null; return someWindow.GetChild("Internet Explorer_Server") != null;
} }
/// <summary> /// <summary>
/// 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 List<WindowDetails> GetIEWindows() {
List<WindowDetails> ieWindows = new List<WindowDetails>(); List<WindowDetails> ieWindows = new List<WindowDetails>();
foreach (WindowDetails possibleIEWindow in WindowDetails.GetVisibleWindows()) { foreach (WindowDetails possibleIEWindow in WindowDetails.GetAllWindows()) {
if (IsIEWindow(possibleIEWindow)) { if (possibleIEWindow.Text.Length == 0) {
ieWindows.Add(possibleIEWindow); continue;
} }
} if (possibleIEWindow.ClientRectangle.IsEmpty) {
return ieWindows; continue;
} }
if (IsIEWindow(possibleIEWindow)) {
ieWindows.Add(possibleIEWindow);
}
}
return ieWindows;
}
/// <summary> /// <summary>
/// Simple check if IE is running /// Simple check if IE is running
/// </summary> /// </summary>
/// <returns>bool</returns> /// <returns>bool</returns>
public static bool IsIERunning() { public static bool IsIERunning() {
return GetIEWindows().Count > 0; return GetIEWindows().Count > 0;
} }
/// <summary> /// <summary>
@ -116,7 +122,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(); List<WindowDetails> ieWindows = GetIEWindows();
foreach (WindowDetails ieWindow in ieWindows) { foreach (WindowDetails ieWindow in ieWindows) {
try { try {
if (!ieHandleList.Contains(ieWindow.Handle)) { if (!ieHandleList.Contains(ieWindow.Handle)) {