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 LogicItemPropertyForm : Form { public LogicItemPropertyForm(string input_timer, int input_time) { InitializeComponent(); TXT_TIME.Text = input_time.ToString(); switch (input_timer) { case "input": //COMBO_TIMER.SelectedText = "Input Timer"; COMBO_TIMER.SelectedIndex = COMBO_TIMER.Items.IndexOf("Input Timer"); break; case "output": //COMBO_TIMER.SelectedText = "Output Timer"; COMBO_TIMER.SelectedIndex = COMBO_TIMER.Items.IndexOf("Output Timer"); break; case "gui": //COMBO_TIMER.SelectedText = "GUI Timer"; COMBO_TIMER.SelectedIndex = COMBO_TIMER.Items.IndexOf("GUI Timer"); break; case "logic": default: //COMBO_TIMER.SelectedText = "Logic Timer"; COMBO_TIMER.SelectedIndex = COMBO_TIMER.Items.IndexOf("Logic Timer"); break; } } #region Verify a Proper Item has Been Selected in Combo Box private void Leave_VerifyCOMBOIsValid(object sender, EventArgs e) { try { ComboBox _senderBox = (ComboBox)sender; if (!_senderBox.Items.Contains(_senderBox.Text)) { (new ErrorForm(_senderBox.Name, "The value you selected or entered is not valid")).ShowDialog(); _senderBox.Focus(); _senderBox.SelectedIndex = 0; } } 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 Textboxes Only get Number Inputs 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; } if (e.KeyData == Keys.Decimal || e.KeyValue == 190) { e.SuppressKeyPress = true; } return; } #endregion #region Verify a Number is entered in TextBox private void Leave_VerifyTXTIsValid(object sender, EventArgs e) { try { TextBox _senderBox = (TextBox)sender; int _tempDbl = 100; if (!int.TryParse(_senderBox.Text, out _tempDbl) || _tempDbl <= 0) { ErrorForm _tempErrorForm = new ErrorForm(_senderBox.Name, "The value you entered is not valid"); _tempErrorForm.ShowDialog(); _senderBox.Focus(); } } 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 private void BTN_CANCEL_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } private void BTN_HELP_TIMER_Click(object sender, EventArgs e) { } private void BTN_SAVE_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; } public string GetBackTheTimer() { if (COMBO_TIMER.Items.Contains(COMBO_TIMER.Text)) { switch (COMBO_TIMER.Text) { case "Input Timer": return "input"; case "Output Timer": return "output"; case "GUI Timer": return "gui"; case "Logic Timer": default: return "logic"; } } else { return null; } } public int GetBackTheDeltaTime() { int returnINT = 100; int.TryParse(TXT_TIME.Text, out returnINT); return returnINT; } } }