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 BrainForm : Form { #region Initialization public BrainForm() { InitializeComponent(); TXT_Human.Focus(); } public BrainForm(string _human, string _vid, int _version) { InitializeComponent(); TXT_Human.Focus(); TXT_Human.Text = _human; TXT_ID.Text = _vid; TXT_Version.Text = _version.ToString(); } #endregion #region Search Button Clicked private void BTN_SEARCHBRAIN_Click(object sender, EventArgs e) { AutoSearchBrains _tempAutoSearch = new AutoSearchBrains(); if (_tempAutoSearch.ShowDialog() == DialogResult.OK) { string theReturnedBrain = _tempAutoSearch.GetSelectedBrainIDBack(); int theReturnedVersion = _tempAutoSearch.GetSelectedVersionBack(); if (theReturnedBrain == null || theReturnedVersion < 0) { this.DialogResult = DialogResult.None; return; } TXT_ID.Text = theReturnedBrain; TXT_Version.Text = theReturnedVersion.ToString(); this.DialogResult = DialogResult.None; } _tempAutoSearch.Dispose(); this.DialogResult = DialogResult.None; } #endregion #region Cancel Button Clicked private void BTN_CANCEL_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } #endregion #region Save Button Clicked private void BTN_SAVE_Click(object sender, EventArgs e) { if (TXT_Human.Text == "") { (new ErrorForm("Invalid Name", "Please enter a valid name for this Fusion Brain Device")).ShowDialog(); return; } if (TXT_ID.Text == "") { (new ErrorForm("Invalid Instance ID", "Please enter a valid instance ID for this Fusion Brain Device")).ShowDialog(); return; } if (TXT_Version.Text == "") { (new ErrorForm("Invalid Version Number", "Please enter a valid version for this Fusion Brain Device")).ShowDialog(); return; } this.DialogResult = DialogResult.OK; } #endregion #region Get the Info and Close public List GetTheBrainInformation() { if (TXT_Human.Text == "" || TXT_ID.Text == "" || TXT_Version.Text == "") { return null; } return new List(new string[] { TXT_Human.Text, TXT_ID.Text, TXT_Version.Text }); } #endregion #region Verify Name Field is Valid private void Leave_VerifyNameIsValid(object sender, EventArgs e) { try { TextBox _senderBox = (TextBox)sender; if (_senderBox.Text == "") { ErrorForm _tempErrorForm = new ErrorForm("Invalid 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_HELP_AUTHOR_Click(object sender, EventArgs e) { GlobalStaticClass.FireHelpEvent("Add Brain Form", "Name"); } private void BTN_HELP_VERSION_Click(object sender, EventArgs e) { GlobalStaticClass.FireHelpEvent("Add Brain Form", "VID/PID"); } } }