Beispiel #1
0
        /// <summary>Called when the device type changes</summary>
        private void OnDeviceChanged(object sender, System.EventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            globalSettings.DeviceType = (DeviceType)cb.GetSelectedData();

            // Update windowed/full screen radio buttons
            bool hasWindowCombo = false;
            bool hasFullscreen  = false;

            EnumDeviceInformation edi = GetCurrentDeviceInfo();

            // See if there are any windowed/fullscreen combos
            foreach (EnumDeviceSettingsCombo edsc in edi.deviceSettingsList)
            {
                if (edsc.IsWindowed)
                {
                    hasWindowCombo = true;
                }
                else
                {
                    hasFullscreen = true;
                }
            }

            // Set the controls enable/disable property based on whether they are available or not
            dialog.SetControlEnable((int)SettingsDialogControlIds.Windowed, hasWindowCombo);
            dialog.SetControlEnable((int)SettingsDialogControlIds.Fullscreen, hasFullscreen);

            SetWindowed(globalSettings.presentParams.Windowed && hasWindowCombo);

            OnWindowedFullscreenChanged(null, e);
        }
Beispiel #2
0
        /// <summary>Called when the fullscreen or windowed item changes</summary>
        private void OnWindowedFullscreenChanged(object sender, System.EventArgs e)
        {
            bool isWindowed = windowedButton.IsChecked;

            globalSettings.presentParams.Windowed = isWindowed;

            // Set the control enabled or disabled properties
            dialog.SetControlEnable((int)SettingsDialogControlIds.AdapterFormatLabel, !isWindowed);
            dialog.SetControlEnable((int)SettingsDialogControlIds.ResolutionLabel, !isWindowed);
            dialog.SetControlEnable((int)SettingsDialogControlIds.RefreshRateLabel, !isWindowed);

            dialog.SetControlEnable((int)SettingsDialogControlIds.AdapterFormat, !isWindowed);
            dialog.SetControlEnable((int)SettingsDialogControlIds.Resolution, !isWindowed);
            dialog.SetControlEnable((int)SettingsDialogControlIds.RefreshRate, !isWindowed);
            dialog.SetControlEnable((int)SettingsDialogControlIds.DeviceClip, isWindowed);

            bool deviceClip = ((globalSettings.presentParams.PresentFlag & PresentFlag.DeviceClip) != 0);

            // If windowed, get the appropriate adapter format from Direct3D
            if (globalSettings.presentParams.Windowed)
            {
                DisplayMode mode = Manager.Adapters[(int)globalSettings.AdapterOrdinal].CurrentDisplayMode;
                globalSettings.AdapterFormat = mode.Format;
                globalSettings.presentParams.BackBufferWidth           = mode.Width;
                globalSettings.presentParams.BackBufferHeight          = mode.Height;
                globalSettings.presentParams.FullScreenRefreshRateInHz = mode.RefreshRate;
            }

            // Update the clip check box
            clipBox.IsChecked = deviceClip;

            // Update the adapter format list
            adapterFormatCombo.Clear();

            EnumDeviceInformation edi = GetCurrentDeviceInfo();

            if (isWindowed)
            {
                if (!adapterFormatCombo.ContainsItem(globalSettings.AdapterFormat.ToString()))
                {
                    adapterFormatCombo.AddItem(globalSettings.AdapterFormat.ToString(), globalSettings.AdapterFormat);
                }
            }
            else
            {
                // Add all the supported formats
                foreach (EnumDeviceSettingsCombo edsc in edi.deviceSettingsList)
                {
                    if (!adapterFormatCombo.ContainsItem(edsc.AdapterFormat.ToString()))
                    {
                        adapterFormatCombo.AddItem(edsc.AdapterFormat.ToString(), edsc.AdapterFormat);
                    }
                }
            }
            adapterFormatCombo.SetSelectedByData(globalSettings.AdapterFormat);
            // Adapter format changed, update there
            OnAdapterFormatChange(adapterFormatCombo, System.EventArgs.Empty);

            // Update resolution
            if (isWindowed)
            {
                resolution.Clear();
                AddResolution((short)globalSettings.presentParams.BackBufferWidth, (short)globalSettings.presentParams.BackBufferHeight);
            }
            resolution.SetSelectedByData(NativeMethods.MakeUInt32(
                                             (short)globalSettings.presentParams.BackBufferWidth, (short)globalSettings.presentParams.BackBufferHeight));

            // Resolution changed
            OnResolutionChanged(resolution, System.EventArgs.Empty);

            // Update refresh
            if (isWindowed)
            {
                refreshCombo.Clear();
                AddRefreshRate(globalSettings.presentParams.FullScreenRefreshRateInHz);
            }

            // Select the correct refresh rate
            refreshCombo.SetSelectedByData(globalSettings.presentParams.FullScreenRefreshRateInHz);

            // refresh rate changed
            OnRefreshRateChanged(refreshCombo, System.EventArgs.Empty);
        }
Beispiel #3
0
        /// <summary>Called when the back buffer format changes</summary>
        private void OnBackBufferChanged(object sender, System.EventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            globalSettings.presentParams.BackBufferFormat = (Format)backBufferCombo.GetSelectedData();

            // Store formats
            Format adapterFormat = globalSettings.AdapterFormat;
            Format backFormat    = globalSettings.presentParams.BackBufferFormat;

            EnumDeviceInformation edi = GetCurrentDeviceInfo();

            // Get possible vertex processing
            bool isAllowSoftware = Enumeration.IsSoftwareVertexProcessingPossible;
            bool isAllowHardware = Enumeration.IsHardwareVertexProcessingPossible;
            bool isAllowPure     = Enumeration.IsPureHardwareVertexProcessingPossible;
            bool isAllowMixed    = Enumeration.IsMixedVertexProcessingPossible;

            foreach (EnumDeviceSettingsCombo edsc in edi.deviceSettingsList)
            {
                if (edsc.IsWindowed == globalSettings.presentParams.Windowed &&
                    edsc.AdapterFormat == adapterFormat &&
                    edsc.BackBufferFormat == backFormat)
                {
                    // Clear the depth stencil buffer
                    depthStencilCombo.Clear();
                    depthStencilCombo.IsEnabled = (globalSettings.presentParams.EnableAutoDepthStencil);
                    if (globalSettings.presentParams.EnableAutoDepthStencil)
                    {
                        foreach (Format f in edsc.depthStencilFormatList)
                        {
                            if (!depthStencilCombo.ContainsItem(f.ToString()))
                            {
                                depthStencilCombo.AddItem(f.ToString(), f);
                            }
                        }

                        depthStencilCombo.SetSelectedByData(globalSettings.presentParams.AutoDepthStencilFormat);
                    }
                    else
                    {
                        if (!depthStencilCombo.ContainsItem("(not used)"))
                        {
                            depthStencilCombo.AddItem("(not used)", null);
                        }
                    }
                    OnDepthStencilChanged(depthStencilCombo, e);

                    // Now remove all the vertex processing information
                    vertexCombo.Clear();
                    if (isAllowPure)
                    {
                        AddVertexProcessing(CreateFlags.PureDevice);
                    }
                    if (isAllowHardware)
                    {
                        AddVertexProcessing(CreateFlags.HardwareVertexProcessing);
                    }
                    if (isAllowSoftware)
                    {
                        AddVertexProcessing(CreateFlags.SoftwareVertexProcessing);
                    }
                    if (isAllowMixed)
                    {
                        AddVertexProcessing(CreateFlags.MixedVertexProcessing);
                    }

                    // Select the right one
                    BehaviorFlags flags = new BehaviorFlags(globalSettings.BehaviorFlags);
                    if (flags.PureDevice)
                    {
                        vertexCombo.SetSelectedByData(CreateFlags.PureDevice);
                    }
                    else if (flags.HardwareVertexProcessing)
                    {
                        vertexCombo.SetSelectedByData(CreateFlags.HardwareVertexProcessing);
                    }
                    else if (flags.SoftwareVertexProcessing)
                    {
                        vertexCombo.SetSelectedByData(CreateFlags.SoftwareVertexProcessing);
                    }
                    else if (flags.MixedVertexProcessing)
                    {
                        vertexCombo.SetSelectedByData(CreateFlags.MixedVertexProcessing);
                    }

                    OnVertexProcessingChanged(vertexCombo, e);

                    // Now present intervals
                    presentCombo.Clear();
                    foreach (PresentInterval pf in edsc.presentIntervalList)
                    {
                        if (!presentCombo.ContainsItem(pf.ToString()))
                        {
                            presentCombo.AddItem(pf.ToString(), pf);
                        }
                    }

                    presentCombo.SetSelectedByData(globalSettings.presentParams.PresentationInterval);
                    OnPresentIntervalChanged(presentCombo, e);
                }
            }
        }
Beispiel #4
0
        /// <summary>Called when the adapter format changes</summary>
        private void OnAdapterFormatChange(object sender, System.EventArgs e)
        {
            ComboBox cb            = sender as ComboBox;
            Format   adapterFormat = (Format)cb.GetSelectedData();

            // Resolutions
            resolution.Clear();

            EnumAdapterInformation adapterInfo = GetCurrentAdapterInfo();

            foreach (DisplayMode dm in adapterInfo.displayModeList)
            {
                if (dm.Format == adapterFormat)
                {
                    AddResolution((short)dm.Width, (short)dm.Height);
                }
            }

            // Add Texture filters
            AddTextureFilter(TextureFilter.None);
            AddTextureFilter(TextureFilter.Linear);
            AddTextureFilter(TextureFilter.Anisotropic);

            uint currentResolution = NativeMethods.MakeUInt32(
                (short)globalSettings.presentParams.BackBufferWidth, (short)globalSettings.presentParams.BackBufferHeight);

            resolution.SetSelectedByData(currentResolution);
            // Resolution changed
            OnResolutionChanged(resolution, e);

            // Back buffer formats
            backBufferCombo.Clear();

            EnumDeviceInformation edi  = GetCurrentDeviceInfo();
            bool hasWindowedBackBuffer = false;
            bool isWindowed            = windowedButton.IsChecked;

            foreach (EnumDeviceSettingsCombo edsc in edi.deviceSettingsList)
            {
                if (edsc.IsWindowed == isWindowed &&
                    edsc.AdapterFormat == globalSettings.AdapterFormat)
                {
                    hasWindowedBackBuffer = true;
                    if (!backBufferCombo.ContainsItem(edsc.BackBufferFormat.ToString()))
                    {
                        backBufferCombo.AddItem(edsc.BackBufferFormat.ToString(), edsc.BackBufferFormat);
                    }
                }
            }
            // Update back buffer
            backBufferCombo.SetSelectedByData(globalSettings.presentParams.BackBufferFormat);
            OnBackBufferChanged(backBufferCombo, e);

            if (!hasWindowedBackBuffer)
            {
                dialog.SetControlEnable((int)SettingsDialogControlIds.Windowed, false);
                if (globalSettings.presentParams.Windowed)
                {
                    SetWindowed(false);
                    OnWindowedFullscreenChanged(null, e);
                }
            }
        }