private void FileFormatComboBox_SelectedIndexChanged(object sender, EventArgs e) { FileTextBox.Text = ""; if (FileFormatComboBox.SelectedIndex == FileFormatComboBox.FindStringExact("CSV")) { dialogFilter = "CSV File |*.csv"; WriteHeadersCheckBox.Enabled = true; MeasurementTypeComboBox.Enabled = false; DetectorIDTextBox.Enabled = false; ItemIDTextBox.Enabled = false; } else if (FileFormatComboBox.SelectedIndex == FileFormatComboBox.FindStringExact("NCC")) { dialogFilter = "NCC File |*.ncc"; WriteHeadersCheckBox.Enabled = false; MeasurementTypeComboBox.Enabled = true; DetectorIDTextBox.Enabled = true; ItemIDTextBox.Enabled = true; } }
private void ExportButton_Click(object sender, EventArgs e) { // Validate channels List <Channel> selectedChannels = new List <Channel>(); foreach (TreeNode node in ChannelTreeView.Nodes) { if (node.Checked) { selectedChannels.Add((Channel)node.Tag); } } if (selectedChannels.Count == 0) { MessageBox.Show("No channels selected!"); return; } // Validate date range DateTime start = StartDatePicker.Value.Date + StartTimePicker.Value.TimeOfDay; DateTime end = EndDatePicker.Value.Date + EndTimePicker.Value.TimeOfDay; if (start >= end) { MessageBox.Show("Negative or 0 time range selected!"); return; } // Validate file string fileName = FileTextBox.Text; try { File.WriteAllText(fileName, ""); } catch { MessageBox.Show("Cannot write to file!"); return; } // All tests pass: let's do this System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; if (FileFormatComboBox.SelectedIndex == FileFormatComboBox.FindStringExact("CSV")) { ExportCSV(fileName, selectedChannels, start, end); } else if (FileFormatComboBox.SelectedIndex == FileFormatComboBox.FindStringExact("NCC")) { ExportNCC(fileName, selectedChannels, start, end); } }
private void ExportDataDialog_Load(object sender, EventArgs e) { FileFormatComboBox.SelectedIndex = FileFormatComboBox.FindStringExact("CSV"); MeasurementTypeComboBox.SelectedIndex = MeasurementTypeComboBox.FindStringExact("Verification"); }