Esempio n. 1
0
 private void Comtrades2CSVsFrom(List <string> filePaths)
 {
     if (filePaths.Count() == 0)
     {
         TipNoFileToConvert();
         TipDropFilesHere();
         return;
     }
     TipConvertingNow();
     new Thread(() =>
     {
         Thread.Sleep(300);
         ParseWave parse;
         foreach (string path in filePaths)
         {
             parse = new ParseWave(path);
             if (!SaveCsvFileFrom(parse))
             {
                 TipCSVFileOpened(path);
             }
         }
         parse = null;
         TipHaveConverted();
         Thread.Sleep(1000);
         TipDropFilesHere();
         GC.Collect();
     }).Start();
 }
Esempio n. 2
0
        private bool SaveCsvFileFrom(ParseWave wave)
        {
            String csvPath = wave.FilePath + ".csv";

            CreatCSVFile(csvPath);
            FileStream fs;

            try
            {
                fs = new FileStream(csvPath, FileMode.Create, FileAccess.Write);
            }
            catch
            {
                return(false);
            }

            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);

            sw.WriteLine(MakeCSVHeaderFrom(wave.Analog));
            double deltaT = StampToValue(wave.Stamp[1]) - StampToValue(wave.Stamp[0]);

            for (int row = 0; row < wave.Stamp.Count; row++)
            {
                sw.WriteLine((deltaT * row).ToString() + MakeRowStringFrom(wave.Analog, row));
            }
            sw.Close();
            fs.Close();
            return(true);
        }