Last active
June 24, 2016 04:52
-
-
Save the-takeo/09a41458b0137b295f5dc576ebb43246 to your computer and use it in GitHub Desktop.
FormMover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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