Example #1
0
        private void UpdateWindowKeys(KeyboardState keyboard)
        {
            if (keyboard.IsKeyDown(Key.Escape))
            {
                Exit();
            }

            if (keyboard[Key.F11] && (lastKeyboard[Key.F11] != keyboard[Key.F11]))
            {
                DisplayDevice defaultDisplayDevice = DisplayDevice.GetDisplay(DisplayIndex.Default);

                if (WindowState == WindowState.Fullscreen)
                {
                    WindowState   = WindowState.Normal;
                    CursorVisible = true;
                    defaultDisplayDevice.RestoreResolution();
                }
                else
                {
                    WindowState   = WindowState.Fullscreen;
                    CursorVisible = false;
                    defaultDisplayDevice
                    .ChangeResolution(
                        Const.DISPLAY_FULLHD_W, Const.DISPLAY_FULLHD_H,
                        Const.DISPLAY_BITPERPIXEL,
                        Const.DISPLAY_REFRESH_RATE);
                }
            } // if state F11
        }     // UpdateWindowKeys()
 public static void Main()
 {
     for (int i = 0; i < 6; i++)
     {
         DisplayDevice dev = DisplayDevice.GetDisplay(DisplayIndex.First + i);
         if (dev != null)
         {
             Trace.WriteLine(dev.ToString());
             MessageBox.Show(dev.ToString());
             dev.ChangeResolution(dev.SelectResolution(640, 480, 32, 60.0f));
             Thread.Sleep(1000);
             MessageBox.Show(dev.ToString());
             dev.RestoreResolution();
             Thread.Sleep(1000);
             MessageBox.Show(dev.ToString());
         }
     }
 }
Example #3
0
        private void ToggleFullscreen()
        {
            DisplayDevice defaultDisplayDevice = DisplayDevice.GetDisplay(DisplayIndex.Default);

            if (WindowState == WindowState.Fullscreen)
            {
                WindowState   = WindowState.Normal;
                CursorVisible = true;
                defaultDisplayDevice.RestoreResolution();
            }
            else
            {
                WindowState   = WindowState.Fullscreen;
                CursorVisible = false;
                defaultDisplayDevice
                .ChangeResolution(
                    Const.DISPLAY_FULLHD_W, Const.DISPLAY_FULLHD_H,
                    Const.DISPLAY_BITPERPIXEL,
                    Const.DISPLAY_REFRESH_RATE);
            }
        }
Example #4
0
 protected virtual void RestoreResolution(DisplayDevice displayDevice) => displayDevice.RestoreResolution();