I'm writing a screensaver in WPF. I have the screensaver working, however, it only displays on my main monitor. Is there a way to "black out" or draw graphics to additional monitors when the user has multiple displays? I've done some searching around, but haven't found anything relevant.
UPDATE
From ananthonline's answer below, I was able to accomplish the "black out" effect on non-primary displays using the following window:
<Window x:Class="ScreenSaver.BlackOut"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Cursor="None" WindowStyle="None" ResizeMode="NoResize" Background="Black">
</Window>
and initializing one for each screen in App.xaml.cs
using the following process:
foreach (Screen s in Screen.AllScreens)
{
if (s != Screen.PrimaryScreen)
{
BlackOut blackOut = new BlackOut();
blackOut.Top = s.WorkingArea.Top;
blackOut.Left = s.WorkingArea.Left;
blackOut.Width = s.WorkingArea.Width;
blackOut.Height = s.WorkingArea.Height;
blackOut.Show();
}
}
Note an import to System.Windows.Forms
is required to access the Screen
class.
You should be able to use the System.Drawing.Screen.* classes to set up multiple windows on each screen. Mind that you don't set each window to be maximized, but a properly sized, border less window.
Also - you might want to remember that the total bounds of the multi monitor setup may not always be a rectangle (if you plan to "union" all the bounds to create a window spanning all monitors).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With