mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Use duration instead of speed
This commit is contained in:
parent
dcd99194aa
commit
77d42d6b57
6 changed files with 16 additions and 15 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -30,7 +30,6 @@ namespace ShareX.ScreenCaptureLib
|
|||
internal class TextAnimation : OpacityAnimation
|
||||
{
|
||||
public string Text { get; set; }
|
||||
|
||||
public Point Position { get; set; }
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue