/// <summary> /// Displays a dialog so the user can select a new adapter, device, or /// display mode, and then recreates the 3D environment if needed /// </summary> public void DxSelectNewDevice() { // Can't display dialogs in fullscreen mode this.DxFullScreen = false; // Make sure the main form is in the background this.SendToBack(); // --- Display settings dialog --- D3DSettingsForm settingsForm = new D3DSettingsForm(mEnumerationSettings, mGraphicsSettings); System.Windows.Forms.DialogResult result = settingsForm.ShowDialog(null); if (result != System.Windows.Forms.DialogResult.OK) return; // User hit cancel mGraphicsSettings = settingsForm.settings; // Inform the display class of the change. It will internally // re-create valid surfaces, a d3ddevice, etc. InitializeEnvironment(!mGraphicsSettings.IsWindowed); }
/// <summary> /// Displays a dialog so the user can select a new adapter, device, or /// display mode, and then recreates the 3D environment if needed /// </summary> private void DoSelectNewDevice() { isHandlingSizeChanges = false; // Can't display dialogs in fullscreen mode if (windowed == false) { try { ToggleFullscreen(); isHandlingSizeChanges = false; } catch { HandleSampleException(new ResetFailedException(), ApplicationMessage.ApplicationMustExit); return; } } // Make sure the main form is in the background this.SendToBack(); D3DSettingsForm settingsForm = new D3DSettingsForm(enumerationSettings, graphicsSettings); System.Windows.Forms.DialogResult result = settingsForm.ShowDialog(null); if (result != System.Windows.Forms.DialogResult.OK) { isHandlingSizeChanges = true; return; } graphicsSettings = settingsForm.settings; windowed = graphicsSettings.IsWindowed; // Release display objects, so a new device can be created device.Dispose(); device = null; // Inform the display class of the change. It will internally // re-create valid surfaces, a d3ddevice, etc. try { InitializeEnvironment(); } catch(SampleException d3de) { HandleSampleException(d3de, ApplicationMessage.ApplicationMustExit); } catch { HandleSampleException(new SampleException(), ApplicationMessage.ApplicationMustExit); } // If the app is paused, trigger the rendering of the current frame if (false == frameMoving) { singleStep = true; DXUtil.Timer(DirectXTimer.Start); DXUtil.Timer(DirectXTimer.Stop); } isHandlingSizeChanges = true; }