今天搓搓的弄了一点代码,基本上实现了QQ的抖动功能,窃喜。
代码思路很简单,就是不停改变界面在桌面上位置。
看来兴趣是个不错的东西……
贴码……
private void button1_Click(object sender, EventArgs e)
{
int r = 3;
Point point = this.Location;
int x = point.X - r;
int y = point.Y;
for (int i = 0; i < 6; i++)
{
for (int j = (-1*r); j < r+1; j++)
{
double z = Math.Pow(-1,i)*Math.Sqrt(r*r - j*j);
this.Location=new Point(x+(int)(Math.Pow(-1,i)*j),y+(int)z);
System.Threading.Thread.Sleep(10);
}
}
this.Location = point;
}