public void UpdateMagnitudePhaseList(List <Tuple <double, double> > magPhaseList) { // Use a new CustomFilter then assign its frequency domain to our frequency domain CustomFilter updater = new CustomFilter(magPhaseList); this.FreqDomain = updater.FreqDomain; }
private void ImportButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = $"{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION} (*{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION})|*{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION}|{Properties.Resources.ALL_FILES} (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { try { using (StreamReader fileReader = File.OpenText(openFileDialog.FileName)) { fileReader.ReadLine(); // Skip the header row List <Tuple <double, double> > magPhaseList = new List <Tuple <double, double> >(); while (!fileReader.EndOfStream) { string[] magPhaseData = fileReader.ReadLine().Split(','); double magnitude = double.Parse(magPhaseData[0]); double phase = double.Parse(magPhaseData[1]); magPhaseList.Add(new Tuple <double, double>(magnitude, phase)); } WorkBookManager manager = WorkBookManager.Manager(); SignalsAndTransforms.Models.CustomFilter customFilter = new SignalsAndTransforms.Models.CustomFilter(magPhaseList); customFilter.Name = System.IO.Path.GetFileNameWithoutExtension(openFileDialog.FileName); customFilter.IsActive = true; FilterViewModel context = DataContext as FilterViewModel; context?.AddFilter(customFilter); } } catch (Exception ex) { Log.Warning(ex, ex.Message); // TODO warn user } } }