欢迎光临
我们一直在努力

用C#写的一个简单屏幕保护程序-.NET教程,C#语言

建站超值云服务器,限时71元/月

screensaver.cs

using system;

using system.windows.forms;

namespace screensaver

{

public class dotnetscreensaver

{

[stathread]

static void main(string[] args)

{

if (args.length > 0)

{

if (args[0].tolower().trim().substring(0,2) == "/c")

{

messagebox.show("this screen saver has no options you can set.", ".net screen saver", messageboxbuttons.ok, messageboxicon.exclamation);

}

else if (args[0].tolower() == "/s")

{

for (int i = screen.allscreens.getlowerbound(0); i <= screen.allscreens.getupperbound(0); i++)

system.windows.forms.application.run(new screensaverform(i));

}

}

else

{

for (int i = screen.allscreens.getlowerbound(0); i <= screen.allscreens.getupperbound(0); i++)

system.windows.forms.application.run(new screensaverform(i));

}

}

}

}

screensaverform.cs

using system;

using system.drawing;

using system.windows.forms;

namespace screensaver

{

public class screensaverform : system.windows.forms.form

{

private point mousexy;

private int screennumber;

public screensaverform(int scrn)

{

initializecomponent();

screennumber = scrn;

}

private void screensaverform_load(object sender, system.eventargs e)

{

this.bounds = screen.allscreens[screennumber].bounds;

cursor.hide();

topmost = true;

}

private void onmouseevent(object sender, system.windows.forms.mouseeventargs e)

{

if (!mousexy.isempty)

{

if (mousexy != new point(e.x, e.y))

close();

if (e.clicks > 0)

close();

}

mousexy = new point(e.x, e.y);

}

private void screensaverform_keydown(object sender, system.windows.forms.keyeventargs e)

{

close();

}

#region windows form designer generated code

/// <summary>

/// required method for designer support – do not modify

/// the contents of this method with the code editor.

/// </summary>

private void initializecomponent()

{

//

// screensaverform

//

this.autoscalebasesize = new system.drawing.size(5, 13);

this.backcolor = system.drawing.color.black;

this.clientsize = new system.drawing.size(292, 273);

this.formborderstyle = system.windows.forms.formborderstyle.none;

this.name = "screensaverform";

this.text = "screensaver";

this.keydown += new system.windows.forms.keyeventhandler(this.screensaverform_keydown);

this.mousedown += new system.windows.forms.mouseeventhandler(this.onmouseevent);

this.load += new system.eventhandler(this.screensaverform_load);

this.mousemove += new system.windows.forms.mouseeventhandler(this.onmouseevent);

}

#endregion

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用C#写的一个简单屏幕保护程序-.NET教程,C#语言
分享到: 更多 (0)