|
#region Using Statements
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX.Direct3D;
#endregion Using Statements
namespace AViD
{
/// <summary>
/// The <see cref="DeviceSettings"/> class is used to change the settings for the currently selected device.
/// The code is borrowed from http://ryanscook.com/adminsBlog/2006/04/d3dcontrol-update.html.
/// </summary>
public partial class DeviceSettings : Form
{
#region Constructor
/// <summary>
/// Creates a new instance of the DeviceSettings form.
/// </summary>
/// <param name="deviceInfo">The <see cref="DeviceInfo"/> dataset containing the supported settings.</param>
public DeviceSettings(DeviceInfo deviceInfo)
{
InitializeComponent();
this.m_deviceInfo = deviceInfo;
// Adapter List
this.adapterList.Items.Add(Manager.Adapters.Default.Information.Description);
this.adapterList.SelectedIndex = 0;
// Render Device List
foreach (DeviceType deviceType in this.m_deviceInfo.GetDeviceTypes())
this.renderDeviceList.Items.Add(deviceType.ToString());
this.renderDeviceList.SelectedIndex = 0;
// Adapter Format List
this.adapterFormatList.Items.Add(Manager.Adapters.Default.CurrentDisplayMode.Format.ToString());
this.adapterFormatList.SelectedIndex = 0;
// Resolution List
this.resolutionList.Items.Add(string.Format("{0} by {1}",
Manager.Adapters.Default.CurrentDisplayMode.Width,
Manager.Adapters.Default.CurrentDisplayMode.Height));
this.resolutionList.SelectedIndex = 0;
// Refresh Rate List
this.refreshRateList.Items.Add(Manager.Adapters.Default.CurrentDisplayMode.RefreshRate.ToString() + " Hz");
this.refreshRateList.SelectedIndex = 0;
}
#endregion Constructor
#region Public Properties
/// <summary>
/// Gets/sets the DeviceType Format.
/// </summary>
public DeviceType DeviceType
{
get
{
return (DeviceType)Enum.Parse(typeof(DeviceType), this.renderDeviceList.SelectedItem.ToString());
}
set
{
this.renderDeviceList.SelectedItem = value.ToString();
}
}
/// <summary>
/// Gets/sets the BackBuffer Format.
/// </summary>
public Format BackBufferFormat
{
get
{
return (Format)Enum.Parse(typeof(Format), this.backBufferList.SelectedItem.ToString());
}
set
{
this.backBufferList.SelectedItem = value.ToString();
}
}
/// <summary>
/// Gets/sets the Depth Format.
/// </summary>
public DepthFormat DepthStencilFormat
{
get
{
return (DepthFormat)Enum.Parse(typeof(DepthFormat), this.depthStencilList.SelectedItem.ToString());
}
set
{
this.depthStencilList.SelectedItem = value.ToString();
}
}
/// <summary>
/// Gets/sets the VertexProcessingFlag.
/// </summary>
public CreateFlags VertexProcessingFlag
{
get
{
return (CreateFlags)Enum.Parse(typeof(CreateFlags), this.vertexProcessingList.SelectedItem.ToString());
}
set
{
this.vertexProcessingList.SelectedItem = value.ToString();
}
}
/// <summary>
/// Gets/sets the MultiSample Type.
/// </summary>
public MultiSampleType MultiSample
{
get
{
return (MultiSampleType)Enum.Parse(typeof(MultiSampleType), this.sampleTypeList.SelectedItem.ToString());
}
set
{
this.sampleTypeList.SelectedItem = value.ToString();
}
}
/// <summary>
/// Gets/sets the PresentInterval flag.
/// </summary>
public PresentInterval PresentInterval
{
get
{
return (PresentInterval)Enum.Parse(typeof(PresentInterval), this.presentIntervalList.SelectedItem.ToString());
}
set
{
this.presentIntervalList.SelectedItem = value.ToString();
}
}
#endregion Public Properties
#region Events/Delegates
/// <summary>
/// Handles the event when the user changes the SelectedIndex for the RenderDevice list.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> of the event.</param>
private void renderDeviceList_SelectedIndexChanged(object sender, EventArgs e)
{
CreateFlags vf;
PresentInterval validPresent;
// Back Buffer List
this.backBufferList.Items.Clear();
foreach (Format f in this.m_deviceInfo.GetBackBufferFormats(this.DeviceType, true))
this.backBufferList.Items.Add(f.ToString());
this.backBufferList.SelectedIndex = 0;
// Vertex Processing List
this.vertexProcessingList.Items.Clear();
vf = DeviceInfo.GetVertexProcessingFlags(this.DeviceType);
if ((CreateFlags.HardwareVertexProcessing & vf) == CreateFlags.HardwareVertexProcessing)
this.vertexProcessingList.Items.Add(CreateFlags.HardwareVertexProcessing.ToString());
if ((CreateFlags.MixedVertexProcessing & vf) == CreateFlags.MixedVertexProcessing)
this.vertexProcessingList.Items.Add(CreateFlags.MixedVertexProcessing.ToString());
if ((CreateFlags.SoftwareVertexProcessing & vf) == CreateFlags.SoftwareVertexProcessing)
this.vertexProcessingList.Items.Add(CreateFlags.SoftwareVertexProcessing.ToString());
this.vertexProcessingList.SelectedIndex = 0;
// Present Interval List
validPresent = DeviceInfo.GetPresentIntervals(this.DeviceType);
this.presentIntervalList.Items.Clear();
foreach (PresentInterval interval in Enum.GetValues(typeof(PresentInterval)))
if ((interval & validPresent) == interval)
this.presentIntervalList.Items.Add(interval.ToString());
this.presentIntervalList.SelectedIndex = 0;
}
/// <summary>
/// Handles the event when the user changes the SelectedIndex for the BackBufferList list.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> of the event.</param>
private void backBufferList_SelectedIndexChanged(object sender, EventArgs e)
{
this.depthStencilList.Items.Clear();
foreach (DepthFormat df in DeviceInfo.GetDepthStencilFormats(this.DeviceType, this.BackBufferFormat))
this.depthStencilList.Items.Add(df.ToString());
if (this.depthStencilList.Items.Count > 0)
this.depthStencilList.SelectedIndex = 0;
}
/// <summary>
/// Handles the event when the user changes the SelectedIndex for the DepthStencil list.
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> of the event.</param>
private void depthStencilList_SelectedIndexChanged(object sender, EventArgs e)
{
this.sampleTypeList.Items.Clear();
foreach (MultiSampleType mst in DeviceInfo.GetMultiSampleTypes(this.DeviceType, this.BackBufferFormat, this.DepthStencilFormat, true))
this.sampleTypeList.Items.Add(mst.ToString());
if (this.sampleTypeList.Items.Count > 0)
this.sampleTypeList.SelectedIndex = 0;
}
#endregion Events/Delegates
#region Private Members
private DeviceInfo m_deviceInfo;
#endregion Private Members
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Since I've begun my profession as a software developer, I've learned one important fact - change is inevitable. Requirements change, code changes, and life changes.
So..If you're not moving forward, you're moving backwards.