Use duration instead of speed

This commit is contained in:
Jaex 2017-04-03 13:49:00 +03:00
parent dcd99194aa
commit 77d42d6b57
6 changed files with 16 additions and 15 deletions

View file

@ -44,9 +44,9 @@ private set
}
}
public TimeSpan FadeInDuration { get; set; } = TimeSpan.Zero;
public TimeSpan Duration { get; set; } = TimeSpan.Zero;
public TimeSpan FadeOutDuration { get; set; } = TimeSpan.Zero;
public TimeSpan FadeInDuration { get; set; }
public TimeSpan Duration { get; set; }
public TimeSpan FadeOutDuration { get; set; }
public TimeSpan TotalDuration => FadeInDuration + Duration + FadeOutDuration;

View file

@ -33,7 +33,7 @@ internal class PointAnimation : BaseAnimation
{
public Point FromPosition { get; set; }
public Point ToPosition { get; set; }
public float Speed { get; set; } = 1;
public TimeSpan Duration { get; set; }
public Point CurrentPosition { get; private set; }
@ -43,7 +43,7 @@ public override bool Update()
{
base.Update();
float amount = (float)Timer.Elapsed.TotalSeconds * Speed;
float amount = (float)Timer.Elapsed.Ticks / Duration.Ticks;
amount = Math.Min(amount, 1);
CurrentPosition = (Point)MathHelpers.Lerp(FromPosition, ToPosition, amount);

View file

@ -33,7 +33,7 @@ internal class RectangleAnimation : BaseAnimation
{
public Rectangle FromRectangle { get; set; }
public Rectangle ToRectangle { get; set; }
public float Speed { get; set; } = 1;
public TimeSpan Duration { get; set; }
public Rectangle CurrentRectangle { get; private set; }
@ -43,7 +43,7 @@ public override bool Update()
{
base.Update();
float amount = (float)Timer.Elapsed.TotalSeconds * Speed;
float amount = (float)Timer.Elapsed.Ticks / Duration.Ticks;
amount = Math.Min(amount, 1);
int x = (int)MathHelpers.Lerp(FromRectangle.X, ToRectangle.X, amount);

View file

@ -30,7 +30,6 @@ namespace ShareX.ScreenCaptureLib
internal class TextAnimation : OpacityAnimation
{
public string Text { get; set; }
public Point Position { get; set; }
}
}

View file

@ -109,7 +109,10 @@ public RegionCaptureForm(RegionCaptureMode mode)
timerFPS = new Stopwatch();
borderColorAnimation = new ColorBlinkAnimation();
borderColorAnimation.Start();
regionAnimation = new RectangleAnimation();
regionAnimation = new RectangleAnimation()
{
Duration = TimeSpan.FromMilliseconds(250)
};
borderPen = new Pen(Color.Black);
borderDotPen = new Pen(Color.White) { DashPattern = new float[] { 5, 5 } };
@ -494,7 +497,6 @@ private void Draw(Graphics g)
{
regionAnimation.FromRectangle = ShapeManager.PreviousHoverRectangle;
regionAnimation.ToRectangle = ShapeManager.CurrentHoverShape.Rectangle;
regionAnimation.Speed = 5f;
regionAnimation.Start();
}

View file

@ -39,9 +39,9 @@ internal partial class ShapeManager
internal TextAnimation MenuTextAnimation = new TextAnimation()
{
FadeInDuration = TimeSpan.FromSeconds(0),
Duration = TimeSpan.FromSeconds(5),
FadeOutDuration = TimeSpan.FromSeconds(0.5)
FadeInDuration = TimeSpan.FromMilliseconds(0),
Duration = TimeSpan.FromMilliseconds(5000),
FadeOutDuration = TimeSpan.FromMilliseconds(500)
};
private Form menuForm;
@ -776,7 +776,7 @@ private void MenuForm_Shown(object sender, EventArgs e)
{
FromPosition = new Point(clientLocation.X + menuForm.Width / 2, clientLocation.Y + menuForm.Height + 1),
ToPosition = new Point(clientLocation.X, clientLocation.Y + menuForm.Height + 1),
Speed = 2f
Duration = TimeSpan.FromMilliseconds(500)
};
form.toolbarAnimation.Start();
@ -785,7 +785,7 @@ private void MenuForm_Shown(object sender, EventArgs e)
{
FromPosition = new Point(clientLocation.X + menuForm.Width / 2, clientLocation.Y + menuForm.Height + 1),
ToPosition = new Point(clientLocation.X + menuForm.Width, clientLocation.Y + menuForm.Height + 1),
Speed = 2f
Duration = TimeSpan.FromMilliseconds(500)
};
form.toolbarAnimation2.Start();