コード例 #1
0
ファイル: LoadListCreator.cs プロジェクト: HPDRC/RasterTile
        /*
         * // scan data files' paths
         *      List<string> dataFilePaths = new List<string>();
         *
         *      // it's different whether to check only *.1 subdir
         *      if (!cbOnlyScan1SubDir.Checked)
         *          Helper.GetAllFilesByExt(tbInputDirPath.Text, tbInputImgExt.Text, dataFilePaths, cbAnyExtName.Checked);
         *      else
         *      {
         *          DirectoryInfo di = new DirectoryInfo(tbInputDirPath.Text);
         *          foreach (DirectoryInfo subDir in di.GetDirectories())
         *          {
         *              if (subDir.Name.EndsWith(".1"))
         *                  Helper.GetAllFilesByExt(subDir.FullName, tbInputImgExt.Text, dataFilePaths, cbAnyExtName.Checked);
         *          }
         *      }
         *
         *      // check is corresponding meta file exists
         *      if (tbInputMetaExt.Enabled == true)
         *          Helper.CheckMetaExists(dataFilePaths, tbInputImgExt.Text, tbInputMetaExt.Text);
         *
         *      // show a message
         *      ShowMessage("ScanDir: " + dataFilePaths.Count + " files in total");
         *
         *      // generate list
         *      currentSourceSet.GenerateFromFiles((ESourceFileType)cbImgType.SelectedIndex, dataFilePaths);
         *
         *      // update loadlist into ui
         *      ShowSourceSetOnUI(currentSourceSet);*/



        #region utm

        public static void CorrectLoadListsFromOldIndex(string[] loadListPaths, string pathOfOldIndex)
        {
            Helper.AsyncRun(delegate
            {
                // first, load dnsindex
                FormMain.ShowMessage("--- Loading dnsindex ---");
                Dictionary <string, OldIndexRecord> oldRecords = new Dictionary <string, OldIndexRecord>();
                DirectoryInfo rootDir = new DirectoryInfo(pathOfOldIndex);
                foreach (DirectoryInfo subDir in rootDir.GetDirectories())
                {
                    foreach (DirectoryInfo lastDir in subDir.GetDirectories())
                    {
                        if (!lastDir.Name.EndsWith(".1"))
                        {
                            continue;
                        }
                        foreach (FileInfo indexfile in lastDir.GetFiles())
                        {
                            foreach (string line in File.ReadAllLines(indexfile.FullName))
                            {
                                try
                                {
                                    OldIndexRecord rec   = new OldIndexRecord(line);
                                    oldRecords[rec.path] = rec;
                                }
                                catch (Exception) { }
                            }
                        }
                    }
                }

                // then, correct each list
                foreach (string loadListPath in loadListPaths)
                {
                    FormMain.ShowMessage("--- Processing " + loadListPath + " ---");
                    LoadList ss = new LoadList(loadListPath);
                    ss.CorrectByOldIndex(oldRecords);
                    ss.Save(loadListPath);
                }
            });
        }
コード例 #2
0
        public LoadListCollection(string[] loadListPathes)
        {
            loadLists.Clear();

            // first check all the config files
            Dictionary <string, int> outputPathList = new Dictionary <string, int>();

            foreach (string loadListPath in loadListPathes)
            {
                LoadList loadList  = new LoadList(loadListPath);
                string   outputDir = loadList.header.outputPath;

                // check if outputDir already used
                if (outputPathList.ContainsKey(outputDir))
                {
                    throw new Exception("SourceSet " + loadListPath + " want to use outputDir " + outputDir + " which is already used by another SourceSet");
                }
                outputPathList[outputDir] = 1;

                // create dir and ensure empty
                if (Directory.Exists(outputDir))
                {
                    if (DialogResult.Cancel == MessageBox.Show("OutputDir " + outputDir + " already exists, you need to either delete it or cancel the load.\r\nDelete " + outputDir + " ?", "Confirm Delete", MessageBoxButtons.OKCancel))
                    {
                        throw new Exception("Load cancelled because outputDir already exists");
                    }
                    else
                    {
                        Directory.Delete(outputDir, true);
                    }
                }
                Directory.CreateDirectory(outputDir);
                loadLists.Add(loadList);
                FormMain.ShowMessage("Prepared: " + loadListPath);
            }
        }