mirror of
https://github.com/greenshot/greenshot
synced 2025-07-14 00:53:51 -07:00
Fixed "does the window to capture" fit routine and changed the isMetroApp to check for the className.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2251 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
114233eed9
commit
3835b198f0
1 changed files with 18 additions and 9 deletions
|
@ -159,6 +159,7 @@ namespace GreenshotPlugin.Core {
|
||||||
/// enumeration
|
/// enumeration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WindowDetails : IEquatable<WindowDetails>{
|
public class WindowDetails : IEquatable<WindowDetails>{
|
||||||
|
private const string METRO_WINDOWS_CLASS = "Windows.UI.Core.CoreWindow";
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WindowDetails));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WindowDetails));
|
||||||
private static Dictionary<string, List<string>> classnameTree = new Dictionary<string, List<string>>();
|
private static Dictionary<string, List<string>> classnameTree = new Dictionary<string, List<string>>();
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
|
@ -181,9 +182,13 @@ namespace GreenshotPlugin.Core {
|
||||||
private WindowDetails parent = null;
|
private WindowDetails parent = null;
|
||||||
private bool frozen = false;
|
private bool frozen = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if this window is the window of a metro app
|
||||||
|
/// </summary>
|
||||||
public bool isMetroApp {
|
public bool isMetroApp {
|
||||||
get;
|
get {
|
||||||
set;
|
return METRO_WINDOWS_CLASS.Equals(ClassName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -783,14 +788,16 @@ namespace GreenshotPlugin.Core {
|
||||||
Point formLocation;
|
Point formLocation;
|
||||||
Rectangle windowRectangle = WindowRectangle;
|
Rectangle windowRectangle = WindowRectangle;
|
||||||
Size borderSize = new Size();
|
Size borderSize = new Size();
|
||||||
|
bool doesCaptureFit = false;
|
||||||
if (!Maximised) {
|
if (!Maximised) {
|
||||||
// Assume using it's own location
|
// Assume using it's own location
|
||||||
formLocation = windowRectangle.Location;
|
formLocation = windowRectangle.Location;
|
||||||
using (Region workingArea = new Region(Screen.PrimaryScreen.WorkingArea)) {
|
using (Region workingArea = new Region(Screen.PrimaryScreen.WorkingArea)) {
|
||||||
// Find the screen where the window is and check if it fits
|
// Find the screen where the window is and check if it fits
|
||||||
foreach (Screen screen in Screen.AllScreens) {
|
foreach (Screen screen in Screen.AllScreens) {
|
||||||
workingArea.Union(screen.WorkingArea);
|
if (screen != Screen.PrimaryScreen) {
|
||||||
|
workingArea.Union(screen.WorkingArea);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the formLocation is not inside the visible area
|
// If the formLocation is not inside the visible area
|
||||||
|
@ -800,9 +807,12 @@ namespace GreenshotPlugin.Core {
|
||||||
Rectangle newWindowRectangle = new Rectangle(screen.WorkingArea.Location, windowRectangle.Size);
|
Rectangle newWindowRectangle = new Rectangle(screen.WorkingArea.Location, windowRectangle.Size);
|
||||||
if (workingArea.AreRectangleCornersVisisble(newWindowRectangle)) {
|
if (workingArea.AreRectangleCornersVisisble(newWindowRectangle)) {
|
||||||
formLocation = screen.WorkingArea.Location;
|
formLocation = screen.WorkingArea.Location;
|
||||||
|
doesCaptureFit = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
doesCaptureFit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -825,8 +835,8 @@ namespace GreenshotPlugin.Core {
|
||||||
captureRectangle.Height -= 2 * borderSize.Height;
|
captureRectangle.Height -= 2 * borderSize.Height;
|
||||||
} else if (autoMode) {
|
} else if (autoMode) {
|
||||||
// check if the capture fits
|
// check if the capture fits
|
||||||
if (!capture.ScreenBounds.Contains(captureRectangle)) {
|
if (!doesCaptureFit) {
|
||||||
// if GDI is allowed..
|
// if GDI is allowed.. (a screenshot won't be better than we comes if we continue)
|
||||||
if (WindowCapture.isGDIAllowed(Process)) {
|
if (WindowCapture.isGDIAllowed(Process)) {
|
||||||
// we return null which causes the capturing code to try another method.
|
// we return null which causes the capturing code to try another method.
|
||||||
return null;
|
return null;
|
||||||
|
@ -1367,13 +1377,12 @@ namespace GreenshotPlugin.Core {
|
||||||
/// <returns>List<WindowDetails> with visible metro apps</returns>
|
/// <returns>List<WindowDetails> with visible metro apps</returns>
|
||||||
public static List<WindowDetails> GetMetroApps() {
|
public static List<WindowDetails> GetMetroApps() {
|
||||||
List<WindowDetails> metroApps = new List<WindowDetails>();
|
List<WindowDetails> metroApps = new List<WindowDetails>();
|
||||||
IntPtr nextHandle = User32.FindWindow("Windows.UI.Core.CoreWindow", null);
|
IntPtr nextHandle = User32.FindWindow(METRO_WINDOWS_CLASS, null);
|
||||||
while (nextHandle != IntPtr.Zero) {
|
while (nextHandle != IntPtr.Zero) {
|
||||||
WindowDetails metroApp = new WindowDetails(nextHandle);
|
WindowDetails metroApp = new WindowDetails(nextHandle);
|
||||||
metroApp.isMetroApp = true;
|
|
||||||
metroApps.Add(metroApp);
|
metroApps.Add(metroApp);
|
||||||
LOG.DebugFormat("Found metro app {0}", metroApp.Text);
|
LOG.DebugFormat("Found metro app {0}", metroApp.Text);
|
||||||
nextHandle = User32.FindWindowEx( IntPtr.Zero, nextHandle, "Windows.UI.Core.CoreWindow", null);
|
nextHandle = User32.FindWindowEx(IntPtr.Zero, nextHandle, METRO_WINDOWS_CLASS, null);
|
||||||
};
|
};
|
||||||
|
|
||||||
return metroApps;
|
return metroApps;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue