refactored: get rid of confusing variables and calculating offsets for screen coordinates vs. bitmap coordinates.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2345 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
JKlingen 2012-12-02 18:18:15 +00:00
commit 7be6f7ab2b
2 changed files with 53 additions and 45 deletions

View file

@ -449,8 +449,9 @@ namespace GreenshotPlugin.Core {
}
/// <summary>
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7
/// <returns>Point with cursor location</returns>
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7.
/// <returns>Point with cursor location, relative to the origin of the monitor setup (i.e. negative coordinates are
/// possible in multiscreen setups)</returns>
public static Point GetCursorLocation() {
if (Environment.OSVersion.Version.Major >= 6) {
POINT cursorLocation;
@ -463,6 +464,29 @@ namespace GreenshotPlugin.Core {
}
return new Point(Cursor.Position.X, Cursor.Position.Y);
}
/// <summary>
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7. This implementation
/// can conveniently be used when the cursor location is needed to deal with a fullscreen bitmap.
/// <returns>Point with cursor location, relative to the top left corner of the monitor setup (which itself might
/// actually not be on any screen)</returns>
public static Point GetCursorLocationRelativeToScreenBounds() {
return GetLocationRelativeToScreenBounds(GetCursorLocation());
}
/// <summary>
/// Converts locationRelativeToScreenOrigin to be relative to top left corner of all screen bounds, which might
/// be different in multiscreen setups. This implementation
/// can conveniently be used when the cursor location is needed to deal with a fullscreen bitmap.
/// </summary>
/// <param name="locationRelativeToScreenOrigin"></param>
/// <returns></returns>
public static Point GetLocationRelativeToScreenBounds(Point locationRelativeToScreenOrigin) {
Point ret = locationRelativeToScreenOrigin;
Rectangle bounds = GetScreenBounds();
ret.Offset(-bounds.X, -bounds.Y);
return ret;
}
/// <summary>
/// This method will capture the current Cursor by using User32 Code