示例#1
0
        //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 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);
        }
示例#3
0
        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);
            }
        }