P2P聊天的時候可以發送抖一抖,但是前提自己得先實作抖一抖,再通過網路發送吧,本文只是將基礎的本地抖一抖實作了.
表單抖動封裝一個類內,使用時直接呼叫即可
public class Shake
{
/// <summary>
/// 震動方法
/// </summary>
/// <param name="form">表單</param>
public void Vibration(Form form)
{
Point pOld = form.Location;//原來的位置
int radius = 3;//半徑
for (int n = 0; n < 3; n++) //旋轉圈數
{
//右半圓逆時針
for (int i = -radius; i <= radius; i++)
{
int x = Convert.ToInt32(Math.Sqrt(radius * radius - i * i));
int y = -i;
form.Location = new Point(pOld.X + x, pOld.Y + y);
Thread.Sleep(10);
}
//左半圓逆時針
for (int j = radius; j >= -radius; j--)
{
int x = -Convert.ToInt32(Math.Sqrt(radius * radius - j * j));
int y = -j;
form.Location = new Point(pOld.X + x, pOld.Y + y);
Thread.Sleep(10);
}
}
//抖動完成,恢復原來位置
form.Location = pOld;
}
}
U層直接呼叫
Shake shake = new Shake();
shake.Vibration(this);//將表單傳進去
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/264753.html
標籤:其他
上一篇:8. 長方體體積
下一篇:音視頻概念
