mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Changes which calculate the amount of frames according to the time the animation should take, this makes the animation run equally long on all systems (independent of the refresh rate)
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2354 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c7c61773a5
commit
1ba5015305
1 changed files with 31 additions and 12 deletions
|
@ -49,6 +49,7 @@ namespace Greenshot.Forms {
|
||||||
private static Pen OverlayPen = new Pen(Color.FromArgb(50, Color.Black));
|
private static Pen OverlayPen = new Pen(Color.FromArgb(50, Color.Black));
|
||||||
private static CaptureForm currentForm = null;
|
private static CaptureForm currentForm = null;
|
||||||
private static Brush backgroundBrush = null;
|
private static Brush backgroundBrush = null;
|
||||||
|
private static int vRefresh = 0;
|
||||||
|
|
||||||
static CaptureForm() {
|
static CaptureForm() {
|
||||||
Image backgroundForTransparency = GreenshotPlugin.Core.GreenshotResources.getImage("Checkerboard.Image");
|
Image backgroundForTransparency = GreenshotPlugin.Core.GreenshotResources.getImage("Checkerboard.Image");
|
||||||
|
@ -73,6 +74,30 @@ namespace Greenshot.Forms {
|
||||||
private RectangleAnimator windowAnimator = null;
|
private RectangleAnimator windowAnimator = null;
|
||||||
private RectangleAnimator zoomAnimator = null;
|
private RectangleAnimator zoomAnimator = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vertical Refresh Rate
|
||||||
|
/// </summary>
|
||||||
|
private static int VRefresh {
|
||||||
|
get {
|
||||||
|
if (vRefresh == 0) {
|
||||||
|
// get te hDC of the desktop to get the VREFRESH
|
||||||
|
IntPtr hDCDesktop = User32.GetWindowDC(User32.GetDesktopWindow());
|
||||||
|
vRefresh = GDI32.GetDeviceCaps(hDCDesktop, DeviceCaps.VREFRESH);
|
||||||
|
User32.ReleaseDC(hDCDesktop);
|
||||||
|
}
|
||||||
|
return vRefresh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculate the amount of frames that an animation takes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="milliseconds"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static int calculateFrames(int milliseconds) {
|
||||||
|
return milliseconds / VRefresh;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Property to access the selected capture rectangle
|
/// Property to access the selected capture rectangle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -125,12 +150,6 @@ namespace Greenshot.Forms {
|
||||||
}
|
}
|
||||||
currentForm = this;
|
currentForm = this;
|
||||||
|
|
||||||
// get te hDC of the desktop to get the VREFRESH
|
|
||||||
IntPtr hDCDesktop = User32.GetWindowDC(User32.GetDesktopWindow());
|
|
||||||
int vRefesh = GDI32.GetDeviceCaps(hDCDesktop, DeviceCaps.VREFRESH);
|
|
||||||
User32.ReleaseDC(hDCDesktop);
|
|
||||||
LOG.DebugFormat("VRefresh {0}", vRefesh);
|
|
||||||
|
|
||||||
// comment this out if the timer should not be used
|
// comment this out if the timer should not be used
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
|
|
||||||
|
@ -177,10 +196,10 @@ namespace Greenshot.Forms {
|
||||||
|
|
||||||
// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
|
// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
|
||||||
if (captureMode == CaptureMode.Window) {
|
if (captureMode == CaptureMode.Window) {
|
||||||
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, 10, EasingType.Quintic, EasingMode.EaseOut);
|
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, calculateFrames(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
}
|
}
|
||||||
// Initialize the zoom with a invalid position
|
// Initialize the zoom with a invalid position
|
||||||
zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), 20, EasingType.Quintic, EasingMode.EaseOut);
|
zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), calculateFrames(1000), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
VerifyZoomAnimation(cursorPos, false);
|
VerifyZoomAnimation(cursorPos, false);
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
this.Bounds = capture.ScreenBounds;
|
this.Bounds = capture.ScreenBounds;
|
||||||
|
@ -191,7 +210,7 @@ namespace Greenshot.Forms {
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
|
|
||||||
if (timer != null) {
|
if (timer != null) {
|
||||||
timer.Interval = 1000/vRefesh;
|
timer.Interval = 1000/VRefresh;
|
||||||
timer.Tick += new EventHandler(timer_Tick);
|
timer.Tick += new EventHandler(timer_Tick);
|
||||||
timer.Start();
|
timer.Start();
|
||||||
}
|
}
|
||||||
|
@ -259,9 +278,9 @@ namespace Greenshot.Forms {
|
||||||
// Set the window capture mode
|
// Set the window capture mode
|
||||||
captureMode = CaptureMode.Window;
|
captureMode = CaptureMode.Window;
|
||||||
// "Fade out" Zoom
|
// "Fade out" Zoom
|
||||||
zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), 20);
|
zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty));
|
||||||
// "Fade in" window
|
// "Fade in" window
|
||||||
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, 10, EasingType.Quintic, EasingMode.EaseOut);
|
windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, calculateFrames(700), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
captureRect = Rectangle.Empty;
|
captureRect = Rectangle.Empty;
|
||||||
break;
|
break;
|
||||||
case CaptureMode.Window:
|
case CaptureMode.Window:
|
||||||
|
@ -270,7 +289,7 @@ namespace Greenshot.Forms {
|
||||||
// "Fade out" window
|
// "Fade out" window
|
||||||
windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty));
|
windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty));
|
||||||
// Fade in zoom
|
// Fade in zoom
|
||||||
zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), 20, EasingType.Quintic, EasingMode.EaseOut);
|
zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), calculateFrames(1000), EasingType.Quintic, EasingMode.EaseOut);
|
||||||
VerifyZoomAnimation(cursorPos, false);
|
VerifyZoomAnimation(cursorPos, false);
|
||||||
captureRect = Rectangle.Empty;
|
captureRect = Rectangle.Empty;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue