Пример #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 btnTemplate_Click(object sender, EventArgs e)
        {
            //create the dialog instance
            OpenFileDialog ofd = new OpenFileDialog
            {
                //the initial directory, fields, for the open dialog
                InitialDirectory = mf.fieldsDirectory,

                //When leaving dialog put windows back where it was
                RestoreDirectory = true,

                //set the filter to text files only
                Filter = "Field files (Field.txt)|Field.txt"
            };

            //was a file selected
            if (ofd.ShowDialog() == DialogResult.Cancel)
            {
                isTemplateSet = false;
                mf.TimedMessageBox(1500, "Template Cancelled", "You can still start a new field");
                return;
            }
            else
            {
                templateFileAndDirectory = ofd.FileName;
                isTemplateSet            = true;
                lblTemplateChosen.Text   = new DirectoryInfo(Path.GetDirectoryName(templateFileAndDirectory)).Name;
            }
        }
Пример #3
0
        private void btnLoadBoundaryFromGE_Click(object sender, EventArgs e)
        {
            string fileAndDirectory;
            {
                //create the dialog instance
                OpenFileDialog ofd = new OpenFileDialog
                {
                    //set the filter to text KML only
                    Filter = "KML files (*.KML)|*.KML",

                    //the initial directory, fields, for the open dialog
                    InitialDirectory = mf.fieldsDirectory + mf.currentFieldDirectory
                };

                //was a file selected
                if (ofd.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    fileAndDirectory = ofd.FileName;
                }
            }

            //start to read the file
            string line = null;
            int    index;

            using (System.IO.StreamReader reader = new System.IO.StreamReader(fileAndDirectory))
            {
                bool done = false;
                try
                {
                    while (!reader.EndOfStream && !done)
                    {
                        line  = reader.ReadLine();
                        index = line.IndexOf("coord");

                        if (index != -1)
                        {
                            line = reader.ReadLine();
                            line = line.Trim();
                            string[] numberSets = line.Split(' ');
                            done = true;

                            //at least 3 points
                            if (numberSets.Length > 2)
                            {
                                //reset boundary
                                mf.boundz.ResetBoundary();
                                foreach (var item in numberSets)
                                {
                                    string[] fix = item.Split(',');
                                    double.TryParse(fix[0], NumberStyles.Float, CultureInfo.InvariantCulture, out lonK);
                                    double.TryParse(fix[1], NumberStyles.Float, CultureInfo.InvariantCulture, out latK);
                                    DecDeg2UTM(latK, lonK);
                                    vec3 bndPt = new vec3(easting, northing, 0);

                                    //TODO - calculate heading!
                                    mf.boundz.ptList.Add(bndPt);
                                }
                                mf.boundz.CalculateBoundaryArea();
                                mf.boundz.PreCalcBoundaryLines();
                                mf.boundz.isSet = true;
                                mf.FileSaveOuterBoundary();
                                Close();
                            }
                            else
                            {
                                mf.TimedMessageBox(2000, "Error reading KML", "Choose or Build a Different one");
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    return;
                }
            }
        }