Introduction
My son and I were watching a sci-fi show on television and saw a cool effect that simulated a spacecraft approaching light speed. Later he asked me if we could do something similar on the computer as a screen saver - this was our go at it.
Background
I found several C# starter programs that produced screen savers, but none of them I found would span multiple screens - this one does. It’s simple enough to be a good starting point for any other screen saver ideas you might have - if not, you can simply enjoy having this screen saver option in your collection.
Using the Code
To deploy the screen saver on your computer, you simply need to copy the binary file “Warp Speed.scr” to your Windows system32 folder (typically C:\Windows\system32\). Once there, the screen saver should appear on your system just like any other. There is a detailed set of options to tinker with for effect and the preview window works as well. Note that if you make modifications to the program and recompile, you will need to rename “Warp Speed.exe” to “Warp Speed.scr” and redeploy to your system folder. Here are some of the available options:
Points of Interest
Of special interest to those wanting to write a screen saver that spans multiple monitors will be the ScreenArea
class, here is an excerpt:
public static int LeftMostBound
{
get
{
int leftBound = int.MaxValue;
foreach (Screen display in Screen.AllScreens)
{
if (leftBound > display.Bounds.X)
leftBound = display.Bounds.X;
}
return leftBound;
}
}
This class allows the screen saver to calculate the bounds across all attached screens as follows:
Left = ScreenArea.LeftMostBound;
Top = ScreenArea.TopMostBound;
Width = ScreenArea.TotalWidth;
Height = ScreenArea.TotalHeight;
History
- 21st December, 2008: Initial post