📄 d3dsettingsform.cs
字号:
//-----------------------------------------------------------------------------
// File: D3DSettingsForm.cs
//
// Desc: Application form for setting up user defined display settings
//
// Copyright (c) 2001-2002 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Windows.Forms;
using Microsoft.DirectX.Direct3D;
/// <summary>
/// Current D3D settings: adapter, device, mode, formats, etc.
/// </summary>
public class D3DSettings
{
public bool IsWindowed;
public GraphicsAdapterInfo WindowedAdapterInfo;
public GraphicsDeviceInfo WindowedDeviceInfo;
public DeviceCombo WindowedDeviceCombo;
public DisplayMode WindowedDisplayMode; // not changable by the user
public DepthFormat WindowedDepthStencilBufferFormat;
public MultiSampleType WindowedMultisampleType;
public int WindowedMultisampleQuality;
public VertexProcessingType WindowedVertexProcessingType;
public PresentInterval WindowedPresentInterval;
public int WindowedWidth;
public int WindowedHeight;
public GraphicsAdapterInfo FullscreenAdapterInfo;
public GraphicsDeviceInfo FullscreenDeviceInfo;
public DeviceCombo FullscreenDeviceCombo;
public DisplayMode FullscreenDisplayMode; // changable by the user
public DepthFormat FullscreenDepthStencilBufferFormat;
public MultiSampleType FullscreenMultisampleType;
public int FullscreenMultisampleQuality;
public VertexProcessingType FullscreenVertexProcessingType;
public PresentInterval FullscreenPresentInterval;
/// <summary>
/// The adapter information
/// </summary>
public GraphicsAdapterInfo AdapterInfo
{
get { return IsWindowed ? WindowedAdapterInfo : FullscreenAdapterInfo; }
set { if (IsWindowed) WindowedAdapterInfo = value; else FullscreenAdapterInfo = value; }
}
/// <summary>
/// The device information
/// </summary>
public GraphicsDeviceInfo DeviceInfo
{
get { return IsWindowed ? WindowedDeviceInfo : FullscreenDeviceInfo; }
set { if (IsWindowed) WindowedDeviceInfo = value; else FullscreenDeviceInfo = value; }
}
/// <summary>
/// The device combo
/// </summary>
public DeviceCombo DeviceCombo
{
get { return IsWindowed ? WindowedDeviceCombo : FullscreenDeviceCombo; }
set { if (IsWindowed) WindowedDeviceCombo = value; else FullscreenDeviceCombo = value; }
}
/// <summary>
/// The adapters ordinal
/// </summary>
public int AdapterOrdinal
{
get { return DeviceCombo.AdapterOrdinal; }
}
/// <summary>
/// The type of device this is
/// </summary>
public DeviceType DevType
{
get { return DeviceCombo.DevType; }
}
/// <summary>
/// The back buffers format
/// </summary>
public Format BackBufferFormat
{
get { return DeviceCombo.BackBufferFormat; }
}
// The display mode
public DisplayMode DisplayMode
{
get { return IsWindowed ? WindowedDisplayMode : FullscreenDisplayMode; }
set { if (IsWindowed) WindowedDisplayMode = value; else FullscreenDisplayMode = value; }
}
// The Depth stencils format
public DepthFormat DepthStencilBufferFormat
{
get { return IsWindowed ? WindowedDepthStencilBufferFormat : FullscreenDepthStencilBufferFormat; }
set { if (IsWindowed) WindowedDepthStencilBufferFormat = value; else FullscreenDepthStencilBufferFormat = value; }
}
/// <summary>
/// The multisample type
/// </summary>
public MultiSampleType MultisampleType
{
get { return IsWindowed ? WindowedMultisampleType : FullscreenMultisampleType; }
set { if (IsWindowed) WindowedMultisampleType = value; else FullscreenMultisampleType = value; }
}
/// <summary>
/// The multisample quality
/// </summary>
public int MultisampleQuality
{
get { return IsWindowed ? WindowedMultisampleQuality : FullscreenMultisampleQuality; }
set { if (IsWindowed) WindowedMultisampleQuality = value; else FullscreenMultisampleQuality = value; }
}
/// <summary>
/// The vertex processing type
/// </summary>
public VertexProcessingType VertexProcessingType
{
get { return IsWindowed ? WindowedVertexProcessingType : FullscreenVertexProcessingType; }
set { if (IsWindowed) WindowedVertexProcessingType = value; else FullscreenVertexProcessingType = value; }
}
/// <summary>
/// The presentation interval
/// </summary>
public PresentInterval PresentInterval
{
get { return IsWindowed ? WindowedPresentInterval : FullscreenPresentInterval; }
set { if (IsWindowed) WindowedPresentInterval = value; else FullscreenPresentInterval = value; }
}
/// <summary>
/// Clone the d3d settings class
/// </summary>
public D3DSettings Clone()
{
return (D3DSettings)MemberwiseClone();
}
}
/// <summary>
/// A form to allow the user to change the current D3D settings.
/// </summary>
public class D3DSettingsForm : System.Windows.Forms.Form
{
private D3DEnumeration enumeration;
public D3DSettings settings; // Potential new D3D settings
private System.Windows.Forms.GroupBox adapterDeviceGroupBox;
private System.Windows.Forms.Label displayAdapterLabel;
private System.Windows.Forms.ComboBox adapterComboBox;
private System.Windows.Forms.Label deviceLabel;
private System.Windows.Forms.ComboBox deviceComboBox;
private System.Windows.Forms.GroupBox modeSettingsGroupBox;
private System.Windows.Forms.RadioButton windowedRadioButton;
private System.Windows.Forms.RadioButton fullscreenRadioButton;
private System.Windows.Forms.Label adapterFormatLabel;
private System.Windows.Forms.ComboBox adapterFormatComboBox;
private System.Windows.Forms.Label resolutionLabel;
private System.Windows.Forms.ComboBox resolutionComboBox;
private System.Windows.Forms.Label refreshRateLabel;
private System.Windows.Forms.ComboBox refreshRateComboBox;
private System.Windows.Forms.GroupBox otherSettingsGroupBox;
private System.Windows.Forms.Label backBufferFormatLabel;
private System.Windows.Forms.ComboBox backBufferFormatComboBox;
private System.Windows.Forms.Label depthStencilBufferLabel;
private System.Windows.Forms.ComboBox depthStencilBufferComboBox;
private System.Windows.Forms.Label multisampleLabel;
private System.Windows.Forms.ComboBox multisampleComboBox;
private System.Windows.Forms.Label vertexProcLabel;
private System.Windows.Forms.ComboBox vertexProcComboBox;
private System.Windows.Forms.Label presentIntervalLabel;
private System.Windows.Forms.ComboBox presentIntervalComboBox;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.ComboBox multisampleQualityComboBox;
private System.Windows.Forms.Label multisampleQualityLabel;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
/// <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>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool Disposing)
{
base.Dispose(Disposing);
if (components != null)
components.Dispose();
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.adapterDeviceGroupBox = new System.Windows.Forms.GroupBox();
this.deviceComboBox = new System.Windows.Forms.ComboBox();
this.deviceLabel = new System.Windows.Forms.Label();
this.adapterComboBox = new System.Windows.Forms.ComboBox();
this.displayAdapterLabel = new System.Windows.Forms.Label();
this.fullscreenRadioButton = new System.Windows.Forms.RadioButton();
this.cancelButton = new System.Windows.Forms.Button();
this.otherSettingsGroupBox = new System.Windows.Forms.GroupBox();
this.multisampleQualityComboBox = new System.Windows.Forms.ComboBox();
this.multisampleQualityLabel = new System.Windows.Forms.Label();
this.multisampleComboBox = new System.Windows.Forms.ComboBox();
this.backBufferFormatComboBox = new System.Windows.Forms.ComboBox();
this.multisampleLabel = new System.Windows.Forms.Label();
this.depthStencilBufferLabel = new System.Windows.Forms.Label();
this.backBufferFormatLabel = new System.Windows.Forms.Label();
this.depthStencilBufferComboBox = new System.Windows.Forms.ComboBox();
this.vertexProcComboBox = new System.Windows.Forms.ComboBox();
this.vertexProcLabel = new System.Windows.Forms.Label();
this.presentIntervalComboBox = new System.Windows.Forms.ComboBox();
this.presentIntervalLabel = new System.Windows.Forms.Label();
this.resolutionComboBox = new System.Windows.Forms.ComboBox();
this.windowedRadioButton = new System.Windows.Forms.RadioButton();
this.resolutionLabel = new System.Windows.Forms.Label();
this.refreshRateComboBox = new System.Windows.Forms.ComboBox();
this.adapterFormatLabel = new System.Windows.Forms.Label();
this.refreshRateLabel = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.modeSettingsGroupBox = new System.Windows.Forms.GroupBox();
this.adapterFormatComboBox = new System.Windows.Forms.ComboBox();
this.adapterDeviceGroupBox.SuspendLayout();
this.otherSettingsGroupBox.SuspendLayout();
this.modeSettingsGroupBox.SuspendLayout();
this.SuspendLayout();
//
// adapterDeviceGroupBox
//
this.adapterDeviceGroupBox.Controls.AddRange(new System.Windows.Forms.Control[] {
this.deviceComboBox,
this.deviceLabel,
this.adapterComboBox,
this.displayAdapterLabel});
this.adapterDeviceGroupBox.Location = new System.Drawing.Point(16, 8);
this.adapterDeviceGroupBox.Name = "adapterDeviceGroupBox";
this.adapterDeviceGroupBox.Size = new System.Drawing.Size(400, 80);
this.adapterDeviceGroupBox.TabIndex = 0;
this.adapterDeviceGroupBox.TabStop = false;
this.adapterDeviceGroupBox.Text = "Adapter and device";
//
// deviceComboBox
//
this.deviceComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.deviceComboBox.DropDownWidth = 121;
this.deviceComboBox.Location = new System.Drawing.Point(160, 48);
this.deviceComboBox.Name = "deviceComboBox";
this.deviceComboBox.Size = new System.Drawing.Size(232, 21);
this.deviceComboBox.TabIndex = 3;
this.deviceComboBox.SelectedIndexChanged += new System.EventHandler(this.DeviceChanged);
//
// deviceLabel
//
this.deviceLabel.Location = new System.Drawing.Point(8, 48);
this.deviceLabel.Name = "deviceLabel";
this.deviceLabel.Size = new System.Drawing.Size(152, 23);
this.deviceLabel.TabIndex = 2;
this.deviceLabel.Text = "Render &Device:";
//
// adapterComboBox
//
this.adapterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.adapterComboBox.DropDownWidth = 121;
this.adapterComboBox.Location = new System.Drawing.Point(160, 24);
this.adapterComboBox.Name = "adapterComboBox";
this.adapterComboBox.Size = new System.Drawing.Size(232, 21);
this.adapterComboBox.TabIndex = 1;
this.adapterComboBox.SelectedIndexChanged += new System.EventHandler(this.AdapterChanged);
//
// displayAdapterLabel
//
this.displayAdapterLabel.Location = new System.Drawing.Point(8, 24);
this.displayAdapterLabel.Name = "displayAdapterLabel";
this.displayAdapterLabel.Size = new System.Drawing.Size(152, 23);
this.displayAdapterLabel.TabIndex = 0;
this.displayAdapterLabel.Text = "Display &Adapter:";
//
// fullscreenRadioButton
//
this.fullscreenRadioButton.Location = new System.Drawing.Point(9, 38);
this.fullscreenRadioButton.Name = "fullscreenRadioButton";
this.fullscreenRadioButton.Size = new System.Drawing.Size(152, 24);
this.fullscreenRadioButton.TabIndex = 1;
this.fullscreenRadioButton.Text = "&Fullscreen";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -