private void AddErrorCSVButton_Click(object sender, RoutedEventArgs e) { FilePickerDialog filePickerDialog = new FilePickerDialog(type == PlotType.bar_grouped); filePickerDialog.Owner = App.Current.MainWindow; if (filePickerDialog.ShowDialog() == true) { errorDataCSV = filePickerDialog.filepath; CSVFileTextBlock.Text = errorDataCSV; } }
private void LoadCSVSeries_Click(object sender, RoutedEventArgs e) { string plotType = ((MenuItem)e.OriginalSource).Header.ToString().ToUpperInvariant(); PlotType type = new PlotType(); switch (plotType) { case "SCATTER PLOT": type = PlotType.scatter; break; case "SIGNAL": type = PlotType.signal; break; case "BAR PLOT": type = PlotType.bar; break; case "HISTOGRAM": type = PlotType.histogram; break; case "BOX AND WHISKER": type = PlotType.box_whisker; break; case "GROUPED BAR PLOT": type = PlotType.bar_grouped; break; } SettingsDialog settingsDialog = new SettingsDialog(type); settingsDialog.Owner = App.Current.MainWindow; DrawSettings drawSettings; drawSettings = FetchSettingsFromDialog(settingsDialog, type); if (!drawSettings.valid) { return; } Dictionary <string, object> metadata = new Dictionary <string, object>(); if (type == PlotType.signal) { SignalFrequencyDialog dlg = new SignalFrequencyDialog(); dlg.Owner = App.Current.MainWindow; if (dlg.ShowDialog() != true) { //Nullable return; } double sampleRate; if (!double.TryParse(dlg.frequency, out sampleRate)) { DialogUtilities.ShowCouldNotParseNumberError("Sample Rate", dlg.frequency); return; } double xOffset; if (double.TryParse(dlg.xOffsetTextBox.Text, out xOffset)) { DialogUtilities.ShowCouldNotParseNumberError("X-Offset", dlg.xOffsetTextBox.Text); return; } metadata.Add("sampleRate", sampleRate); metadata.Add("xOffset", xOffset); } else if (type == PlotType.bar_grouped) { GroupedPlotDialog dlg = new GroupedPlotDialog(); dlg.Owner = App.Current.MainWindow; if (dlg.ShowDialog() != true) { //Nullable return; } if (dlg.groupNamesTextBox.Text != "") { metadata.Add("group_names", dlg.groupNamesTextBox.Text.Split(',')); } if (dlg.seriesNamesTextBox.Text != "") { metadata.Add("series_names", dlg.seriesNamesTextBox.Text.Split(',')); } } FilePickerDialog filePickerDialog = new FilePickerDialog(drawSettings.type == PlotType.bar_grouped); filePickerDialog.Owner = App.Current.MainWindow; try { if (filePickerDialog.ShowDialog() == true) { PlotParameters plotParams = new PlotParameters(); plotParams = (App.Current as App).AddSeriesFromCSVFile(filePickerDialog.filepath, drawSettings, metadata); if (settingsDialog.errorDataCSV != null) { ((App)App.Current).AddErrorFromCSVFile(plotParams, settingsDialog.errorDataCSV); } statusMessage.Text = $"{filePickerDialog.filepath} loaded"; } } catch { DialogUtilities.ShowGenericPlotNotAddedError(); return; } }