Making capture more stable for #1475

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2532 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-03-13 16:56:57 +00:00
commit 94c0f1064f

View file

@ -357,11 +357,13 @@ namespace Greenshot.Helpers {
LOG.Debug("Nothing to capture found"); LOG.Debug("Nothing to capture found");
return null; return null;
} }
LOG.DebugFormat("Window class {0}", documentContainer.ContentWindow.ClassName);
LOG.DebugFormat("Window location {0}", documentContainer.ContentWindow.Location);
// The URL is available unter "document2.url" and can be used to enhance the meta-data etc. try {
capture.CaptureDetails.AddMetaData("url", documentContainer.Url); LOG.DebugFormat("Window class {0}", documentContainer.ContentWindow.ClassName);
LOG.DebugFormat("Window location {0}", documentContainer.ContentWindow.Location);
} catch (Exception ex) {
LOG.Warn("Error while logging information.", ex);
}
// bitmap to return // bitmap to return
Bitmap returnBitmap = null; Bitmap returnBitmap = null;
@ -405,14 +407,20 @@ namespace Greenshot.Helpers {
// Store the bitmap for further processing // Store the bitmap for further processing
capture.Image = returnBitmap; capture.Image = returnBitmap;
// Store the location of the window try {
capture.Location = documentContainer.ContentWindow.Location; // Store the location of the window
capture.Location = documentContainer.ContentWindow.Location;
// Store the title of the page // The URL is available unter "document2.url" and can be used to enhance the meta-data etc.
if (documentContainer.Name != null) { capture.CaptureDetails.AddMetaData("url", documentContainer.Url);
capture.CaptureDetails.Title = documentContainer.Name; // Store the title of the page
} else { if (documentContainer.Name != null) {
capture.CaptureDetails.Title = windowToCapture.Text; capture.CaptureDetails.Title = documentContainer.Name;
} else {
capture.CaptureDetails.Title = windowToCapture.Text;
}
} catch (Exception ex) {
LOG.Warn("Problems getting some attributes...", ex);
} }
// Store the URL of the page // Store the URL of the page
@ -441,10 +449,13 @@ namespace Greenshot.Helpers {
LOG.Warn("Exception when trying to use url in metadata "+documentContainer.Url,e); LOG.Warn("Exception when trying to use url in metadata "+documentContainer.Url,e);
} }
} }
try {
// Only move the mouse to correct for the capture offset // Only move the mouse to correct for the capture offset
capture.MoveMouseLocation(-documentContainer.ViewportRectangle.X, -documentContainer.ViewportRectangle.Y); capture.MoveMouseLocation(-documentContainer.ViewportRectangle.X, -documentContainer.ViewportRectangle.Y);
// Used to be: capture.MoveMouseLocation(-(capture.Location.X + documentContainer.CaptureOffset.X), -(capture.Location.Y + documentContainer.CaptureOffset.Y)); // Used to be: capture.MoveMouseLocation(-(capture.Location.X + documentContainer.CaptureOffset.X), -(capture.Location.Y + documentContainer.CaptureOffset.Y));
} catch (Exception ex) {
LOG.Warn("Error while correcting the mouse offset.", ex);
}
} finally { } finally {
// Always close the background form // Always close the background form
backgroundForm.CloseDialog(); backgroundForm.CloseDialog();