Skip to content

Instantly share code, notes, and snippets.

@the-takeo
Last active June 24, 2016 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-takeo/09a41458b0137b295f5dc576ebb43246 to your computer and use it in GitHub Desktop.
Save the-takeo/09a41458b0137b295f5dc576ebb43246 to your computer and use it in GitHub Desktop.
FormMover
static class FormMover
{
static double Max = 8;
static double MaxExp = Math.Exp(Max);
static public void WipeUp(Form Frm, int MovingTime, int WaitTimeForMoving, bool Fade)
{
System.Threading.Thread.Sleep(WaitTimeForMoving);
int X = Frm.Location.X;
int Y = Frm.Location.Y;
int MovingDistance = Y + Frm.Height;
for (int i = 0; i < MovingTime; i++)
{
double ratio = (double)(i + 1) / MovingTime;
double expratio = ExpRatio(ratio);
Frm.Location = new Point(X, Y - Math.Min(MovingDistance - 3, (int)(MovingDistance * expratio)));
if (Fade) Frm.Opacity = 1 - ratio;
Frm.Refresh();
System.Threading.Thread.Sleep(1);
}
}
static private double ExpRatio(double ratio)
{
return 1 - Math.Exp(Max * (1 - ratio)) / MaxExp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment