/// <summary>Called when the adapter changes</summary> private void OnAdapterChanged(object sender, System.EventArgs e) { ComboBox cb = sender as ComboBox; // Store the adapter index globalSettings.AdapterOrdinal = (uint)(int)cb.GetSelectedData(); // Remove all the items from the device type deviceCombo.Clear(); // Get the adapter information EnumAdapterInformation adapterInfo = GetCurrentAdapterInfo(); // Add each device type to the combo list foreach (EnumDeviceInformation edi in adapterInfo.deviceInfoList) { if (!deviceCombo.ContainsItem(edi.DeviceType.ToString())) { deviceCombo.AddItem(edi.DeviceType.ToString(), edi.DeviceType); } } deviceCombo.SetSelectedByData(globalSettings.DeviceType); // Device type was changed update OnDeviceChanged(deviceCombo, e); }
/// <summary>Called when the resolution changes</summary> private void OnResolutionChanged(object sender, System.EventArgs e) { ComboBox cb = sender as ComboBox; // Set the resolution uint data = (uint)cb.GetSelectedData(); int width = NativeMethods.LoWord(data); int height = NativeMethods.HiWord(data); globalSettings.presentParams.BackBufferWidth = width; globalSettings.presentParams.BackBufferHeight = height; int refreshRate = globalSettings.presentParams.FullScreenRefreshRateInHz; // Update the refresh rate list refreshCombo.Clear(); EnumAdapterInformation adapterInfo = GetCurrentAdapterInfo(); Format adapterFormat = globalSettings.AdapterFormat; foreach (DisplayMode dm in adapterInfo.displayModeList) { if (dm.Format == adapterFormat && dm.Width == width && dm.Height == height) { AddRefreshRate(dm.RefreshRate); } } // select and update refreshCombo.SetSelectedByData(refreshRate); OnRefreshRateChanged(refreshCombo, e); }
private void InitResolutions() { // Resolutions comboResolution.Clear(); // Add the windowed option. comboResolution.AddItem("Windowed", null); EnumAdapterInformation adapterInfo = Enumeration.GetAdapterInformation(globalSettings.AdapterOrdinal); foreach (DisplayMode dm in adapterInfo.displayModeList) { if ((dm.Format == globalSettings.AdapterFormat) && (dm.Height >= 480)) { AddResolution((short)dm.Width, (short)dm.Height); } } if (globalSettings.presentParams.Windowed) { comboResolution.SetSelected(0); } else { comboResolution.SetSelectedByData(NativeMethods.MakeUInt32( (short)globalSettings.presentParams.BackBufferWidth, (short)globalSettings.presentParams.BackBufferHeight)); } }
/// <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); } } }
/// <summary>Changes the UI defaults to the current device settings</summary> public void Refresh() { // Get some information globalSettings = parent.DeviceSettings.Clone(); System.Drawing.Rectangle client = parent.WindowClientRectangle; windowWidth = (uint)client.Width; windowHeight = (uint)client.Height; // Fill the UI with the current settings if (!deviceCombo.ContainsItem(globalSettings.DeviceType.ToString())) { deviceCombo.AddItem(globalSettings.DeviceType.ToString(), globalSettings.DeviceType.ToString()); } SetWindowed(globalSettings.presentParams.Windowed); clipBox.IsChecked = ((globalSettings.presentParams.PresentFlag & PresentFlag.DeviceClip) != 0); if (!adapterFormatCombo.ContainsItem(globalSettings.AdapterFormat.ToString())) { adapterFormatCombo.AddItem(globalSettings.AdapterFormat.ToString(), globalSettings.AdapterFormat); } AddResolution((short)globalSettings.presentParams.BackBufferWidth, (short)globalSettings.presentParams.BackBufferHeight); AddRefreshRate(globalSettings.presentParams.FullScreenRefreshRateInHz); if (!backBufferCombo.ContainsItem(globalSettings.presentParams.BackBufferFormat.ToString())) { backBufferCombo.AddItem(globalSettings.presentParams.BackBufferFormat.ToString(), globalSettings.presentParams.BackBufferFormat); } if (!depthStencilCombo.ContainsItem(globalSettings.presentParams.AutoDepthStencilFormat.ToString())) { depthStencilCombo.AddItem(globalSettings.presentParams.AutoDepthStencilFormat.ToString(), globalSettings.presentParams.AutoDepthStencilFormat); } if (!multiSampleTypeCombo.ContainsItem(globalSettings.presentParams.MultiSample.ToString())) { multiSampleTypeCombo.AddItem(globalSettings.presentParams.MultiSample.ToString(), globalSettings.presentParams.MultiSample); } if (!multiSampleQualityCombo.ContainsItem(globalSettings.presentParams.MultiSampleQuality.ToString())) { multiSampleQualityCombo.AddItem(globalSettings.presentParams.MultiSampleQuality.ToString(), globalSettings.presentParams.MultiSampleQuality); } if (!presentCombo.ContainsItem(globalSettings.presentParams.PresentationInterval.ToString())) { presentCombo.AddItem(globalSettings.presentParams.PresentationInterval.ToString(), globalSettings.presentParams.PresentationInterval); } if (!textureFilterCombo.ContainsItem(globalSettings.TextureFilter.ToString())) { textureFilterCombo.AddItem(globalSettings.TextureFilter.ToString(), globalSettings.TextureFilter); } BehaviorFlags flags = new BehaviorFlags(globalSettings.BehaviorFlags); if (flags.PureDevice) { AddVertexProcessing(CreateFlags.PureDevice); } else if (flags.HardwareVertexProcessing) { AddVertexProcessing(CreateFlags.HardwareVertexProcessing); } else if (flags.SoftwareVertexProcessing) { AddVertexProcessing(CreateFlags.SoftwareVertexProcessing); } else if (flags.MixedVertexProcessing) { AddVertexProcessing(CreateFlags.MixedVertexProcessing); } // Get the adapters list from Enumeration object ArrayList adapterInfoList = Enumeration.AdapterInformationList; if (adapterInfoList.Count == 0) { throw new NoCompatibleDevicesException(); } adapterCombo.Clear(); // Add all of the adapters for (int iAdapter = 0; iAdapter < adapterInfoList.Count; iAdapter++) { EnumAdapterInformation adapterInfo = adapterInfoList[iAdapter] as EnumAdapterInformation; if (!adapterCombo.ContainsItem(adapterInfo.UniqueDescription)) { adapterCombo.AddItem(adapterInfo.UniqueDescription, iAdapter); } } adapterCombo.SetSelectedByData(globalSettings.AdapterOrdinal); // The adapter changed, call the handler OnAdapterChanged(adapterCombo, System.EventArgs.Empty); Dialog.SetRefreshTime((float)FrameworkTimer.GetTime()); }