[Mwinapi-commits] SF.net SVN: mwinapi:[107] trunk/ManagedWinapi
Status: Beta
Brought to you by:
schierlm
|
From: <sch...@us...> - 2011-02-14 19:54:12
|
Revision: 107
http://mwinapi.svn.sourceforge.net/mwinapi/?rev=107&view=rev
Author: schierlm
Date: 2011-02-14 19:54:06 +0000 (Mon, 14 Feb 2011)
Log Message:
-----------
- Highlight current rectangle while doing a scrolling screenshot
Modified Paths:
--------------
trunk/ManagedWinapi/Properties/AssemblyInfo.cs
trunk/ManagedWinapi/Screenshot.cs
Modified: trunk/ManagedWinapi/Properties/AssemblyInfo.cs
===================================================================
--- trunk/ManagedWinapi/Properties/AssemblyInfo.cs 2011-02-01 17:32:55 UTC (rev 106)
+++ trunk/ManagedWinapi/Properties/AssemblyInfo.cs 2011-02-14 19:54:06 UTC (rev 107)
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.3.0.2")]
-[assembly: AssemblyFileVersion("0.3.0.2")]
+[assembly: AssemblyVersion("0.3.0.3")]
+[assembly: AssemblyFileVersion("0.3.0.3")]
Modified: trunk/ManagedWinapi/Screenshot.cs
===================================================================
--- trunk/ManagedWinapi/Screenshot.cs 2011-02-01 17:32:55 UTC (rev 106)
+++ trunk/ManagedWinapi/Screenshot.cs 2011-02-14 19:54:06 UTC (rev 107)
@@ -227,7 +227,7 @@
public static Bitmap TakeVerticalScrollingScreenshot(Point scrollPoint, Rectangle rect, Point? clickPoint)
{
int scrollCount;
- return TakeScrollingScreenshot(scrollPoint, rect, clickPoint.HasValue ? clickPoint.Value : scrollPoint, clickPoint.HasValue, r => TakeScreenshot(r, false, null), out scrollCount);
+ return TakeScrollingScreenshot(scrollPoint, rect, clickPoint.HasValue ? clickPoint.Value : scrollPoint, clickPoint.HasValue, r => TakeScreenshot(r, false, null), r => HighlightRect(r), out scrollCount);
}
/// <summary>
@@ -256,12 +256,13 @@
public static Bitmap TakeHorizontalScrollingScreenshot(Point scrollPoint, Rectangle rect, Point? clickPoint)
{
int scrollCount;
- return FlipRotate(TakeScrollingScreenshot(new Point(scrollPoint.Y, scrollPoint.X), FlipRotate(rect), clickPoint.HasValue ? clickPoint.Value : scrollPoint, clickPoint.HasValue, r => FlipRotate(TakeScreenshot(FlipRotate(r), false, null)), out scrollCount));
+ return FlipRotate(TakeScrollingScreenshot(new Point(scrollPoint.Y, scrollPoint.X), FlipRotate(rect), clickPoint.HasValue ? clickPoint.Value : scrollPoint, clickPoint.HasValue, r => FlipRotate(TakeScreenshot(FlipRotate(r), false, null)), r => HighlightRect(FlipRotate(r)), out scrollCount));
}
private delegate Bitmap ScreenshotFunction(Rectangle rect);
+ private delegate void HighlightFunction(Rectangle rect);
- private static Bitmap TakeScrollingScreenshot(Point centerPoint, Rectangle rect, Point mousePoint, bool click, ScreenshotFunction screenshot, out int scrollCount)
+ private static Bitmap TakeScrollingScreenshot(Point centerPoint, Rectangle rect, Point mousePoint, bool click, ScreenshotFunction screenshot, HighlightFunction highlight, out int scrollCount)
{
scrollCount = 0;
Cursor.Position = mousePoint;
@@ -282,6 +283,7 @@
KeyboardKey.InjectMouseEvent(0x0800, 0, 0, unchecked((uint)-120), UIntPtr.Zero);
}
Application.DoEvents();
+ highlight(rect);
Bitmap nextPart = screenshot(rect);
int scrollHeight = AppendBelow(buffer, usedHeight, nextPart, false);
foreach (int delay in new int[] { 0, 2, 10, 100, 200, 1000 })
@@ -290,6 +292,7 @@
break;
Thread.Sleep(delay);
Application.DoEvents();
+ highlight(rect);
nextPart = screenshot(rect);
scrollHeight = AppendBelow(buffer, usedHeight, nextPart, false);
}
@@ -308,6 +311,7 @@
if (scrollHeight == -1)
{
CropToSimilarRange(centerPoint, ref rect, ref buffer, ref usedHeight, ref nextPart);
+ highlight(rect);
scrollHeight = AppendBelow(buffer, usedHeight, nextPart, false);
}
if (scrollHeight <= 0)
@@ -394,7 +398,7 @@
int pixel = nextPartPixels[x, y];
if (bufferPixels[x, y] != pixel)
{
- int score = 1000 / (Math.Abs(relX - x) + Math.Abs(relY - y)+1 ) + 1;
+ int score = 1000 / (Math.Abs(relX - x) + Math.Abs(relY - y) + 1) + 1;
for (int scrollHeight = 1; scrollHeight < Math.Min(scrollScores.Length, rect.Height - y); scrollHeight++)
{
if (bufferPixels[x, y + scrollHeight] == pixel)
@@ -594,6 +598,18 @@
return result;
}
+ private static void HighlightRect(Rectangle rect)
+ {
+ SystemWindow window = SystemWindow.DesktopWindow;
+ using (WindowDeviceContext windowDC = window.GetDeviceContext(false))
+ {
+ using (Graphics g = windowDC.CreateGraphics())
+ {
+ g.DrawRectangle(Pens.Blue, rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2);
+ }
+ }
+ }
+
private static Bitmap FlipRotate(Bitmap original)
{
Bitmap result = new Bitmap(original.Height, original.Width);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|