c#如何实现抖屏和屏幕右下角的信息提示
你说的是winform的还是WEBForm的。下面是winform的代码哦。
屏幕右下角信息提示代码如下:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width, Screen.PrimaryScreen.Bounds.Height-this.Height);
这行代码放在你要在右下角要显示窗体的Load方法里面。
抖屏代码放在你点击按钮的那个事件里面,代码如下(这是规则的抖屏):
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;
完整代码见附件。有问题HI我即可
推荐于2016-09-19
private void btnButton1_Click(object sender, EventArgs e)
{
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;
}
//不规则震动
private void btnButton2_Click(object sender, EventArgs e)
{
int X = this.Top;
int Y = this.Left;
Random radom = new Random(); for (int i = 0; i < 100; i++)
{
this.Top = radom.Next(800);
this.Left = radom.Next(800);
this.Top = radom.Next(800);
this.Left = radom.Next(800);
}
this.Top = X;
this.Left = Y;
}
//五秒之内的震动
private void btnButton3_Click(object sender, EventArgs e)
{
int X = this.Top;
int Y = this.Left; if (Time.Enabled)
{
MessageBox.Show("对不起,五秒之内不能再发出抖动!!");
}else
{
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;
Time.Enabled = true;
}
}
//当时间为五秒后,Enabled为false,又可以继续震动
private void Time_Tick(object sender, EventArgs e)
{
Time.Enabled = false;
}
2013-04-20