c#实现屏保

实现思路:纯黑窗体去边框,加入标签。 使用Timmer让windows 10标签运动。限制标签的行为。

 

代码:

int deltX = 10;
int deltY = 8;
private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Left += deltX;//这里+=一个变量。
this.label1.Top += deltY;
if (this.label1.Top < 0 ||
this.label1.Top + this.label1.Height > this.Height)
deltY = -deltY;
if (this.label1.Left < 0 ||
this.label1.Left + this.label1.Width > this.Width)
deltX = -deltX;
使用外部参数来控制移动。

文章来源:

https://www.cnblogs.com/ilovepro/p/6211735.html
posted @ 2018-04-04 09:24  we_are_young  阅读(1305)  评论(0编辑  收藏  举报