/// <summary> /// Determines whether the file can be parsed at this time. /// </summary> /// <param name="filePath">The path to the file to be parsed.</param> /// <param name="fileCreationTime">The time the file was created.</param> /// <returns>True if the file can be parsed; false otherwise.</returns> public bool CanParse(string filePath, DateTime fileCreationTime) { try { m_parser = new LogicalParser(filePath); m_parser.Open(); return true; } catch (IOException) { return false; } }
private void PQDIFButton_Click(object sender, EventArgs e) { List<ObservationRecord> observationRecords; using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.Filter = "PQDIF Files|*.pqd|All Files|*.*"; dialog.Title = "Browse PQDIF Files"; if (dialog.ShowDialog() == DialogResult.Cancel) return; if (!File.Exists(dialog.FileName)) return; // Parse PQDif File Data using (LogicalParser logicalParser = new LogicalParser(dialog.FileName)) { observationRecords = new List<ObservationRecord>(); logicalParser.Open(); while (logicalParser.HasNextObservationRecord()) observationRecords.Add(logicalParser.NextObservationRecord()); } // Convert to common channel format m_channels = observationRecords .SelectMany(observation => observation.ChannelInstances) .Where(channel => channel.Definition.QuantityTypeID == QuantityType.WaveForm) .Select(MakeParsedChannel) .ToList(); // Clear the list box and data chart ChannelListBox.Items.Clear(); DataChart.Series.Clear(); // Populate the list box with channel names ChannelListBox.Items.AddRange(m_channels .Select((channel, index) => string.Format("[{0}] {1}", index, channel.Name)) .Cast<object>() .ToArray()); // Select the first channel in the list ChannelListBox.SelectedIndex = 0; // Change the title text of the window to show what file the user has open m_fileName = dialog.SafeFileName; Text = string.Format("PQDIF - [{0}]", dialog.SafeFileName); } }