Exemple #1
0
        /// <summary>
        /// Shows screen saver by creating one instance of Screen for each monitor.
        /// 
        /// Note: uses WinForms's Screen class to get monitor info.
        /// </summary>
        void ShowScreenSaver()
        {
            //creates window on primary screen
            Screen primaryWindow = new Screen();
            primaryWindow.WindowStartupLocation = WindowStartupLocation.Manual;
            System.Drawing.Rectangle location = WinForms.Screen.PrimaryScreen.Bounds;
            primaryWindow.WindowState = WindowState.Maximized;

            //creates window on other screens
            foreach (var screen in WinForms.Screen.AllScreens)
            {
                if (screen == WinForms.Screen.PrimaryScreen)
                    continue;

                var window = new Screen();
                window.WindowStartupLocation = WindowStartupLocation.Manual;
                location = screen.Bounds;

                //covers entire monitor
                window.Left = location.X - 7;
                window.Top = location.Y - 7;
                window.Width = location.Width + 14;
                window.Height = location.Height + 14;
            }

            //show non-primary screen windows
            foreach (var window in Current.Windows)
                if (window != primaryWindow)
                    window.Show();

            ///shows primary screen window last
            primaryWindow.Show();
        }