private void _refreshConfig()
{
ConfigOption optVideoMode = ConfigOptions[ "Video Mode" ];
ConfigOption optColorDepth = ConfigOptions[ "Color Depth" ];
ConfigOption optDisplayFrequency = ConfigOptions[ "Display Frequency" ];
ConfigOption optFullScreen = ConfigOptions[ "Full Screen" ];
string val = optVideoMode.Value;
int pos = val.IndexOf( 'x' );
if ( pos == -1 )
throw new Exception( "Invalid Video Mode provided" );
int width = Int32.Parse( val.Substring( 0, pos ) );
int height = Int32.Parse( val.Substring( pos + 1 ) );
DisplayDevice dev = DisplayDevice.Default;
optColorDepth.PossibleValues.Clear();
for ( int q = 0; q < dev.AvailableResolutions.Count; q++ )
{
DisplayResolution item = dev.AvailableResolutions[ q ];
if ( item.Width == width &&
item.Height == height && item.BitsPerPixel >= 16 )
{
if ( !optColorDepth.PossibleValues.ContainsValue( item.BitsPerPixel.ToString() ) )
{
optColorDepth.PossibleValues.Add( optColorDepth.PossibleValues.Values.Count, item.BitsPerPixel.ToString() );
}
if ( !optDisplayFrequency.PossibleValues.ContainsValue( item.RefreshRate.ToString() ) )
{
optDisplayFrequency.PossibleValues.Add( optDisplayFrequency.PossibleValues.Values.Count, item.RefreshRate.ToString() );
}
}
}
if ( optFullScreen.Value == "No" )
{
optDisplayFrequency.Value = "N/A";
optDisplayFrequency.Immutable = true;
}
else
{
optDisplayFrequency.Immutable = false;
optDisplayFrequency.Value = optDisplayFrequency.PossibleValues.Values[ optDisplayFrequency.PossibleValues.Count - 1 ];
}
if ( optColorDepth.PossibleValues.Values.Count > 0 )
optColorDepth.Value = optColorDepth.PossibleValues.Values[ 0 ];
if ( optDisplayFrequency.Value != "N/A" )
optDisplayFrequency.Value = optDisplayFrequency.PossibleValues.Values[ optDisplayFrequency.PossibleValues.Count - 1 ];
}