Example #1
0
 private void CloseWpfWindow()
 {
   if (_wpfWindow != null)
   {
     // Close WPF window.
     _wpfWindow.Closing -= OnWindowClosing;  // Remove Closing event handler. (Otherwise, the event would exit the game.)
     _wpfWindow.Close();
     _wpfWindow = null;
   }
 }
Example #2
0
    private void OpenWpfWindow()
    {
      _wpfWindow = new WpfWindow { GraphicsService = _graphicsManager };
      _wpfWindow.Closing += OnWindowClosing;

      // Allow WPF window to receive keyboard events from Windows Forms.
      ElementHost.EnableModelessKeyboardInterop(_wpfWindow);

      _wpfWindow.Show();
    }
Example #3
0
 private void CloseWpfWindow()
 {
     if (_wpfWindow != null)
     {
         // Close WPF window. This must be executed on the WPF thread!
         WpfEnvironment.Dispatcher.Invoke((Action)(() =>
         {
             _wpfWindow.Closing -= OnWindowClosing; // Remove Closing event handler. (Otherwise, the event would exit the game.)
             _wpfWindow.Close();
             _wpfWindow = null;
         }));
     }
 }
Example #4
0
        private void OpenWpfWindow()
        {
            // WPF windows need to run on a separate thread. This thread is prepared by
            // the WpfEnvironment class. (Redundant calls of Startup() are no problem.)
            WpfEnvironment.Startup(Window.Handle);

            // WPF windows must be created and handled on the WPF thread. From the WpfEnvironment
            // class we can get the Dispatcher of the WPF thread. We can use it to execute actions
            // on the WPF thread.
            WpfEnvironment.Dispatcher.Invoke((Action)(() =>
            {
                _wpfWindow = new WpfWindow {
                    GraphicsService = _graphicsManager
                };
                _wpfWindow.Closing += OnWindowClosing;
                _wpfWindow.Show();
            }));
        }
Example #5
0
 private void CloseWpfWindow()
 {
   if (_wpfWindow != null)
   {
     // Close WPF window.
     _wpfWindow.Closing -= OnWindowClosing;  // Remove Closing event handler. (Otherwise, the event would exit the game.)
     _wpfWindow.Close();
     _wpfWindow = null;
   }
 }
Example #6
0
    private void OpenWpfWindow()
    {
      _wpfWindow = new WpfWindow { GraphicsService = _graphicsManager };
      _wpfWindow.Closing += OnWindowClosing;

      // Allow WPF window to receive keyboard events from Windows Forms.
      ElementHost.EnableModelessKeyboardInterop(_wpfWindow);

      _wpfWindow.Show();
    }