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
}
}