private void menuAnalyze_Click(object sender, EventArgs e) { // Are they requesting a log? if (menuAnalyze.Text == "View Log") { // Yes. Create a form for the log LogForm form = new LogForm(); // Tell the form which device to use form.Device = _CurrentDevice; // Read in the log file StreamReader reader = File.OpenText(_LogName); form.Body = reader.ReadToEnd(); reader.Close(); // Show the log file form form.Show(); Application.DoEvents(); return; } /* This feature will examine the NMEA data from a device and * report on what features it supports. */ menuAnalyze.Enabled = false; tabControl1.SelectedIndex = 1; // Show a busy cursor until analysis completes Cursor.Current = Cursors.WaitCursor; Application.DoEvents(); // Test the device _Analysis = _CurrentDevice.Test(); // Write the analysis to a log file StreamWriter writer = new StreamWriter(_LogName); writer.Write(_Analysis.Log); writer.Close(); // Show supported sentences foreach (string sentence in _Analysis.SupportedSentences) { sentenceListBox.Items.Add(sentence); } // Set images based on supported features if (_Analysis.IsPositionSupported) { pictureBoxPosition.Image = imageList1.Images[0]; } else { pictureBoxPosition.Image = imageList1.Images[1]; } if (_Analysis.IsAltitudeSupported) { pictureBoxAltitude.Image = imageList1.Images[0]; } else { pictureBoxAltitude.Image = imageList1.Images[1]; } if (_Analysis.IsBearingSupported) { pictureBoxBearing.Image = imageList1.Images[0]; } else { pictureBoxBearing.Image = imageList1.Images[1]; } if (_Analysis.IsPrecisionSupported) { pictureBoxPrecision.Image = imageList1.Images[0]; } else { pictureBoxPrecision.Image = imageList1.Images[1]; } if (_Analysis.IsSpeedSupported) { pictureBoxSpeed.Image = imageList1.Images[0]; } else { pictureBoxSpeed.Image = imageList1.Images[1]; } if (_Analysis.IsSatellitesSupported) { pictureBoxSatellites.Image = imageList1.Images[0]; } else { pictureBoxSatellites.Image = imageList1.Images[1]; } // change "Analyze" to "View Log" menuAnalyze.Text = "View Log"; // Re-enable the menu menuAnalyze.Enabled = true; // Restore the cursor Cursor.Current = Cursors.Default; // Let them know which features are supported by their device if (_Analysis.IsWorkingProperly) { MessageBox.Show(_CurrentDevice.Name + " fully supports all real-time GPS data.", "No Problems", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } else { MessageBox.Show(_CurrentDevice.Name + " does not appear to fully support real-time GPS data. Try another analysis. If the same problem persists, some NMEA sentences may need to be activated on the device.", "Problems Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }
private void menuAnalyze_Click(object sender, EventArgs e) { // Are they requesting a log? if (menuAnalyze.Text == "View Log") { // Yes. Create a form for the log LogForm form = new LogForm(); // Tell the form which device to use form.Device = _CurrentDevice; // Read in the log file StreamReader reader = File.OpenText(_LogName); form.Body = reader.ReadToEnd(); reader.Close(); // Show the log file form form.Show(); Application.DoEvents(); return; } /* This feature will examine the NMEA data from a device and * report on what features it supports. */ menuAnalyze.Enabled = false; tabControl1.SelectedIndex = 1; // Show a busy cursor until analysis completes Cursor.Current = Cursors.WaitCursor; Application.DoEvents(); // Test the device _Analysis = _CurrentDevice.Test(); // Write the analysis to a log file StreamWriter writer = new StreamWriter(_LogName); writer.Write(_Analysis.Log); writer.Close(); // Show supported sentences foreach (string sentence in _Analysis.SupportedSentences) sentenceListBox.Items.Add(sentence); // Set images based on supported features if (_Analysis.IsPositionSupported) pictureBoxPosition.Image = imageList1.Images[0]; else pictureBoxPosition.Image = imageList1.Images[1]; if (_Analysis.IsAltitudeSupported) pictureBoxAltitude.Image = imageList1.Images[0]; else pictureBoxAltitude.Image = imageList1.Images[1]; if (_Analysis.IsBearingSupported) pictureBoxBearing.Image = imageList1.Images[0]; else pictureBoxBearing.Image = imageList1.Images[1]; if (_Analysis.IsPrecisionSupported) pictureBoxPrecision.Image = imageList1.Images[0]; else pictureBoxPrecision.Image = imageList1.Images[1]; if (_Analysis.IsSpeedSupported) pictureBoxSpeed.Image = imageList1.Images[0]; else pictureBoxSpeed.Image = imageList1.Images[1]; if (_Analysis.IsSatellitesSupported) pictureBoxSatellites.Image = imageList1.Images[0]; else pictureBoxSatellites.Image = imageList1.Images[1]; // change "Analyze" to "View Log" menuAnalyze.Text = "View Log"; // Re-enable the menu menuAnalyze.Enabled = true; // Restore the cursor Cursor.Current = Cursors.Default; // Let them know which features are supported by their device if (_Analysis.IsWorkingProperly) MessageBox.Show(_CurrentDevice.Name + " fully supports all real-time GPS data.", "No Problems", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); else MessageBox.Show(_CurrentDevice.Name + " does not appear to fully support real-time GPS data. Try another analysis. If the same problem persists, some NMEA sentences may need to be activated on the device.", "Problems Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); }