?? form1.cs
字號(hào):
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace Chapter2Code
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TreeView treeView1;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Size = new Size(800, 600);
}
/// <summary>
/// We will fill our tree view here
/// </summary>
public void LoadGraphics()
{
bool b = Manager.CheckDeviceFormatConversion(0, DeviceType.Hardware, Format.X8R8G8B8, Format.A8R8G8B8);
foreach(AdapterInformation ai in Manager.Adapters)
{
TreeNode root = new TreeNode(ai.Information.Description);
TreeNode driverInfo = new TreeNode(string.Format
("Driver information: {0} - {1}",
ai.Information.DriverName,
ai.Information.DriverVersion) );
// Add the driver information to the root node
root.Nodes.Add(driverInfo);
// Get each display mode supported
TreeNode displayMode = new TreeNode(string.Format
("Current Display Mode: {0}x{1}x{2}",
ai.CurrentDisplayMode.Width,
ai.CurrentDisplayMode.Height,
ai.CurrentDisplayMode.Format));
foreach(DisplayMode dm in ai.SupportedDisplayModes)
{
TreeNode supportedNode = new TreeNode(string.Format
("Supported: {0}x{1}x{2}",
dm.Width, dm.Height, dm.Format));
displayMode.Nodes.Add(supportedNode);
}
// Add the display modes
root.Nodes.Add(displayMode);
// Add the root node
treeView1.Nodes.Add(root);
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#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.treeView1 = new System.Windows.Forms.TreeView();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.Dock = System.Windows.Forms.DockStyle.Left;
this.treeView1.ImageIndex = -1;
this.treeView1.Name = "treeView1";
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(280, 478);
this.treeView1.TabIndex = 0;
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
//
// textBox1
//
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(280, 0);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(400, 478);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(680, 478);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBox1,
this.treeView1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
PresentParameters p = new PresentParameters();
using (Form1 frm = new Form1())
{
frm.LoadGraphics();
Application.Run(frm);
}
}
private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
if (e.Node.Parent == null) // root node
{
// Get the device caps for this node
textBox1.Text = e.Node.Text + " Capabilities: \r\n\r\n" + Manager.GetDeviceCaps
(e.Node.Index, DeviceType.Hardware).ToString().Replace("\n", "\r\n");
}
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -