Made zoom move to a different location if it goes outside the screen. Also changed the Metro-App visibility property, this might work (up to an acceptable level) but is untested.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2284 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-11-13 21:13:09 +00:00
commit 831a3b4d5b
4 changed files with 57 additions and 35 deletions

View file

@ -168,6 +168,13 @@ namespace GreenshotPlugin.Core {
private static List<IntPtr> ignoreHandles = new List<IntPtr>();
private static Dictionary<string, Image> iconCache = new Dictionary<string, Image>();
private static List<string> excludeProcessesFromFreeze = new List<string>();
private static IAppVisibility appVisibility = null;
static WindowDetails() {
try {
appVisibility = COMWrapper.CreateInstance<IAppVisibility>();
} catch {}
}
public static void AddProcessToExcludeFromFreeze(string processname) {
if (!excludeProcessesFromFreeze.Contains(processname)) {
@ -598,24 +605,30 @@ namespace GreenshotPlugin.Core {
public bool Visible {
get {
if (isApp) {
// IAppVisibility appVisibility = COMWrapper.CreateInstance<IAppVisibility>();
// if (appVisibility != null) {
//foreach (Screen screen in Screen.AllScreens) {
// RECT rect = new RECT(screen.Bounds);
// IntPtr monitor = User32.MonitorFromRect(ref rect, User32.MONITOR_DEFAULTTONULL);
// if (monitor != IntPtr.Zero) {
// LOG.DebugFormat("Monitor {0} has hMonitor {1}", screen.DeviceName, monitor);
// }
//}
// IntPtr monitor = User32.MonitorFromWindow(Handle, User32.MONITOR_DEFAULTTONULL);
// if (monitor != IntPtr.Zero) {
// LOG.DebugFormat("Monitor = {0}", monitor);
// MONITOR_APP_VISIBILITY monitorAppVisibility = appVisibility.GetAppVisibilityOnMonitor(monitor);
// LOG.DebugFormat("App visible: {0}", monitorAppVisibility);
// return monitorAppVisibility == MONITOR_APP_VISIBILITY.MAV_APP_VISIBLE;
// }
// }
Rectangle windowRectangle = WindowRectangle;
foreach (Screen screen in Screen.AllScreens) {
if (screen.Bounds.Contains(windowRectangle)) {
if (windowRectangle.Equals(screen.Bounds)) {
// Fullscreen, it's "visible" when AppVisibilityOnMonitor says yes
// Although it might be the other App, this is not "very" important
RECT rect = new RECT(screen.Bounds);
IntPtr monitor = User32.MonitorFromRect(ref rect, User32.MONITOR_DEFAULTTONULL);
if (monitor != IntPtr.Zero) {
if (appVisibility != null) {
MONITOR_APP_VISIBILITY monitorAppVisibility = appVisibility.GetAppVisibilityOnMonitor(monitor);
LOG.DebugFormat("App visible: {0}", monitorAppVisibility);
if (monitorAppVisibility == MONITOR_APP_VISIBILITY.MAV_APP_VISIBLE) {
return true;
}
}
}
} else {
// Not Fullscreen -> Than it's visible!
return true;
}
}
}
return false;
}
if (isAppLauncher) {
return IsAppLauncherVisible;
@ -1578,14 +1591,10 @@ namespace GreenshotPlugin.Core {
/// <returns></returns>
public static bool IsAppLauncherVisible {
get {
try {
IAppVisibility appVisibility = COMWrapper.CreateInstance<IAppVisibility>();
if (appVisibility != null) {
return appVisibility.IsLauncherVisible;
}
} catch {}
if (appVisibility != null) {
return appVisibility.IsLauncherVisible;
}
return false;
}
}
}