コード例 #1
0
 private void UpdateOutputFileName()
 {
     if (_mosaicProjectionFileProvider.FileItems != null && _mosaicProjectionFileProvider.FileItems.Length != 0)
     {
         string filename = _mosaicProjectionFileProvider.FileItems[0].MainFile.fileName;
         string fileDir;
         if (string.IsNullOrEmpty(_projectConfigDir))
         {
             fileDir = Path.GetDirectoryName(filename) + @"\Prj\";
         }
         else
         {
             fileDir = _projectConfigDir;
         }
         //if (!Directory.Exists(fileDir))
         //    Directory.CreateDirectory(fileDir);
         if (rbBlocks.Checked || _mosaicType != MosaicType.Mosaic)
         {
             txtOutDir.Text = fileDir;
             return;
         }
         string blockName = "";
         if (rbAllFile.Checked)
         {
             blockName = "GBAL";
         }
         else if (rbCenter.Checked)
         {
             blockName = "AOI";
         }
         string       satellite;
         string       sensor;;
         DateTime     datetime;
         DataIdentify dataIdentify = _mosaicProjectionFileProvider.FileItems[0].MainFile.DataIdentify;
         if (string.IsNullOrWhiteSpace(dataIdentify.Satellite) || string.IsNullOrWhiteSpace(dataIdentify.Sensor) || dataIdentify.OrbitDateTime == DateTime.MinValue)
         {
             RasterIdentify identify = new RasterIdentify(_mosaicProjectionFileProvider.FileItems[0].MainFile);
             satellite = string.IsNullOrWhiteSpace(dataIdentify.Satellite) ? identify.Satellite : dataIdentify.Satellite;
             sensor    = string.IsNullOrWhiteSpace(dataIdentify.Sensor) ? identify.Sensor : dataIdentify.Sensor;
             datetime  = identify.OrbitDateTime.TimeOfDay == TimeSpan.Zero ? dataIdentify.OrbitDateTime : identify.OrbitDateTime;
         }
         else
         {
             satellite = dataIdentify.Satellite;
             sensor    = dataIdentify.Sensor;
             datetime  = dataIdentify.OrbitDateTime;
         }
         float  resolution            = ucPrjEnvelopes1.ResolutionX;
         string outFilenameWithoutDir = PrjFileName.GetL1PrjFilenameWithOutDir(filename, satellite, sensor, datetime, _dstSpatialRef, blockName, resolution);
         string outfilename           = Path.Combine(fileDir, outFilenameWithoutDir);
         txtOutDir.Text = outfilename;
     }
 }
コード例 #2
0
        private void SetDir(TextBox txtDir)
        {
            bool isDir = true;

            if (string.IsNullOrWhiteSpace(txtDir.Text))
            {
                isDir = true;
            }
            else
            {
                isDir = PrjFileName.IsDir(txtDir.Text);
            }
            if (isDir)
            {
                using (FolderBrowserDialog dlg = new FolderBrowserDialog())
                {
                    if (txtDir.Text != "")
                    {
                        dlg.SelectedPath = txtDir.Text;
                    }
                    dlg.ShowNewFolderButton = true;
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        txtDir.Text = dlg.SelectedPath;
                    }
                }
            }
            else
            {
                using (SaveFileDialog dlg = new SaveFileDialog())
                {
                    if (txtDir.Text != "")
                    {
                        dlg.FileName         = Path.GetFileName(txtDir.Text);
                        dlg.DefaultExt       = ".ldf";
                        dlg.Filter           = "局地文件(*.ldf)|*.ldf";
                        dlg.InitialDirectory = Path.GetDirectoryName(txtDir.Text);
                        dlg.RestoreDirectory = true;
                    }
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        txtDir.Text = dlg.FileName;
                    }
                }
            }
        }