private void btnDelete_Click(object sender, EventArgs e) { btnLeftRight.Enabled = false; btnGo.Enabled = false; btnDelete.Enabled = false; nudBndOffset.Enabled = false; if (mf.bnd.bndArr.Count > mf.bnd.boundarySelected) { mf.bnd.bndArr.RemoveAt(mf.bnd.boundarySelected); mf.turn.turnArr.RemoveAt(mf.bnd.boundarySelected); mf.gf.geoFenceArr.RemoveAt(mf.bnd.boundarySelected); } mf.FileSaveBoundary(); if (mf.bnd.boundarySelected == 0) { mf.hd.headArr[0].hdLine.Clear(); mf.hd.isOn = false; mf.FileSaveHeadland(); } mf.bnd.boundarySelected = -1; Selectedreset = true; mf.fd.UpdateFieldBoundaryGUIAreas(); mf.turn.BuildTurnLines(); mf.gf.BuildGeoFenceLines(); mf.mazeGrid.BuildMazeGridArray(); UpdateChart(); }
private void btnExit_Click(object sender, EventArgs e) { mf.hd.headArr[0].hdLine?.Clear(); mf.hd.headArr[0].isDrawList?.Clear(); for (int i = 0; i < hdArr.Length; i++) { vec3 pt = new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading); mf.hd.headArr[0].hdLine.Add(pt); if (mf.gf.geoFenceArr[0].IsPointInGeoFenceArea(pt)) { mf.hd.headArr[0].isDrawList.Add(true); } else { mf.hd.headArr[0].isDrawList.Add(false); } } mf.hd.headArr[0].PreCalcHeadLines(); mf.FileSaveHeadland(); Close(); }
private void btnExit_Click(object sender, EventArgs e) { mf.hd.headArr[0].hdLine?.Clear(); //middle points for (int i = 1; i < hdArr.Length; i++) { hdArr[i - 1].heading = Math.Atan2(hdArr[i - 1].easting - hdArr[i].easting, hdArr[i - 1].northing - hdArr[i].northing); if (hdArr[i].heading < 0) { hdArr[i].heading += glm.twoPI; } if (hdArr[i].heading > glm.twoPI) { hdArr[i].heading -= glm.twoPI; } } double delta = 0; for (int i = 0; i < hdArr.Length; i++) { if (i == 0) { mf.hd.headArr[0].hdLine.Add(new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading)); continue; } delta += (hdArr[i - 1].heading - hdArr[i].heading); if (Math.Abs(delta) > 0.01) { vec3 pt = new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading); mf.hd.headArr[0].hdLine.Add(pt); delta = 0; } } //for (int i = 0; i < hdArr.Length; i++) //{ // vec3 pt = new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading); // mf.hd.headArr[0].hdLine.Add(pt); // if (mf.bnd.bndArr[0].IsPointInsideBoundaryEar(pt)) mf.hd.headArr[0].isDrawList.Add(true); // else mf.hd.headArr[0].isDrawList.Add(false); //} mf.hd.headArr[0].PreCalcHeadLines(); mf.FileSaveHeadland(); Close(); }
private void btnExit_Click(object sender, EventArgs e) { mf.bnd.bndList[0].hdLine?.Clear(); //does headland control sections mf.bnd.isSectionControlledByHeadland = cboxIsSectionControlled.Checked; Properties.Settings.Default.setHeadland_isSectionControlled = cboxIsSectionControlled.Checked; Properties.Settings.Default.Save(); //middle points for (int i = 1; i < hdArr.Length; i++) { hdArr[i - 1].heading = Math.Atan2(hdArr[i - 1].easting - hdArr[i].easting, hdArr[i - 1].northing - hdArr[i].northing); if (hdArr[i].heading < 0) { hdArr[i].heading += glm.twoPI; } if (hdArr[i].heading > glm.twoPI) { hdArr[i].heading -= glm.twoPI; } } double delta = 0; for (int i = 0; i < hdArr.Length; i++) { if (i == 0) { mf.bnd.bndList[0].hdLine.Add(new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading)); continue; } delta += (hdArr[i - 1].heading - hdArr[i].heading); if (Math.Abs(delta) > 0.01) { vec3 pt = new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading); mf.bnd.bndList[0].hdLine.Add(pt); delta = 0; } } mf.FileSaveHeadland(); isClosing = true; Close(); }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult result3 = MessageBox.Show(gStr.gsCompletelyDeleteBoundary, gStr.gsDeleteForSure, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result3 == DialogResult.Yes) { btnLeftRight.Enabled = false; btnGo.Enabled = false; btnDelete.Enabled = false; nudBndOffset.Enabled = false; if (mf.bnd.bndArr.Count > mf.bnd.boundarySelected) { mf.bnd.bndArr.RemoveAt(mf.bnd.boundarySelected); mf.turn.turnArr.RemoveAt(mf.bnd.boundarySelected); mf.gf.geoFenceArr.RemoveAt(mf.bnd.boundarySelected); } mf.FileSaveBoundary(); if (mf.bnd.boundarySelected == 0) { mf.hd.headArr[0].hdLine.Clear(); mf.hd.isOn = false; mf.FileSaveHeadland(); } mf.bnd.boundarySelected = -1; Selectedreset = true; mf.fd.UpdateFieldBoundaryGUIAreas(); mf.turn.BuildTurnLines(); mf.gf.BuildGeoFenceLines(); mf.mazeGrid.BuildMazeGridArray(); UpdateChart(); } else { mf.TimedMessageBox(1500, gStr.gsNothingDeleted, gStr.gsActionHasBeenCancelled); } }
private void btnExit_Click(object sender, EventArgs e) { mf.bnd.bndList[0].hdLine?.Clear(); //middle points for (int i = 1; i < hdArr.Length; i++) { hdArr[i - 1].heading = Math.Atan2(hdArr[i - 1].easting - hdArr[i].easting, hdArr[i - 1].northing - hdArr[i].northing); if (hdArr[i].heading < 0) { hdArr[i].heading += glm.twoPI; } if (hdArr[i].heading > glm.twoPI) { hdArr[i].heading -= glm.twoPI; } } double delta = 0; for (int i = 0; i < hdArr.Length; i++) { if (i == 0) { mf.bnd.bndList[0].hdLine.Add(new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading)); continue; } delta += (hdArr[i - 1].heading - hdArr[i].heading); if (Math.Abs(delta) > 0.01) { vec3 pt = new vec3(hdArr[i].easting, hdArr[i].northing, hdArr[i].heading); mf.bnd.bndList[0].hdLine.Add(pt); delta = 0; } } mf.FileSaveHeadland(); Close(); }
private void btnSave_Click(object sender, EventArgs e) { //fill something in if (String.IsNullOrEmpty(tboxFieldName.Text.Trim())) { Close(); return; } //append date time to name mf.currentFieldDirectory = tboxFieldName.Text.Trim() + " "; //task if (!String.IsNullOrEmpty(tboxTask.Text.Trim())) { mf.currentFieldDirectory += tboxTask.Text.Trim() + " "; } //vehicle if (!String.IsNullOrEmpty(tboxVehicle.Text.Trim())) { mf.currentFieldDirectory += tboxVehicle.Text.Trim() + " "; } //date mf.currentFieldDirectory += String.Format("{0}", DateTime.Now.ToString("yyyy.MMM.dd HH_mm", CultureInfo.InvariantCulture)); //get the directory and make sure it exists, create if not string dirNewField = mf.fieldsDirectory + mf.currentFieldDirectory + "\\"; mf.menustripLanguage.Enabled = false; // create from template string directoryName = Path.GetDirectoryName(dirNewField); if ((!string.IsNullOrEmpty(directoryName)) && (Directory.Exists(directoryName))) { MessageBox.Show(gStr.gsChooseADifferentName, gStr.gsDirectoryExists, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { //create the new directory if ((!string.IsNullOrEmpty(directoryName)) && (!Directory.Exists(directoryName))) { Directory.CreateDirectory(directoryName); } } string line; string offsets, convergence, startFix; using (StreamReader reader = new StreamReader(mf.fieldsDirectory + lblTemplateChosen.Text + "\\Field.txt")) { try { line = reader.ReadLine(); line = reader.ReadLine(); line = reader.ReadLine(); line = reader.ReadLine(); //read the Offsets - all we really need from template field file offsets = reader.ReadLine(); line = reader.ReadLine(); convergence = reader.ReadLine(); line = reader.ReadLine(); startFix = reader.ReadLine(); } catch (Exception ex) { mf.WriteErrorLog("While Opening Field" + ex); var form = new FormTimedMessage(2000, gStr.gsFieldFileIsCorrupt, gStr.gsChooseADifferentField); form.Show(); mf.JobClose(); return; } const string myFileName = "Field.txt"; using (StreamWriter writer = new StreamWriter(dirNewField + myFileName)) { //Write out the date writer.WriteLine(DateTime.Now.ToString("yyyy-MMMM-dd hh:mm:ss tt", CultureInfo.InvariantCulture)); writer.WriteLine("$FieldDir"); writer.WriteLine(mf.currentFieldDirectory.ToString(CultureInfo.InvariantCulture)); //write out the easting and northing Offsets writer.WriteLine("$Offsets"); writer.WriteLine(offsets); writer.WriteLine("$Convergence"); writer.WriteLine(convergence); writer.WriteLine("StartFix"); writer.WriteLine(startFix); } //create txt file copies string templateDirectoryName = (mf.fieldsDirectory + lblTemplateChosen.Text); string fileToCopy = ""; string destinationDirectory = ""; if (chkApplied.Checked) { fileToCopy = templateDirectoryName + "\\Contour.txt"; destinationDirectory = directoryName + "\\Contour.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\Sections.txt"; destinationDirectory = directoryName + "\\Sections.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } } else { //create blank Contour and Section files mf.FileCreateSections(); mf.FileCreateContour(); //mf.FileCreateElevation(); } fileToCopy = templateDirectoryName + "\\Boundary.txt"; destinationDirectory = directoryName + "\\Boundary.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } if (chkFlags.Checked) { fileToCopy = templateDirectoryName + "\\Flags.txt"; destinationDirectory = directoryName + "\\Flags.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } } else { mf.FileSaveFlags(); } if (chkGuidanceLines.Checked) { fileToCopy = templateDirectoryName + "\\ABLines.txt"; destinationDirectory = directoryName + "\\ABLines.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\RecPath.txt"; destinationDirectory = directoryName + "\\RecPath.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\CurveLines.txt"; destinationDirectory = directoryName + "\\CurveLines.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } } else { mf.FileSaveABLines(); mf.FileSaveCurveLines(); mf.FileSaveRecPath(); } if (chkHeadland.Checked) { fileToCopy = templateDirectoryName + "\\Headland.txt"; destinationDirectory = directoryName + "\\Headland.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } } else { mf.FileSaveHeadland(); } //fileToCopy = templateDirectoryName + "\\Elevation.txt"; //destinationDirectory = directoryName + "\\Elevation.txt"; //if (File.Exists(fileToCopy)) // File.Copy(fileToCopy, destinationDirectory); //now open the newly cloned field mf.FileOpenField(dirNewField + myFileName); mf.Text = "AgOpenGPS - " + mf.currentFieldDirectory; } DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { mf.FileSaveHeadland(); }
private void btnSave_Click(object sender, EventArgs e) { //fill something in if (String.IsNullOrEmpty(tboxFieldName.Text.Trim())) { Close(); return; } //append date time to name mf.currentFieldDirectory = tboxFieldName.Text.Trim() + String.Format("{0}", DateTime.Now.ToString("-yyyy.MMM.dd HH_mm", CultureInfo.InvariantCulture)); //get the directory and make sure it exists, create if not string dirNewField = mf.fieldsDirectory + mf.currentFieldDirectory + "\\"; //if no template set just make a new file. if (!isTemplateSet) { try { //start a new job mf.JobNew(); //create it for first save string directoryName = Path.GetDirectoryName(dirNewField); if ((!string.IsNullOrEmpty(directoryName)) && (Directory.Exists(directoryName))) { MessageBox.Show("Choose a different name", "Directory Exists", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { //reset the offsets mf.pn.utmEast = (int)mf.pn.actualEasting; mf.pn.utmNorth = (int)mf.pn.actualNorthing; mf.worldGrid.CreateWorldGrid(0, 0); //make sure directory exists, or create it if ((!string.IsNullOrEmpty(directoryName)) && (!Directory.Exists(directoryName))) { Directory.CreateDirectory(directoryName); } //create the field file header info mf.FileCreateField(); mf.FileCreateSections(); mf.FileCreateRecPath(); mf.FileCreateContour(); mf.FileSaveFlags(); mf.FileSaveABLine(); mf.FileSaveCurveLine(); mf.FileSaveHeadland(); } } catch (Exception ex) { mf.WriteErrorLog("Creating new field " + ex); MessageBox.Show("Error", ex.ToString()); mf.currentFieldDirectory = ""; } } else { // create from template string directoryName = Path.GetDirectoryName(dirNewField); if ((!string.IsNullOrEmpty(directoryName)) && (Directory.Exists(directoryName))) { MessageBox.Show("Choose a different name", "Directory Exists", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { //create the new directory if ((!string.IsNullOrEmpty(directoryName)) && (!Directory.Exists(directoryName))) { Directory.CreateDirectory(directoryName); } } string line; string offsets; using (StreamReader reader = new StreamReader(templateFileAndDirectory)) { try { line = reader.ReadLine(); line = reader.ReadLine(); line = reader.ReadLine(); line = reader.ReadLine(); //read the Offsets - all we really need from template field file offsets = reader.ReadLine(); } catch (Exception ex) { mf.WriteErrorLog("While Opening Field" + ex); var form = new FormTimedMessage(4000, "Field File is Corrupt", "Choose a different field"); form.Show(); mf.JobClose(); return; } const string myFileName = "Field.txt"; using (StreamWriter writer = new StreamWriter(dirNewField + myFileName)) { //Write out the date writer.WriteLine(DateTime.Now.ToString("yyyy-MMMM-dd hh:mm:ss tt", CultureInfo.InvariantCulture)); writer.WriteLine("$FieldDir"); writer.WriteLine(mf.currentFieldDirectory.ToString(CultureInfo.InvariantCulture)); //write out the easting and northing Offsets writer.WriteLine("$Offsets"); writer.WriteLine(offsets); } //create blank Contour and Section files mf.FileCreateSections(); mf.FileCreateContour(); //copy over the files from template string templateDirectoryName = Path.GetDirectoryName(templateFileAndDirectory); string fileToCopy = templateDirectoryName + "\\Boundary.txt"; string destinationDirectory = directoryName + "\\Boundary.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\Headland.txt"; destinationDirectory = directoryName + "\\Headland.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\Flags.txt"; destinationDirectory = directoryName + "\\Flags.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\ABLine.txt"; destinationDirectory = directoryName + "\\ABLine.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\RecPath.txt"; destinationDirectory = directoryName + "\\RecPath.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } fileToCopy = templateDirectoryName + "\\CurveLine.txt"; destinationDirectory = directoryName + "\\CurveLine.txt"; if (File.Exists(fileToCopy)) { File.Copy(fileToCopy, destinationDirectory); } //now open the newly cloned field mf.FileOpenField(dirNewField + myFileName); } } DialogResult = DialogResult.OK; Close(); }