Пример #1
0
        /// <summary>
        /// Shows screen saver by creating one instance of Window1 for each monitor.
        ///
        /// Note: uses WinForms's Screen class to get monitor info.
        /// </summary>
        void ShowScreensaver()
        {
            //creates window on primary screen
            SaverWindow primaryWindow = new SaverWindow();

            primaryWindow.WindowStartupLocation = WindowStartupLocation.Manual;
            System.Drawing.Rectangle location = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            primaryWindow.WindowState = WindowState.Maximized;

            //creates window on other screens
            foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
            {
                if (screen == System.Windows.Forms.Screen.PrimaryScreen)
                {
                    continue;
                }

                SaverWindow window = new SaverWindow();
                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 (Window window in System.Windows.Application.Current.Windows)
            {
                if (window != primaryWindow)
                {
                    window.Show();
                }
            }

            ///shows primary screen window last
            primaryWindow.Show();
        }
Пример #2
0
        /// <summary>
        /// Shows screen saver by creating one instance of Window1 for each monitor.
        /// 
        /// Note: uses WinForms's Screen class to get monitor info.
        /// </summary>
        void ShowScreensaver()
        {
            //creates window on primary screen
            SaverWindow primaryWindow = new SaverWindow();
            primaryWindow.WindowStartupLocation = WindowStartupLocation.Manual;
            System.Drawing.Rectangle location = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            primaryWindow.WindowState = WindowState.Maximized;

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

                SaverWindow window = new SaverWindow();
                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 (Window window in System.Windows.Application.Current.Windows)
            {
                if (window != primaryWindow)
                    window.Show();
            }

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