/// <summary>
 /// Loads bearings from a file. The file should look like this:
 /// bearing_id,bearing
 /// with the first row being a header row, and bearing_id being 1_2, 1_3, or 2_3 for each row.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonLoadBearings_Click(object sender, EventArgs e)
 {
     try
     {
         openFileDialog1.Title = "Select Bearings File";
         if (openFileDialog1.ShowDialog() == DialogResult.OK)
         {
             using (StreamReader sr = new StreamReader(openFileDialog1.FileName))
             {
                 string   index;
                 string[] data;
                 string   line;
                 while ((line = sr.ReadLine()) != null)
                 {
                     data  = line.Split(',');
                     index = data[0].Trim();
                     if ((index == "1_2") && GeoUtilities.CheckBearing(data[1]))
                     {
                         textBoxBearing12.Text = data[1].Trim();
                     }
                     else if ((index == "1_3") && GeoUtilities.CheckBearing(data[1]))
                     {
                         textBoxBearing13.Text = data[1].Trim();
                     }
                     else if ((index == "2_3") && GeoUtilities.CheckBearing(data[1]))
                     {
                         textBoxBearing23.Text = data[1].Trim();
                     }
                 }
             }
             EnableSelectInputs();
         }
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }
Exemple #2
0
 /// <summary>
 /// Checks to see if a string is a valid bearing value.
 /// </summary>
 /// <param name="str">string to check</param>
 /// <returns>true if the string is null or can be converted to a valid bearing, false if
 /// not</returns>
 private bool CheckBearing(string str)
 {
     return(string.IsNullOrEmpty(str) || GeoUtilities.CheckBearing(str));
 }