//Contructor for the add and edit dispatch GUI public AddEditGUI(ISimulationEnvironment env, DispatchDatabase dispatchDatabase, bool isEdit, string[] data) { //Store all incoming information to our globals _environment = env; _dispatchDatabase = dispatchDatabase; _incomingData = data; _isEdit = isEdit; //Load up the form InitializeComponent(); //If this is an edit if (isEdit) { //Prepopulate the fields in the form with information //Time of dispatch DateTime tempDateTime = DateTime.Parse(data[1]); cmbHour.SelectedIndex = (tempDateTime.Hour%12) - 1; //Round to closest 15 minute interval cmbMinute.SelectedIndex = (tempDateTime.Minute/15); //Select the right line (green or red) if (data[3].Equals("Red")) { cmbSelect.SelectedIndex = 0; } else { cmbSelect.SelectedIndex = 1; } //Select AM or PM if (tempDateTime.Hour > 11) { cmbAMPM.SelectedIndex = 1; } else { cmbAMPM.SelectedIndex = 0; } //Select custom or predefined route if (int.Parse(data[2]) == 0) { rdbDefined.Checked = false; rdbCustom.Checked = true; txtCustom.Text = data[4]; } else { rdbDefined.Checked = true; rdbCustom.Checked = false; cmbSelect.SelectedIndex = int.Parse(data[4]); } } }
//Method used to load a new database from an incoming filepath public void NewFile(string filename) { _dispatchDatabase = new DispatchDatabase(_env, filename); //If there were any problem, make our reference now null if (_dispatchDatabase.SuccessfulParse == false) { _dispatchDatabase = null; } }