Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphicsMain"/> class.
 /// </summary>
 /// <param name="host"></param>
 public ControlHost(HostForm host)
 {
     this.owner               = host;
     this.surfaces            = new Collection <Surface>();
     this.controls            = new DXControlCollection();
     this.settings            = new D3DSettings();
     this.parameters          = new PresentParameters();
     this.enumerationSettings = new D3DEnumeration();
     InitializeInputDevices();
     InitDirect3D();
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Constructor.  Pass in an enumeration and the current D3D settings.
    /// </summary>
    public D3DSettingsForm(D3DEnumeration enumerationParam, D3DSettings settingsParam)
    {
        enumeration = enumerationParam;
        settings    = settingsParam.Clone();

        // Required for Windows Form Designer support
        InitializeComponent();

        // Fill adapter combo box.  Updating the selected adapter will trigger
        // updates of the rest of the dialog.
        foreach (GraphicsAdapterInfo adapterInfo in enumeration.AdapterInfoList)
        {
            adapterComboBox.Items.Add(adapterInfo);
            if (adapterInfo.AdapterOrdinal == settings.AdapterOrdinal)
            {
                adapterComboBox.SelectedItem = adapterInfo;
            }
        }
        if (adapterComboBox.SelectedItem == null && adapterComboBox.Items.Count > 0)
        {
            adapterComboBox.SelectedIndex = 0;
        }
    }
Ejemplo n.º 3
0
		/// <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>
    /// Constructor.  Pass in an enumeration and the current D3D settings.
    /// </summary>
    public D3DSettingsForm(D3DEnumeration enumerationParam, D3DSettings settingsParam)
    {
        enumeration = enumerationParam;
        settings = settingsParam.Clone();

        // Required for Windows Form Designer support
        InitializeComponent();

        // Fill adapter combo box.  Updating the selected adapter will trigger
        // updates of the rest of the dialog.
        foreach (GraphicsAdapterInfo adapterInfo in enumeration.AdapterInfoList)
        {
            adapterComboBox.Items.Add(adapterInfo);
            if (adapterInfo.AdapterOrdinal == settings.AdapterOrdinal)
                adapterComboBox.SelectedItem = adapterInfo;
        }
        if (adapterComboBox.SelectedItem == null && adapterComboBox.Items.Count > 0)
            adapterComboBox.SelectedIndex = 0;
    }
    /// <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;
    }