private void noCenterPad_rb_CheckedChanged(object sender, EventArgs e) { if (noCenterPad_rb.Checked == true) { ELM_GUI.disableTB(centeredPadX_tb); } }
private void any_tb_TextChanged(object sender, EventArgs e) { if (TB_MASTER_CONTROL == false) { if (N_rows_nud.Value == 1) { //Clean values. ELM_GUI.cleanIntInput(Npads_tb); ELM_GUI.cleanDoubleInput(padX_tb); ELM_GUI.cleanDoubleInput(padY_tb); ELM_GUI.cleanDoubleInput(padSpace_tb); ELM_GUI.disableTB(offsetX_tb); ELM_GUI.disableTB(offsetY_tb); } if (N_rows_nud.Value == 2) { //ELM_GUI.enableTB(offsetX_tb); //ELM_GUI.enableTB(offsetY_tb); ELM_GUI.cleanDoubleInput(offsetX_tb); ELM_GUI.cleanDoubleInput(offsetY_tb); //setAllTextBoxesForTwoRow(); } //else //{ // setAllTextBoxesForInput(); //} } }
//Execute. private void generateDevice_btn_Click(object sender, EventArgs e) { //Generate the arguments to put into the Pinvoke. int N = Convert.ToInt32(N_tb.Text); char[] padNames = ELM_GUI.stringArrayToCharArray( ELM_GUI.textBoxToPadNamesList(padNames_tb, 2 * N)); double[] meas = new double[] { Convert.ToDouble(space_x_tb.Text), Convert.ToDouble(space_y_tb.Text), Convert.ToDouble(dim_x_tb.Text), Convert.ToDouble(dim_y_tb.Text) }; convertUnitToMM(meas); double space_x = meas[0]; double space_y = meas[1]; double dim_x = meas[2]; double dim_y = meas[3]; int initialNumDevices = ELM_GUI.CurrentSession.currentDeviceNameList.Length; //Call the Pinvoke. IntPtr newDeviceList_IntPtr = ELM_GUI.AddDevice_2xN_GUI( ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.inputPath), ELM_GUI.stringToCharArray(newDeviceName_tb.Text), padNames, space_x, space_y, dim_x, dim_y, N, ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.outputPath) ); ELM_GUI.postDeviceAdd(newDeviceList_IntPtr, initialNumDevices); //Push form to back. SendToBack(); Visible = false; }
private void RemoveDevicesUC_Remove_btn_Click(object sender, EventArgs e) { //Do all the calls for removing selected devices based on selected items in DeviceList_lbl. //DeviceList_lb.SelectedItems //GetCurrentDeviceNameList_GUI(char[] path); //Calculate namesToRemove. ListBox.SelectedObjectCollection selectedNames = DeviceList_lb.SelectedItems; //foreach (string x in selectedNames) //{ // MessageBox.Show(x); //} string[] namesToRemove = SOCtoStringArray(selectedNames); string namesToRemoveString = ELM_GUI.stringArrayToString(namesToRemove); //Calculate output path. string outputPath = "C:\\Users\\Mehdy Faik\\AppData\\Roaming\\SPB_16.6\\eagle\\Library_Holder\\General_Passives_Test1.lbr"; //Call. IntPtr val_PTR = ELM_GUI.RemoveDevices_GUI(ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.inputPath), ELM_GUI.stringToCharArray(namesToRemoveString), ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.outputPath) ); //Interpret. ELM_GUI.CurrentSession.ProcessIntPtrToStringArray(val_PTR); //Update namelist in device box. updateDeviceList(); }
private void noCornerPad_rb_CheckedChanged(object sender, EventArgs e) { if (noCornerPad_rb.Checked == true) { ELM_GUI.disableTB(ccp_dim_tb); ELM_GUI.disableTB(ccp_ref_tb); } }
/* * private bool valid_input; * private bool valid_vector_inputs() * { * //Checks for valid vecotr inputs across entire panel. * * * return false; * } * * private Regex generateRegexIntArray(int N) * { * string s = @"^\["; * for (int n = 0; n < N; n++) * s += @"\d+" + ","; * s = s.Remove(s.Length - 1); * s += @"\]$"; * return new Regex(s); * } * public bool isIntVectorValid_TB(TextBox tb) * { * Regex regex_intArray = generateRegexIntArray((int)(N_rows_nud.Value)); * return regex_intArray.IsMatch(tb.Text); * } * public bool isDoubleVectorValid_TB(TextBox tb) * { * Regex regex_doubleArray = generateRegexDoubleArray((int)(N_rows_nud.Value)); * return regex_doubleArray.IsMatch(tb.Text); * } */ //Vector valid inputs check. /* * bool vecdata_isvalid; * bool validate_textboxes() * { * //This function automatically: * //Cleans double and int inputs when vectors have been turned into them. * //Checks vector inputs where appropriate and returns a bool to tell whether they are all well. * //Yeah so this basically just cleans up the whole picture doesn't it. * //if there's an int to be entered it cleans it. * //if there's a double to be entered it cleans it. * //this saves me from typing the if structure into every single event handler. * //stead i just have one fn to call. * * //DO THESE TEXTBOXES HOLD VALID DATA. * //YES OR NO. * * int[] t_i = new int[(int)(N_rows_nud.Value)]; * double[] t_d = new double[(int)(N_rows_nud.Value)]; * * ELM_GUI.cleanTextInput(newDeviceName_tb); * * if ((int)N_rows_nud.Value == 1) * { * //If it says "N/A" in there, that's ok IF the box is also readonly. Becuase the user might set it to * //N/A but he'll never set it to readonly. GOOD. * * //LEFT FOUR are checked by being valid ints. * ELM_GUI.cleanIntInput(Npads_tb); * ELM_GUI.cleanDoubleInput(padX_tb); * ELM_GUI.cleanDoubleInput(padY_tb); * ELM_GUI.cleanDoubleInput(padSpace_tb); * * //RIGHT TWO are checked by holding "N/A" and being READONLY. * //If I want them to hold N/A and be READONLY, this would be the time to set it anyway. * ELM_GUI.disableTB(offsetX_tb); * ELM_GUI.disableTB(offsetY_tb); * } * else if ((int)N_rows_nud.Value == 2) * { * * //LEFT FOUR are checked by being vectors * t_i = ELM_GUI.textBoxToIntArray(Npads_tb); * if (t_i[0] == -1) return false; * t_d = ELM_GUI.textBoxToDoubleArray(padX_tb); * if (t_d[0] == -1) return false; * t_d = ELM_GUI.textBoxToDoubleArray(padY_tb); * if (t_d[0] == -1) return false; * t_d = ELM_GUI.textBoxToDoubleArray(padSpace_tb); * if (t_d[0] == -1) return false; * * //RIGHT TWO are checked as doubles. * ELM_GUI.cleanDoubleInput(offsetX_tb); * ELM_GUI.cleanDoubleInput(offsetY_tb); * } * else * { * //Check left four as vectors. * t_i = ELM_GUI.textBoxToIntArray(Npads_tb); * if (t_i[0] == -1) return false; * t_d = ELM_GUI.textBoxToDoubleArray(padX_tb); * if (t_d[0] == -1) return false; * t_d = ELM_GUI.textBoxToDoubleArray(padY_tb); * if (t_d[0] == -1) return false; * t_d = ELM_GUI.textBoxToDoubleArray(padSpace_tb); * if (t_d[0] == -1) return false; * * //Check right two as vectors. * t_d = ELM_GUI.textBoxToDoubleArray(offsetX_tb); * if (t_d[0] == -1) return false; * t_d = ELM_GUI.textBoxToDoubleArray(offsetY_tb); * if (t_d[0] == -1) return false; * } * * return true; * } */ //Misc math helper fns. public int calc_RxR_numPads() { double[] dd = ELM_GUI.textBoxToDoubleArray(Npads_tb); int totalNumPads = 0; foreach (double d in dd) { totalNumPads += (int)d; } return(totalNumPads); }
public void setAllTextBoxesForOneRow() { ELM_GUI.enableTB(Npads_tb); ELM_GUI.enableTB(padX_tb); ELM_GUI.enableTB(padY_tb); ELM_GUI.enableTB(padSpace_tb); ELM_GUI.disableTB(offsetX_tb); ELM_GUI.disableTB(offsetY_tb); Npads_tb.Text = ""; padX_tb.Text = ""; padY_tb.Text = ""; padSpace_tb.Text = ""; }
public void setAllTextBoxesForTwoRow() { ELM_GUI.enableTB(Npads_tb); ELM_GUI.enableTB(padX_tb); ELM_GUI.enableTB(padY_tb); ELM_GUI.enableTB(padSpace_tb); ELM_GUI.enableTB(offsetX_tb); ELM_GUI.enableTB(offsetY_tb); setIntTextBox(Npads_tb, (int)N_rows_nud.Value); setDoubleTextBox(padX_tb, (int)N_rows_nud.Value); setDoubleTextBox(padY_tb, (int)N_rows_nud.Value); setDoubleTextBox(padSpace_tb, (int)N_rows_nud.Value); offsetX_tb.Text = ""; offsetY_tb.Text = ""; }
//Upon OK click: private void OK_btn_Click(object sender, EventArgs e) { //If paths don't exist, re-enter. if (!File.Exists(ChooseInputFilePath_tb.Text))//) || (!File.Exists(ChooseOutputFilePath_tb.Text))) { MessageBox.Show("Path can't be found - please review your path."); } //If paths exist, get current device list. else { ELM_GUI.CurrentSession.inputPath = ChooseInputFilePath_tb.Text; ELM_GUI.CurrentSession.outputPath = ChooseOutputFilePath_tb.Text; IntPtr p = ELM_GUI.GetCurrentDeviceNameList_GUI(ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.inputPath)); ELM_GUI.CurrentSession.ProcessIntPtrToStringArray(p); MessageBox.Show("Loaded (" + ELM_GUI.CurrentSession.currentDeviceNameList.Length + ")" + " devices from:\n " + ELM_GUI.CurrentSession.inputPath); SendToBack(); Visible = false; } }
private void generateDevice_btn_Click(object sender, EventArgs e) { /* * Arguments. * char* name, * double ref, int N, double padW, double padL, double padSpace, * double centeredSquarePad, * double cornerSquarePads_REF, double cornerSquarePads_DIM * * Definition for centeredSquarePad_DIM: * <=0: None. * >0: give me a centered squared pad with the dim. * * Definition for cornerSquarePads_DIM: * <=0: None. * >0, <10000: give me those corner pads with dim and ref given. * >=10000: give me those corner pads with dim and ref equal to the lateral pads. * * As is, how many args is this. This is 8 args. * * If we used rectangular instead of square, what would we have. */ //Under "Corner Pads": //If "Copy Lateral Pads" is checked: //cornerSquarePads_REF then follows REF_tb //cornerSquarePads_DIM then follows pad length and width..... but to communicate this in one variable //I'll need to agree on a value to set cornerSquarePads_DIM to. //Process of events. //When Copy Lateral Pads is checked under Corner pads, I now have event handlers to show the //user in an accurate manner what is happening. That is a good thing. //However on the backend what i'm doing is setting d_cornerSquarePads_DIM to be over 10000. //So i need a fn for that. double d_REF = Convert.ToDouble(REF_tb.Text); int d_N = Convert.ToInt32(N_tb.Text); double d_padW = Convert.ToDouble(lateralPads_width_tb.Text); double d_padL = Convert.ToDouble(lateralPads_length_tb.Text); double d_padSpace = Convert.ToDouble(padSpace_tb.Text); double d_centeredSquarePad_DIM = centeredPadX_tb.Text == "N/A" ? -1 : Convert.ToDouble(centeredPadX_tb.Text); double d_cornerSquarePads_REF = ccp_ref_tb.Text == "N/A" ? -1 : Convert.ToDouble(ccp_ref_tb.Text); double d_cornerSquarePads_DIM = calc_cornerSquarePads_DIM(); int numPads = calc_RA_numPads(d_N, d_cornerSquarePads_DIM, d_centeredSquarePad_DIM); char[] padNames = ELM_GUI.stringArrayToCharArray(ELM_GUI.textBoxToPadNamesList(padNames_tb, numPads)); int initialNumDevices = ELM_GUI.CurrentSession.currentDeviceNameList.Length; IntPtr newDeviceList_IntPtr = ELM_GUI.AddDevice_RA_GUI( ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.inputPath), //char[] inputPath, ELM_GUI.stringToCharArray(newDeviceName_tb.Text), //char[] d_name, padNames, //char[] padNames, d_REF, d_N, d_padW, d_padL, d_padSpace, d_centeredSquarePad_DIM, d_cornerSquarePads_REF, d_cornerSquarePads_DIM, 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); }
private void newDeviceName_tb_TextChanged(object sender, EventArgs e) { ELM_GUI.cleanTextInput(newDeviceName_tb); }
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); } }