Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: Multiple screens

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.

like image 814
Nathan Friend Avatar asked Jul 25 '13 13:07

Nathan Friend


1 Answers

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).

like image 179
Ani Avatar answered Oct 04 '22 22:10

Ani