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 COM_Setup_ExecutableForm : Form { public GlobalStaticClass.COM_Execution_Object_Class _com = new GlobalStaticClass.COM_Execution_Object_Class(); public COM_Setup_ExecutableForm() { SetupForm(); } public COM_Setup_ExecutableForm(GlobalStaticClass.COM_Execution_Object_Class inputCOM) { _com.Copy(inputCOM); SetupForm(); TXT_ID.Text = _com.id; } private void SetupForm() { InitializeComponent(); DisplayData(); } private void DisplayData() { LISTVIEW_COMMANDS.Items.Clear(); BTN_DELETE_COMMAND.Enabled = false; BTN_EDIT_COMMAND.Enabled = false; foreach (GlobalStaticClass.COM_Execution_Object_Class.COM_Execution_Object_Command_IDs_Class _cOC in _com.COM_Commands) { BTN_DELETE_COMMAND.Enabled = true; BTN_EDIT_COMMAND.Enabled = true; string _newItem = _cOC.internal_Command + " = " + _cOC.external_Command + "("; int i = 0; foreach (GlobalStaticClass.COM_Execution_Object_Class.COM_External_Executable_Parameter_Class _p in _cOC.external_Command_Parameters) { _newItem += _p._param; i++; if (i < _cOC.external_Command_Parameters.Count) { _newItem += ", "; } } _newItem += ")"; LISTVIEW_COMMANDS.Items.Add(_newItem); } } private void BTN_SAVE_Click(object sender, EventArgs e) { if (TXT_ID.Text == "") { (new ErrorForm("Invalid ID", "Enter an ID for this Command")).ShowDialog(); return; } else { _com.id = TXT_ID.Text; } int _currentIndex = -1; for (int i = 0; i < GlobalStaticClass.COM_List_of_Executable_Commands.Count; i++) { if (GlobalStaticClass.COM_List_of_Executable_Commands[i].id.ToLower() == _com.id.ToLower()) { _currentIndex = i; break; } } if (_currentIndex < 0) { GlobalStaticClass.COM_List_of_Executable_Commands.Add(_com); } else { GlobalStaticClass.COM_List_of_Executable_Commands[_currentIndex] = _com; } this.DialogResult = DialogResult.OK; } private void BTN_ADD_COMMAND_Click(object sender, EventArgs e) { COM_Setup_Executable_CommandForm _blah = new COM_Setup_Executable_CommandForm(ref _com); _blah.ShowDialog(); DisplayData(); this.DialogResult = DialogResult.None; } private void BTN_EDIT_COMMAND_Click(object sender, EventArgs e) { if (LISTVIEW_COMMANDS.SelectedIndex < _com.COM_Commands.Count) { COM_Setup_Executable_CommandForm _csif = new COM_Setup_Executable_CommandForm(ref _com, _com.COM_Commands[LISTVIEW_COMMANDS.SelectedIndex]); _csif.ShowDialog(); _csif.Close(); } this.DialogResult = DialogResult.None; DisplayData(); } private void BTN_DELETE_COMMAND_Click(object sender, EventArgs e) { if (LISTVIEW_COMMANDS.SelectedIndex < _com.COM_Commands.Count) { _com.COM_Commands.RemoveAt(LISTVIEW_COMMANDS.SelectedIndex); } this.DialogResult = DialogResult.None; DisplayData(); } } }