mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 05:23:24 -07:00
Restored Jens his Animation logic, this does cause problems with the drawing as the size is not exact.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2339 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
ae38bd7ac2
commit
03efcf8d17
2 changed files with 50 additions and 6 deletions
|
@ -72,7 +72,7 @@ namespace Greenshot.Forms {
|
||||||
private Point previousMousePos = Point.Empty;
|
private Point previousMousePos = Point.Empty;
|
||||||
private FixMode fixMode = FixMode.None;
|
private FixMode fixMode = FixMode.None;
|
||||||
private RectangleAnimator windowAnimator = new RectangleAnimator(Rectangle.Empty, Rectangle.Empty, 0);
|
private RectangleAnimator windowAnimator = new RectangleAnimator(Rectangle.Empty, Rectangle.Empty, 0);
|
||||||
private SizeAnimator zoomAnimator;
|
private FlexibleAnimator<Size> zoomAnimator;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Property to access the selected capture rectangle
|
/// Property to access the selected capture rectangle
|
||||||
|
@ -179,7 +179,14 @@ namespace Greenshot.Forms {
|
||||||
WindowDetails.ToForeground(this.Handle);
|
WindowDetails.ToForeground(this.Handle);
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
|
|
||||||
zoomAnimator = new SizeAnimator(Size.Empty, new Size(200, 200), 10);
|
zoomAnimator = new FlexibleAnimator<Size>(Size.Empty,
|
||||||
|
delegate(Size current) {
|
||||||
|
return current.Width < 200;
|
||||||
|
},
|
||||||
|
delegate(Size current) {
|
||||||
|
int newvalue = current.Width + (220-current.Width) /5;
|
||||||
|
return new Size(newvalue, newvalue);
|
||||||
|
});
|
||||||
if (timer != null) {
|
if (timer != null) {
|
||||||
timer.Interval = 30;
|
timer.Interval = 30;
|
||||||
timer.Tick += new EventHandler(timer_Tick);
|
timer.Tick += new EventHandler(timer_Tick);
|
||||||
|
|
|
@ -43,13 +43,18 @@ namespace Greenshot.Helpers {
|
||||||
current = first;
|
current = first;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Current {
|
public virtual void Reset() {
|
||||||
|
currentFrame = 0;
|
||||||
|
current = first;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual T Current {
|
||||||
get {
|
get {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool hasNext {
|
public virtual bool hasNext {
|
||||||
get {
|
get {
|
||||||
return currentFrame < frames;
|
return currentFrame < frames;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +97,7 @@ namespace Greenshot.Helpers {
|
||||||
/// Implementation of the PointAnimator
|
/// Implementation of the PointAnimator
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PointAnimator : AnimatorBase<Point> {
|
public class PointAnimator : AnimatorBase<Point> {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(RectangleAnimator));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PointAnimator));
|
||||||
public PointAnimator(Point first, Point last, int frames)
|
public PointAnimator(Point first, Point last, int frames)
|
||||||
: base(first, last, frames) {
|
: base(first, last, frames) {
|
||||||
}
|
}
|
||||||
|
@ -117,10 +122,11 @@ namespace Greenshot.Helpers {
|
||||||
/// Implementation of the SizeAnimator
|
/// Implementation of the SizeAnimator
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SizeAnimator : AnimatorBase<Size> {
|
public class SizeAnimator : AnimatorBase<Size> {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(RectangleAnimator));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SizeAnimator));
|
||||||
public SizeAnimator(Size first, Size last, int frames)
|
public SizeAnimator(Size first, Size last, int frames)
|
||||||
: base(first, last, frames) {
|
: base(first, last, frames) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Size Next() {
|
public override Size Next() {
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
currentFrame++;
|
currentFrame++;
|
||||||
|
@ -137,4 +143,35 @@ namespace Greenshot.Helpers {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implementation of the FlexibleSizeAnimator
|
||||||
|
/// </summary>
|
||||||
|
public class FlexibleAnimator<T> : AnimatorBase<T> {
|
||||||
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(FlexibleAnimator<T>));
|
||||||
|
public delegate bool HasNextValue(T current);
|
||||||
|
public delegate T NextValue(T current);
|
||||||
|
private HasNextValue hasNextValue;
|
||||||
|
private NextValue nextValue;
|
||||||
|
|
||||||
|
public FlexibleAnimator(T first, HasNextValue hasNextDelegate, NextValue nextValueDelegate)
|
||||||
|
: base(first, default(T) , 0) {
|
||||||
|
this.hasNextValue = hasNextDelegate;
|
||||||
|
this.nextValue = nextValueDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool hasNext {
|
||||||
|
get {
|
||||||
|
return hasNextValue(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override T Next() {
|
||||||
|
if (hasNext) {
|
||||||
|
current = nextValue(current);
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue