private void generate_btn_Click(object sender, EventArgs e) { /* * AddDevice_RxR_GUI( * char* inputPath, * * char* d_name, * char* d_padNames, * int d_N_rows, * int* d_N_pads, double* d_padX, double* d_padY, double* d_padSpace, //length N_rows * double* d_horizontalOffset, double* d_verticalOffset, //length N_rows - 1 * * char* outputPath * ) */ int initialNumDevices = ELM_GUI.CurrentSession.currentDeviceNameList.Length; int[] Npads = ELM_GUI.textBoxToIntArray(Npads_tb); double[] padX = ELM_GUI.textBoxToDoubleArray(padX_tb); double[] padY = ELM_GUI.textBoxToDoubleArray(padY_tb); double[] padSpace = ELM_GUI.textBoxToDoubleArray(padSpace_tb); int N_rows = (int)N_rows_nud.Value; double[] offsetX = ELM_GUI.textBoxToDoubleArray(offsetX_tb); double[] offsetY = ELM_GUI.textBoxToDoubleArray(offsetY_tb); //Check vector inputs. //First: Are we able to attain enough, meaningful, information from each textbox. //That means actual numbers must be entered in. //Yes. If legitimate values are put in, even for the edge cases, the program works. //What protects us from accessing junk information in the "undersized" double[] vectors //is d_N_rows. It defines a universal length vector for everything. Then on the C++ level //we intentionally block ourselves from that junk information by a simple counter. //Second: Does valid input data hurt if we only have 1 or two rows. //No.... see above. //Stop program operation in this line if any inputs are invalid. //If you have a textBoxToArray call that gives you the [-1......] vector, AND that data is actuallly going //to be something that C++ tries to read from, then you need to stop operation here. //is not readonly and saying "N/A", that's how you know that this textbox has some invalid data. Or, rather, //needs data input into it. if (stop_program(Npads, padX, padY, padSpace, offsetX, offsetY) != 0) { MessageBox.Show("One or more input boxes on this page are lacking sufficient information."); } else { IntPtr newDeviceList_IntPtr = ELM_GUI.AddDevice_RxR_GUI( ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.inputPath), //char[] inputPath ELM_GUI.stringToCharArray(newDeviceName_tb.Text), //char[] d_name ELM_GUI.stringArrayToCharArray(ELM_GUI.textBoxToPadNamesList(newDeviceName_tb, calc_RxR_numPads())), //char[] padNames N_rows, //int d_N_rows Npads, padX, padY, padSpace, //d_N_pads, d_padX, d_padY, d_padSpace offsetX, offsetY, //d_horizontalOffset, d_verticalOffset ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.outputPath) //char[] outputPath ); ELM_GUI.postDeviceAdd(newDeviceList_IntPtr, initialNumDevices); foreach (string x in ELM_GUI.CurrentSession.currentDeviceNameList) { Debug.WriteLine(x); } Debug.WriteLine("New num devices: " + ELM_GUI.CurrentSession.currentDeviceNameList.Length + "\nOld num devices: " + initialNumDevices); } }