目录
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://blog.csdn.net/promsing/article/details/109495040
查看评论