diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index 0bea97f5b..f5eda02b4 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -72,7 +72,7 @@ namespace Greenshot.Forms { private Point previousMousePos = Point.Empty; private FixMode fixMode = FixMode.None; private RectangleAnimator windowAnimator = new RectangleAnimator(Rectangle.Empty, Rectangle.Empty, 0); - private SizeAnimator zoomAnimator; + private FlexibleAnimator zoomAnimator; /// /// Property to access the selected capture rectangle @@ -179,7 +179,14 @@ namespace Greenshot.Forms { WindowDetails.ToForeground(this.Handle); this.TopMost = true; - zoomAnimator = new SizeAnimator(Size.Empty, new Size(200, 200), 10); + zoomAnimator = new FlexibleAnimator(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) { timer.Interval = 30; timer.Tick += new EventHandler(timer_Tick); diff --git a/Greenshot/Helpers/AnimationHelper.cs b/Greenshot/Helpers/AnimationHelper.cs index aad833568..155024aa9 100644 --- a/Greenshot/Helpers/AnimationHelper.cs +++ b/Greenshot/Helpers/AnimationHelper.cs @@ -43,13 +43,18 @@ namespace Greenshot.Helpers { current = first; } - public T Current { + public virtual void Reset() { + currentFrame = 0; + current = first; + } + + public virtual T Current { get { return current; } } - public bool hasNext { + public virtual bool hasNext { get { return currentFrame < frames; } @@ -92,7 +97,7 @@ namespace Greenshot.Helpers { /// Implementation of the PointAnimator /// public class PointAnimator : AnimatorBase { - 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) : base(first, last, frames) { } @@ -117,10 +122,11 @@ namespace Greenshot.Helpers { /// Implementation of the SizeAnimator /// public class SizeAnimator : AnimatorBase { - 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) : base(first, last, frames) { } + public override Size Next() { if (hasNext) { currentFrame++; @@ -137,4 +143,35 @@ namespace Greenshot.Helpers { return current; } } + + + /// + /// Implementation of the FlexibleSizeAnimator + /// + public class FlexibleAnimator : AnimatorBase { + private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(FlexibleAnimator)); + 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; + } + } }