|
using System;
using System.Configuration;
using System.Windows.Forms;
namespace DcamScreenSaver
{
public partial class OptionsForm : Form
{
public OptionsForm()
{
InitializeComponent();
// load controls from properties
try
{
cbxScreenSaver.SelectedIndex = Math.Min( Math.Max( 0, Properties.Settings.Default.Main_ScreenSaver ), 3 );
nudHours.Value = Math.Min( Math.Max( 0, Properties.Settings.Default.Main_BlackAfterHH ), 23 );
nudMinutes.Value = Math.Min( Math.Max( 0, Properties.Settings.Default.Main_BlackAfterMM ), 59 );
nudSeconds.Value = Math.Min( Math.Max( 0, Properties.Settings.Default.Main_BlackAfterSS ), 59 );
cbxWormType.SelectedIndex = Math.Min( Math.Max( 0, Properties.Settings.Default.Worms_WormType ), 3 );
nudNumWorms.Value = Math.Min( Math.Max( 1, Properties.Settings.Default.Worms_NumWorms ), 200 );
cbxStartPosType.SelectedIndex = Math.Min( Math.Max( 0, Properties.Settings.Default.Worms_StartPosType ), 10 );
nudNumPacman.Value = Math.Min( Math.Max( 1, Properties.Settings.Default.Pacman_NumPacman ), 200 );
nudMazeCellSize.Value = Math.Min( Math.Max( 10, Properties.Settings.Default.Maze_CellSize ), 128 );
nudMazeGenSpeed.Value = Math.Min( Math.Max( 0, Properties.Settings.Default.Maze_GenSpeed ), 5000 );
nudMazeSearchSpeed.Value = Math.Min( Math.Max( 0, Properties.Settings.Default.Maze_SearchSpeed ), 5000 );
nudMazeGenWaitAfter.Value = Math.Min( Math.Max( 500, Properties.Settings.Default.Maze_GenWaitAfter ), 5000 );
nudMazeSearchWaitAfter.Value = Math.Min( Math.Max( 500, Properties.Settings.Default.Maze_SearchWaitAfter ), 5000 );
}
catch
{
MessageBox.Show( "Problems reading the properties" );
// set defaults
cbxScreenSaver.SelectedIndex = 0;
nudHours.Value = 0;
nudMinutes.Value = 10;
nudSeconds.Value = 0;
cbxWormType.SelectedIndex = 0;
nudNumWorms.Value = 20;
cbxStartPosType.SelectedIndex = 1;
nudNumPacman.Value = 20;
nudMazeCellSize.Value = 16;
nudMazeGenSpeed.Value = 5;
nudMazeSearchSpeed.Value = 5;
nudMazeGenWaitAfter.Value = 2000;
nudMazeSearchWaitAfter.Value = 5000;
}
}
private void btnOK_Click( object sender, EventArgs e )
{
try
{
Properties.Settings.Default.Main_ScreenSaver = cbxScreenSaver.SelectedIndex;
Properties.Settings.Default.Main_BlackAfterHH = Decimal.ToInt32( nudHours.Value );
Properties.Settings.Default.Main_BlackAfterMM = Decimal.ToInt32( nudMinutes.Value );
Properties.Settings.Default.Main_BlackAfterSS = Decimal.ToInt32( nudSeconds.Value );
Properties.Settings.Default.Worms_NumWorms = Decimal.ToInt32( nudNumWorms.Value );
Properties.Settings.Default.Worms_WormType = cbxWormType.SelectedIndex;
Properties.Settings.Default.Worms_StartPosType = cbxStartPosType.SelectedIndex;
Properties.Settings.Default.Pacman_NumPacman = Decimal.ToInt32( nudNumPacman.Value );
Properties.Settings.Default.Maze_CellSize = Decimal.ToInt32( nudMazeCellSize.Value );
Properties.Settings.Default.Maze_GenSpeed = Decimal.ToInt32( nudMazeGenSpeed.Value );
Properties.Settings.Default.Maze_SearchSpeed = Decimal.ToInt32( nudMazeSearchSpeed.Value );
Properties.Settings.Default.Maze_GenWaitAfter = Decimal.ToInt32( nudMazeGenWaitAfter.Value );
Properties.Settings.Default.Maze_SearchWaitAfter = Decimal.ToInt32( nudMazeSearchWaitAfter.Value );
Properties.Settings.Default.Save();
}
catch( ConfigurationException )
{
MessageBox.Show( "Problems writing the properties.", "Dcam Screensaver Options",
MessageBoxButtons.OK, MessageBoxIcon.Error );
}
finally
{
Close();
}
}
private void btnCancel_Click( object sender, EventArgs e )
{
Close();
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.