private void btnStop_Click(object sender, EventArgs e) { if (mf.bnd.bndPts.Count > 5) { mf.bnd.bndArr.Add(new CBoundaryLines()); mf.turn.turnArr.Add(new CTurnLines()); mf.gf.geoFenceArr.Add(new CGeoFenceLines()); for (int i = 0; i < mf.bnd.bndPts.Count; i++) { mf.bnd.bndArr[mf.bnd.boundarySelected].bndLine.Add(mf.bnd.bndPts[i]); } mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].FixBoundaryLine(mf.bnd.boundarySelected, mf.vehicle.toolWidth); mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].isSet = true; mf.bnd.bndArr[mf.bnd.boundarySelected].CalculateBoundaryArea(); mf.fd.UpdateFieldBoundaryGUIAreas(); } //stop it all for adding mf.bnd.isOkToAddPoints = false; //turn lines made from boundaries mf.CalculateMinMax(); mf.FileSaveBoundary(); mf.turn.BuildTurnLines(); mf.gf.BuildGeoFenceLines(); //Task.Run(() => mf.mazeGrid.BuildMazeGridArray()); mf.mazeGrid.BuildMazeGridArray(); mf.bnd.bndPts.Clear(); //close window Close(); }
private void btnStop_Click(object sender, EventArgs e) { if (mf.bnd.bndBeingMadePts.Count > 2) { CBoundaryList New = new CBoundaryList(); for (int i = 0; i < mf.bnd.bndBeingMadePts.Count; i++) { New.fenceLine.Add(mf.bnd.bndBeingMadePts[i]); } New.CalculateFenceArea(mf.bnd.bndList.Count); New.FixFenceLine(mf.bnd.bndList.Count); mf.bnd.bndList.Add(New); mf.fd.UpdateFieldBoundaryGUIAreas(); //turn lines made from boundaries mf.CalculateMinMax(); mf.FileSaveBoundary(); mf.bnd.BuildTurnLines(); //mf.hd.BuildSingleSpaceHeadLines(); mf.btnABDraw.Visible = true; } //stop it all for adding mf.bnd.isOkToAddPoints = false; mf.bnd.isBndBeingMade = false; mf.bnd.bndBeingMadePts.Clear(); //close window isClosing = true; Close(); }
private void btnAddFence_Click(object sender, EventArgs e) { if (bingLine.Count > 2) { CBoundaryList New = new CBoundaryList(); double east, nort; for (int i = 0; i < bingLine.Count; i++) { mf.pn.ConvertWGS84ToLocal(bingLine[i].Latitude, bingLine[i].Longitude, out nort, out east); vec3 v = new vec3(east, nort, 0); New.fenceLine.Add(v); } New.CalculateFenceArea(mf.bnd.bndList.Count); New.FixFenceLine(mf.bnd.bndList.Count); mf.bnd.bndList.Add(New); mf.fd.UpdateFieldBoundaryGUIAreas(); //turn lines made from boundaries mf.CalculateMinMax(); mf.FileSaveBoundary(); mf.bnd.BuildTurnLines(); mf.btnABDraw.Visible = true; } //clean up line bingLine.Clear(); mapControl.Markers.Clear(); mapControl.Invalidate(); lblPoints.Text = bingLine.Count.ToString(); }
private void btnStop_Click(object sender, EventArgs e) { if (mf.bnd.bndBeingMadePts.Count > 2) { mf.bnd.bndArr.Add(new CBoundaryLines()); mf.turn.turnArr.Add(new CTurnLines()); for (int i = 0; i < mf.bnd.bndBeingMadePts.Count; i++) { mf.bnd.bndArr[mf.bnd.boundarySelected].bndLine.Add(mf.bnd.bndBeingMadePts[i]); } mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].FixBoundaryLine(mf.bnd.boundarySelected, mf.tool.toolWidth); mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryEarLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].isSet = true; mf.bnd.bndArr[mf.bnd.boundarySelected].CalculateBoundaryArea(); mf.fd.UpdateFieldBoundaryGUIAreas(); } //stop it all for adding mf.bnd.isOkToAddPoints = false; mf.bnd.isBndBeingMade = false; //turn lines made from boundaries mf.CalculateMinMax(); mf.FileSaveBoundary(); mf.turn.BuildTurnLines(); //mf.hd.BuildSingleSpaceHeadLines(); mf.bnd.bndBeingMadePts.Clear(); //close window Close(); }
private void btnStop_Click(object sender, EventArgs e) { if (mf.bnd.bndArr[mf.bnd.boundarySelected].bndLine.Count > 5) { mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].FixBoundaryLine(mf.bnd.boundarySelected); mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].isSet = true; } else { mf.bnd.bndArr[mf.bnd.boundarySelected].calcList.Clear(); mf.bnd.bndArr[mf.bnd.boundarySelected].bndLine.Clear(); mf.bnd.bndArr[mf.bnd.boundarySelected].area = 0; mf.bnd.bndArr[mf.bnd.boundarySelected].isSet = false; } //stop it all for adding for (int i = 0; i < FormGPS.MAXBOUNDARIES; i++) { mf.bnd.bndArr[i].isOkToAddPoints = false; } //turn lines made from boundaries mf.CalculateMinMax(); mf.FileSaveBoundary(); mf.turn.BuildTurnLines(); mf.gf.BuildGeoFenceLines(); //Task.Run(() => mf.mazeGrid.BuildMazeGridArray()); mf.mazeGrid.BuildMazeGridArray(); //close window Close(); }
public FormTouchPick(Form callingForm) { //get copy of the calling main form mf = callingForm as FormGPS; InitializeComponent(); //lblPick.Text = gStr.gsSelectALine; //nudDistance.Controls[0].Enabled = false; mf.CalculateMinMax(); }
public FormHeadland(Form callingForm) { //get copy of the calling main form mf = callingForm as FormGPS; InitializeComponent(); //lblPick.Text = gStr.gsSelectALine; this.Text = gStr.gsHeadlandForm; btnReset.Text = gStr.gsResetAll; nudDistance.Controls[0].Enabled = false; mf.CalculateMinMax(); }
private void btnStop_Click(object sender, EventArgs e) { if (mf.bnd.bndBeingMadePts.Count > 2) { mf.bnd.bndArr.Add(new CBoundaryLines()); mf.turn.turnArr.Add(new CTurnLines()); for (int i = 0; i < mf.bnd.bndBeingMadePts.Count; i++) { mf.bnd.bndArr[mf.bnd.boundarySelected].bndLine.Add(mf.bnd.bndBeingMadePts[i]); } //build the boundary, make sure is clockwise for outer counter clockwise for inner bool isCW = mf.bnd.bndArr[mf.bnd.boundarySelected].CalculateBoundaryArea(); if (mf.bnd.boundarySelected == 0 && isCW) { mf.bnd.bndArr[mf.bnd.boundarySelected].ReverseWinding(); } //inner boundaries if (mf.bnd.boundarySelected > 0 && !isCW) { mf.bnd.bndArr[mf.bnd.boundarySelected].ReverseWinding(); } mf.bnd.bndArr[mf.bnd.boundarySelected].FixBoundaryLine(mf.bnd.boundarySelected); mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryEarLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].PreCalcBoundaryLines(); mf.bnd.bndArr[mf.bnd.boundarySelected].isSet = true; mf.fd.UpdateFieldBoundaryGUIAreas(); } //stop it all for adding mf.bnd.isOkToAddPoints = false; mf.bnd.isBndBeingMade = false; //turn lines made from boundaries mf.CalculateMinMax(); mf.FileSaveBoundary(); mf.turn.BuildTurnLines(); //mf.hd.BuildSingleSpaceHeadLines(); mf.btnMakeLinesFromBoundary.Visible = true; mf.bnd.bndBeingMadePts.Clear(); //close window Close(); }
public FormABDraw(Form callingForm) { //get copy of the calling main form mf = callingForm as FormGPS; InitializeComponent(); //lblPick.Text = gStr.gsSelectALine; //label5.Text = gStr.gsToolWidth; //this.Text = gStr.gsClick2Pointsontheboundary; lblCmInch.Text = mf.unitsInCm; nudDistance.Controls[0].Enabled = false; if (!mf.isMetric) { nudDistance.Maximum = (int)(nudDistance.Maximum / 2.54M); nudDistance.Minimum = (int)(nudDistance.Minimum / 2.54M); } mf.CalculateMinMax(); }
private void LoadKMLBoundary(string filename) { string coordinates = null; int startIndex; using (System.IO.StreamReader reader = new System.IO.StreamReader(filename)) { try { while (!reader.EndOfStream) { //start to read the file string line = reader.ReadLine(); startIndex = line.IndexOf("<coordinates>"); if (startIndex != -1) { while (true) { int endIndex = line.IndexOf("</coordinates>"); if (endIndex == -1) { //just add the line if (startIndex == -1) { coordinates += line.Substring(0); } else { coordinates += line.Substring(startIndex + 13); } } else { if (startIndex == -1) { coordinates += line.Substring(0, endIndex); } else { coordinates += line.Substring(startIndex + 13, endIndex - (startIndex + 13)); } break; } line = reader.ReadLine(); line = line.Trim(); startIndex = -1; } line = coordinates; char[] delimiterChars = { ' ', '\t', '\r', '\n' }; string[] numberSets = line.Split(); //at least 3 points if (numberSets.Length > 2) { CBoundaryList New = new CBoundaryList(); foreach (string item in numberSets) { if (item.Length < 3) { continue; } string[] fix = item.Split(','); double.TryParse(fix[0], NumberStyles.Float, CultureInfo.InvariantCulture, out lonK); double.TryParse(fix[1], NumberStyles.Float, CultureInfo.InvariantCulture, out latK); mf.pn.ConvertWGS84ToLocal(latK, lonK, out northing, out easting); //add the point to boundary New.fenceLine.Add(new vec3(easting, northing, 0)); } //build the boundary, make sure is clockwise for outer counter clockwise for inner New.CalculateFenceArea(mf.bnd.bndList.Count); New.FixFenceLine(mf.bnd.bndList.Count); mf.bnd.bndList.Add(New); mf.btnABDraw.Visible = true; coordinates = ""; } else { mf.TimedMessageBox(2000, gStr.gsErrorreadingKML, gStr.gsChooseBuildDifferentone); } break; } } mf.FileSaveBoundary(); mf.bnd.BuildTurnLines(); mf.fd.UpdateFieldBoundaryGUIAreas(); mf.CalculateMinMax(); btnSave.Enabled = true; btnLoadKML.Enabled = false; } catch (Exception) { btnSave.Enabled = false; btnLoadKML.Enabled = false; return; } } mf.bnd.isOkToAddPoints = false; }
private void LoadKMLBoundary(string filename) { string coordinates = null; int startIndex; int i; using (System.IO.StreamReader reader = new System.IO.StreamReader(filename)) { i = mf.bnd.boundarySelected; try { while (!reader.EndOfStream) { //start to read the file string line = reader.ReadLine(); startIndex = line.IndexOf("<coordinates>"); if (startIndex != -1) { while (true) { int endIndex = line.IndexOf("</coordinates>"); if (endIndex == -1) { //just add the line if (startIndex == -1) { coordinates += line.Substring(0); } else { coordinates += line.Substring(startIndex + 13); } } else { if (startIndex == -1) { coordinates += line.Substring(0, endIndex); } else { coordinates += line.Substring(startIndex + 13, endIndex - (startIndex + 13)); } break; } line = reader.ReadLine(); line = line.Trim(); startIndex = -1; } line = coordinates; char[] delimiterChars = { ' ', '\t', '\r', '\n' }; string[] numberSets = line.Split(delimiterChars); //at least 3 points if (numberSets.Length > 2) { mf.bnd.bndArr.Add(new CBoundaryLines()); mf.turn.turnArr.Add(new CTurnLines()); 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); mf.pn.ConvertWGS84ToLocal(latK, lonK, out northing, out easting); //add the point to boundary vec3 bndPt = new vec3(easting, northing, 0); mf.bnd.bndArr[i].bndLine.Add(bndPt); } //build the boundary, make sure is clockwise for outer counter clockwise for inner bool isCW = mf.bnd.bndArr[i].CalculateBoundaryArea(); if (mf.bnd.boundarySelected == 0 && isCW) { mf.bnd.bndArr[i].ReverseWinding(); } //inner boundaries if (mf.bnd.boundarySelected > 0 && !isCW) { mf.bnd.bndArr[i].ReverseWinding(); } mf.bnd.bndArr[i].FixBoundaryLine(i); mf.bnd.bndArr[i].PreCalcBoundaryEarLines(); mf.bnd.bndArr[i].PreCalcBoundaryLines(); mf.bnd.bndArr[i].isSet = true; mf.fd.UpdateFieldBoundaryGUIAreas(); mf.btnMakeLinesFromBoundary.Visible = true; coordinates = ""; i++; } else { mf.TimedMessageBox(2000, gStr.gsErrorreadingKML, gStr.gsChooseBuildDifferentone); } //if (button.Name == "btnLoadBoundaryFromGE") //{ break; //} } } mf.FileSaveBoundary(); mf.turn.BuildTurnLines(); mf.fd.UpdateFieldBoundaryGUIAreas(); mf.CalculateMinMax(); btnSave.Enabled = true; btnLoadKML.Enabled = false; } catch (Exception) { btnSave.Enabled = false; btnLoadKML.Enabled = false; return; } } mf.bnd.isOkToAddPoints = false; }