示例#1
0
        private void OnCalibrationClick(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Calibration Files|*.calib"
                                    + "|All files|*.*";
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.CheckFileExists  = true;
            openFileDialog.CheckPathExists  = true;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string calibFileName = openFileDialog.FileName;
                try {
                    MapCalibration = new MapCalibration();
                    MapCalibration.read(calibFileName);
                    redrawLines();
                    Properties.Settings.Default.LastCalibFile = calibFileName;
                    Properties.Settings.Default.Save();
                } catch (Exception ex) {
                    Utils.excMsg("Error opening file:" + NL + calibFileName, ex);
                    return;
                }
            }
        }
示例#2
0
        private void OnFormShown(object sender, EventArgs e)
        {
            // This needs to be none in Shown not Load as the sizes aren't
            // right then.
            string imageFileName = Properties.Settings.Default.LastImageFile;
            string calibFileName = Properties.Settings.Default.LastCalibFile;

            try {
                // Load last image
                if (File.Exists(imageFileName))
                {
                    resetImage(imageFileName, true);
                }
            } catch (Exception ex) {
                Utils.excMsg("Error opening last image file:" + NL
                             + imageFileName, ex);
                return;
            }
            try {
                // Load last calibration
                if (File.Exists(calibFileName))
                {
                    MapCalibration = new MapCalibration();
                    MapCalibration.read(calibFileName);
                }
            } catch (Exception ex) {
                Utils.excMsg("Error opening last calib file:" + NL
                             + calibFileName, ex);
                return;
            }
        }
示例#3
0
        private void OnOpenImageClick(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Image Files|*.png;*.bmp;*.jpg;*.jpeg;*.jpe;*.jfif;*.tif;*.tiff;*.gif"
                                    + "|JPEG|*.jpg;*.jpeg;*.jpe"
                                    + "|PNG|*.png"
                                    + "|All files|*.*";
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.CheckFileExists  = true;
            openFileDialog.CheckPathExists  = true;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = openFileDialog.FileName;
                try {
                    resetImage(fileName, true);
                    Properties.Settings.Default.LastImageFile = fileName;
                    Properties.Settings.Default.Save();
                } catch (Exception ex) {
                    Utils.excMsg("Error opening file:" + NL + fileName, ex);
                    return;
                }
                // Check if there is a calibration file with the same name
                string calibFileName = Path.ChangeExtension(fileName, ".calib");
                if (File.Exists(calibFileName))
                {
                    DialogResult res = Utils.confirmMsg(
                        "There is a calibration file with the same name." + NL
                        + "Would you like to open it also?");
                    if (res == DialogResult.Yes)
                    {
                        try {
                            MapCalibration = new MapCalibration();
                            MapCalibration.read(calibFileName);
                            redrawLines();
                            Properties.Settings.Default.LastCalibFile = calibFileName;
                            Properties.Settings.Default.Save();
                        } catch (Exception ex) {
                            Utils.excMsg("Error opening calib file:" + NL
                                         + calibFileName, ex);
                            return;
                        }
                    }
                }
            }
        }