Exemplo n.º 1
0
        void ReleaseDesignerOutlets()
        {
            if (ConversionStatus != null)
            {
                ConversionStatus.Dispose();
                ConversionStatus = null;
            }

            if (ConversionProgress != null)
            {
                ConversionProgress.Dispose();
                ConversionProgress = null;
            }

            if (FileToConvert != null)
            {
                FileToConvert.Dispose();
                FileToConvert = null;
            }

            if (ConvertButton != null)
            {
                ConvertButton.Dispose();
                ConvertButton = null;
            }

            if (OpenButton != null)
            {
                OpenButton.Dispose();
                OpenButton = null;
            }
        }
Exemplo n.º 2
0
        private void ConvertButton_Click(object sender, EventArgs e)
        {
            //validate output scale settings
            double scaleFactor;
            bool   isValidScaleFactor = double.TryParse(OutputScaleFactorText.Text, out scaleFactor);

            if (isValidScaleFactor == false)
            {
                printNotification("Bad scale factor.", Color.Red);
                return;                //do not proceed with conversion
            }

            //store conversion values (in case user changes them during conversion)
            conversionFilesConverted            = 0;
            conversionSkipAlreadyConvertedFiles = InputSkipConvertedCheck.Checked;
            conversionOutputDataType            = (OutputDataTypeCombo.SelectedIndex == 0) ? DataType.GDT_UInt16 : DataType.GDT_Float32;
            conversionOutputScaleFactor         = scaleFactor;
            conversionApplyFineTuningCal        = OutputApplyFineTuneCalibrationsCheck.Checked;

            if (InputTypeRadioFolder.Checked == true)              //convert whole folder of files
            {
                processingMultipleFiles = true;
                setControlAvailabilityDuringProcessing(true);                //enable/disable appropriate interface buttons

                //get a list of all NITF files in folder
                string[] inputFiles;
                try {
                    string[] extensions = { ".ntf", ".nitf" };
                    inputFiles = Directory.GetFiles(InputFolderText.Text, "*.*").Where(f => extensions.Contains(System.IO.Path.GetExtension(f).ToLower())).ToArray();
                    printNotification(inputFiles.Length + " files found in folder.");
                } catch (Exception ex) {
                    printNotification("Bad path. Aborting.", Color.Red);
                    return;
                }

                //generate input/output file names for all files
                filesToConvert = new FileToConvert[inputFiles.Length];
                for (int i = 0; i < filesToConvert.Length; i++)
                {
                    filesToConvert[i] = new FileToConvert();
                    filesToConvert[i].NITFFilename   = inputFiles[i];
                    filesToConvert[i].IMDTarFilename = Path.GetDirectoryName(inputFiles[i]) + "\\" + Path.GetFileNameWithoutExtension(inputFiles[i]) + ".imd";                    //try IMD file first
                    if (File.Exists(filesToConvert[i].IMDTarFilename) == false)
                    {
                        filesToConvert[i].IMDTarFilename = filesToConvert[i].IMDTarFilename.Substring(0, filesToConvert[i].IMDTarFilename.Length - 4) + ".tar";                                                                            //try tar if IMD not present
                    }
                    filesToConvert[i].outputFilename = Path.GetDirectoryName(inputFiles[i]) + "\\" + Path.GetFileNameWithoutExtension(inputFiles[i]) + "_cal";
                }

                StatusBarLabel.Text = "Conversion started";

                //start conversion process
                startConvertingNextFile();
            }
            else                //convert a single file
                                //generate input/output file names for specified file
            {
                try {
                    filesToConvert    = new FileToConvert[1];
                    filesToConvert[0] = new FileToConvert();
                    filesToConvert[0].NITFFilename   = InputFileNITFText.Text;
                    filesToConvert[0].IMDTarFilename = InputFileIMDText.Text;
                    filesToConvert[0].outputFilename = Path.GetDirectoryName(InputFileNITFText.Text) + "\\" + Path.GetFileNameWithoutExtension(InputFileNITFText.Text) + "_cal";
                } catch (Exception ex) {
                    printNotification("Bad file. Aborting,", Color.Red);
                    return;                    //do not proceed with conversion
                }

                processingMultipleFiles = false;
                setControlAvailabilityDuringProcessing(true);                //enable/disable appropriate interface buttons

                StatusBarLabel.Text = "Conversion started";

                //start conversion process
                startConvertingNextFile();
            }
        }