public VerificationForm(Form1 mainForm, string[] selectedFiles, RangeHz[] userSelectedRanges, double discretization)
 {
     InitializeComponent();
     this.selectedFiles    = selectedFiles;
     this.mainForm         = mainForm;
     this.simplifiedRanges = FTCoumputer.CollapseRangesHzIntersections(userSelectedRanges);
     this.discretization   = discretization;
 }
Exemple #2
0
        private FTCoumputer.Result Compute(VerificationForm f, FTCoumputer c, string file, double discretization, RangeHz[] ranges)
        {
            List <string> lines;

            try {
                lines = new List <string>(File.ReadAllLines(file));
                lines = lines.FindAll((el) =>
                {
                    return(!string.IsNullOrWhiteSpace(el));
                });
            }
            catch
            {
                //WriteFileStatusToVerificationForm(file, "Не удалось открыть");
                //return  null;
                throw new FileComputeError(file, FileComputeError.Error.FAILED_TO_OPEN);
            }
            double[] data = new double[lines.Count];
            int      i    = 0;

            char sep = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);

            foreach (var el in lines)
            {
                var eldot = el.Replace('.', sep);

                if (!double.TryParse(el.Replace(',', sep), out data[i]))
                {
                    if (!double.TryParse(el.Replace('.', sep), out data[i]))
                    {
                        //WriteFileStatusToVerificationForm(file, "Не верный формат файла");
                        //return null;
                        throw new FileComputeError(file, FileComputeError.Error.INVALID_FORMAT);
                    }
                }
                i++;
            }
            var res = c.Compute(data, discretization, ranges);

            WriteFileStatusToVerificationForm(file, "Обработан");
            return(res);
        }