C# 三种实现抖屏的方式

时间:2021-01-01 14:30:08
          //int a = -2;
//this.BringToFront();
//for (int i = 0; i < 20; i++)
//{
// a = -a;
// this.Location = new Point(this.Location.X + 6 * a, this.Location.Y + 8 * a); // Thread.Sleep(100); //}
//2.
//int X = this.Top; int Y = this.Left; //for (int i = 0; i < 100; i++)
//{ // this.Top = this.Top + 10; // this.Left = this.Left + 10; // this.Top = this.Top - 10; // this.Left = this.Left - 10; //} ////回到原来的位置 //this.Top = X;
//this.Left = Y; //3.
Point pOld = this.Location;//原来的位置
int radius = ;//半径
for (int n = ; n < ; n++) //旋转圈数
{
//右半圆逆时针
for (int i = -radius; i <= radius; i++)
{
int x = Convert.ToInt32(Math.Sqrt(radius * radius - i * i)); int y = -i; this.Location = new Point(pOld.X + x, pOld.Y + y); System.Threading.Thread.Sleep(); } //左半圆逆时针
for (int j = radius; j >= -radius; j--)
{
int x = -Convert.ToInt32(Math.Sqrt(radius * radius - j * j));
int y = -j;
this.Location = new Point(pOld.X + x, pOld.Y + y);
System.Threading.Thread.Sleep();
}
} this.Location = pOld;