protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!String.IsNullOrEmpty(Settings.Default.CalibrationFile))
            {
                try
                {
                    CalibrationFile.Read(Settings.Default.CalibrationFile, m_Servos);
                }
                catch (Exception ex)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Error: Could not read calibration data from file:");
                    stringBuilder.AppendLine(Settings.Default.CalibrationFile);
                    stringBuilder.AppendLine("Original error:");
                    stringBuilder.AppendLine(ex.Message);

                    MessageBox.Show(stringBuilder.ToString());
                }
            }

            StringCollection servoPositionStrings = Settings.Default.ServoPositions;

            if (servoPositionStrings != null && servoPositionStrings.Count != 0)
            {
                for (int i = 0; i < m_ServoControls.Count; i++)
                {
                    ServoControl servoControl  = m_ServoControls[i];
                    int          servoPosition = (int)Convert.ToInt32(servoPositionStrings[i], CultureInfo.InvariantCulture);

                    servoControl.Model.Position = servoPosition;
                }
            }
        }
        private void OnLoadCalibration(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (!String.IsNullOrEmpty(Settings.Default.CalibrationFile))
            {
                openFileDialog.InitialDirectory = Path.GetDirectoryName(Settings.Default.CalibrationFile);
            }
            //openFileDialog.InitialDirectory = "c:\\";
            openFileDialog.Filter           = "cfg files (*.cfg)|*.cfg|All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.CalibrationFile = openFileDialog.FileName;
                try
                {
                    CalibrationFile.Read(openFileDialog.FileName, m_Servos);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Exemple #3
0
        private void RestoreCalibration()
        {
            if (!String.IsNullOrEmpty(Settings.Default.CalibrationFile))
            {
                try
                {
                    CalibrationFile.Read(Settings.Default.CalibrationFile, m_Servos);
                }
                catch (Exception ex)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine("Error: Could not read calibration data from file:");
                    stringBuilder.AppendLine(Settings.Default.CalibrationFile);
                    stringBuilder.AppendLine("Original error:");
                    stringBuilder.AppendLine(ex.Message);

                    MessageBox.Show(stringBuilder.ToString());
                }
            }
        }
Exemple #4
0
        private void LoadCalibration()
        {
            Debug.WriteLine("In Load Calibration");
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "cfg files (*.cfg)|*.cfg|All files (*.*)|*.*";
            openFileDialog.FilterIndex = 1;

            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    CalibrationFile.Read(openFileDialog.FileName, m_Servos);
                    Settings.Default.CalibrationFile = openFileDialog.FileName;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }