using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace FCC_Uber_MDX_Configurator { public partial class TimerSetupForm : Form { #region Initializing public TimerSetupForm() { InitializeComponent(); TXT_INPUT.Text = GlobalStaticClass._GlobalTimerClass._timer_Input.ToString(); TXT_OUTPUT.Text = GlobalStaticClass._GlobalTimerClass._timer_Output.ToString(); TXT_GUI.Text = GlobalStaticClass._GlobalTimerClass._timer_GUI.ToString(); TXT_LOGIC.Text = GlobalStaticClass._GlobalTimerClass._timer_Logic.ToString(); TXT_INPUT.Focus(); } #endregion #region Verify is Valid private void Leave_VerifyTXTIsValid(object sender, EventArgs e) { try { TextBox _senderBox = (TextBox)sender; int _tempInt; if (!int.TryParse(_senderBox.Text, out _tempInt)) { ErrorForm _tempErrorForm = new ErrorForm(_senderBox.Name, "The value you entered is not valid"); _tempErrorForm.ShowDialog(); _senderBox.Focus(); } if (_tempInt < 30) { (new ErrorForm("Heavy CPU Warning [" + _senderBox.Name + "]", "By setting an interval less than 30ms, your USB bandwith will degrade quickly. It will also put a heavier strain on your CPU. Not reccommended for lower end systems", true)).ShowDialog(); } } catch (Exception) { ErrorForm _tempErrorForm = new ErrorForm("Unknown Error", "There was an unexpected untraceable error caught in the application. If you can reproduce this error, please let me know at FusionControlCentre@gmail.com"); _tempErrorForm.ShowDialog(); } } #endregion #region Verify is Number private void KeyDown_IsANumber(object sender, KeyEventArgs e) { if (!char.IsDigit((char)e.KeyValue) && e.KeyData != Keys.Back && e.KeyData != Keys.Left && e.KeyData != Keys.Right && e.KeyData != Keys.Decimal && e.KeyValue != 190 && !e.KeyCode.Equals(Keys.NumPad0) && !e.KeyCode.Equals(Keys.NumPad1) && !e.KeyCode.Equals(Keys.NumPad2) && !e.KeyCode.Equals(Keys.NumPad3) && !e.KeyCode.Equals(Keys.NumPad4) && !e.KeyCode.Equals(Keys.NumPad5) && !e.KeyCode.Equals(Keys.NumPad6) && !e.KeyCode.Equals(Keys.NumPad7) && !e.KeyCode.Equals(Keys.NumPad8) && !e.KeyCode.Equals(Keys.NumPad9)) { e.SuppressKeyPress = true; } return; } #endregion #region Cancel Button Clicked private void BTN_CANCEL_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } #endregion #region Save Button Clicked private void BTN_SAVE_Click(object sender, EventArgs e) { int _tempInput, _tempOutput, _tempGUI, _tempLogic; if (!int.TryParse(TXT_INPUT.Text, out _tempInput) || !int.TryParse(TXT_OUTPUT.Text, out _tempOutput) || !int.TryParse(TXT_GUI.Text, out _tempGUI) || !int.TryParse(TXT_LOGIC.Text, out _tempLogic)) { (new ErrorForm("Parse Error", "Unable to parse one of the timer values.")).ShowDialog(); this.DialogResult = DialogResult.None; return; } GlobalStaticClass._GlobalTimerClass._timer_Input = _tempInput; GlobalStaticClass._GlobalTimerClass._timer_Output = _tempOutput; GlobalStaticClass._GlobalTimerClass._timer_GUI = _tempGUI; GlobalStaticClass._GlobalTimerClass._timer_Logic = _tempLogic; this.DialogResult = DialogResult.OK; this.Close(); } #endregion } }