Пример #1
0
        /// <summary>Loads HALCON calibration data.</summary>
        private void LoadCamParamButton_Click(object sender, System.EventArgs e)
        {
            HTuple buttonType, valType;
            string file;
            string [] val;
            bool   isCalFile;

            StatusLabel.Text = "";
            buttonType = new HTuple(sender.ToString());
            valType = buttonType.TupleStrrstr(new HTuple("CamPar"));

            if (valType[0].I > 0)
                openCamparFileDialog.FilterIndex = 1;
            else
                openCamparFileDialog.FilterIndex = 2;

            openCamparFileDialog.FileName = "";

            if (openCamparFileDialog.ShowDialog() == DialogResult.OK)
            {
                file = openCamparFileDialog.FileName;
                StatusLabel.Text = "";

                if ((isCalFile = file.EndsWith(".cal")) || file.EndsWith(".dat"))
                {

                    try
                    {
                        if (valType[0].I > 0)
                        {
                            mAssistant.LoadCamParFile(file);
                            val = file.Split(new Char[] { '\\' });
                            file = val[val.Length - 1];
                            CalibCamTextBox.Text = file;

                        }
                        else
                        {
                            mAssistant.LoadCamPoseFile(file);
                            val = file.Split(new Char[] { '\\' });
                            file = val[val.Length - 1];
                            CalibPoseTextBox.Text = file;
                        }
                    }
                    catch (HOperatorException)
                    {
                        if (valType[0].I > 0)
                            CalibCamTextBox.Text = "*.cal";
                        else
                            CalibPoseTextBox.Text = "*.dat";

                        StatusLabel.Text = mAssistant.exceptionText;
                        valType = mAssistant.exceptionText.TupleSplit(":");
                        MessageBox.Show("File is corrupted or has a wrong format:\nPlease check if you chose a valid calibration file (or format)!",
                                         "Measure Assistant",
                                         MessageBoxButtons.OK,
                                         MessageBoxIcon.Information);

                    }

                }
                else
                {
                    MessageBox.Show("Fileformat is wrong: Data is not a calibration file!",
                                     "Measure Assistant",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Information);
                }

                if (mAssistant.mIsCalibValid)
                {
                    TransWCoordCheckBox.Enabled = true;
                }
                else
                {
                    TransWCoordCheckBox.Enabled = false;
                    TransWCoordCheckBox.Checked = false;
                }
            }
        }