示例#1
0
 private void tboxAutoSteerIP_Validating(object sender, CancelEventArgs e)
 {
     if (!CheckIPValid(tboxAutoSteerIP.Text))
     {
         tboxAutoSteerIP.Text = "127.0.0.1";
         tboxAutoSteerIP.Focus();
         mf.TimedMessageBox(3000, "Invalid IP Address", "Set to Default Local 127.0.0.1");
     }
 }
示例#2
0
        private void FormABLine_Load(object sender, EventArgs e)
        {
            //different start based on AB line already set or not
            if (mf.ABLine.isABLineSet)
            {
                //AB line is on screen and set
                btnAPoint.Enabled    = false;
                btnBPoint.Enabled    = true;
                upDnHeading          = Math.Round(glm.toDegrees(mf.ABLine.abHeading), 1);
                nudTramRepeats.Value = mf.ABLine.tramPassEvery;
                nudBasedOnPass.Value = mf.ABLine.passBasedOn;
                tboxHeading.Text     = upDnHeading.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                //no AB line
                btnAPoint.Enabled = true;
                btnBPoint.Enabled = false;
                //btnABLineOk.Enabled = false;
                upDnHeading             = Math.Round(glm.toDegrees(mf.fixHeading), 1);
                nudTramRepeats.Value    = 0;
                nudBasedOnPass.Value    = 0;
                mf.ABLine.tramPassEvery = 0;
                mf.ABLine.passBasedOn   = 0;
            }
            //make sure at least a blank AB Line file exists
            string dirABLines    = mf.ablinesDirectory;
            string directoryName = Path.GetDirectoryName(dirABLines).ToString(CultureInfo.InvariantCulture);

            if ((directoryName.Length > 0) && (!Directory.Exists(directoryName)))
            {
                Directory.CreateDirectory(directoryName);
            }
            filename = directoryName + "\\ABLines.txt";
            if (!File.Exists(filename))
            {
                using (StreamWriter writer = new StreamWriter(filename))
                {
                    writer.WriteLine("ABLine N S,0,0,0");
                    writer.WriteLine("ABLine E W,90,0,0");
                }
            }

            //get the file of previous AB Lines
            if ((directoryName.Length > 0) && (!Directory.Exists(directoryName)))
            {
                Directory.CreateDirectory(directoryName);
            }

            filename = directoryName + "\\ABLines.txt";

            if (!File.Exists(filename))
            {
                mf.TimedMessageBox(2000, "File Error", "Missing AB Line File, Critical Error");
            }
            else
            {
                using (StreamReader reader = new StreamReader(filename))
                {
                    try
                    {
                        string       line;
                        ListViewItem itm;

                        //read all the lines
                        while (!reader.EndOfStream)
                        {
                            line = reader.ReadLine();
                            string[] words = line.Split(',');
                            //listboxLines.Items.Add(line);
                            itm = new ListViewItem(words);
                            lvLines.Items.Add(itm);

                            //coords.easting = double.Parse(words[0], CultureInfo.InvariantCulture);
                            //coords.northing = double.Parse(words[1], CultureInfo.InvariantCulture);
                            //youFileList.Add(coords);
                        }
                    }
                    catch (Exception er)
                    {
                        var form = new FormTimedMessage(4000, "ABLine File is Corrupt", "Please delete it!!!");
                        form.Show();
                        mf.WriteErrorLog("FieldOpen, Loading ABLine, Corrupt ABLine File" + er);
                    }
                }

                // go to bottom of list - if there is a bottom
                if (lvLines.Items.Count > 0)
                {
                    lvLines.Items[lvLines.Items.Count - 1].EnsureVisible();
                }
            }
        }