Beispiel #1
0
        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)
            {
                btnDelete.Enabled = false;

                if (mf.bnd.bndList.Count > fenceSelected)
                {
                    mf.bnd.bndList.RemoveAt(fenceSelected);
                }
                fenceSelected = -1;

                mf.FileSaveBoundary();
                mf.fd.UpdateFieldBoundaryGUIAreas();
                mf.bnd.BuildTurnLines();
                UpdateChart();
            }
            else
            {
                mf.TimedMessageBox(1500, gStr.gsNothingDeleted, gStr.gsActionHasBeenCancelled);
            }
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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 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();
        }
Beispiel #6
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     btnLeftRight.Enabled          = false;
     btnOuter.Enabled              = false;
     btnLoadBoundaryFromGE.Enabled = false;
     btnOpenGoogleEarth.Enabled    = false;
     btnGo.Enabled              = false;
     btnDelete.Enabled          = false;
     cboxSelectBoundary.Enabled = true;
     {
         mf.bndArr[mf.bnd.boundarySelected].ResetBoundary();
         mf.FileSaveBoundary();
     }
     btnLeftRight.Image = Properties.Resources.BoundaryRight;
     UpdateChart();
 }
Beispiel #7
0
        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;
            }

            //turn lines made from boundaries
            mf.FileSaveBoundary();
            mf.turn.BuildTurnLines();

            //stop it all for adding
            for (int i = 0; i < FormGPS.MAXBOUNDARIES; i++)
            {
                mf.bnd.bndArr[i].isOkToAddPoints = false;
            }

            //close window
            Close();
        }
Beispiel #8
0
        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();
        }
Beispiel #9
0
        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.vehicle.toolWidth);
                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();
        }
Beispiel #10
0
        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 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();
        }
Beispiel #12
0
        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;
        }
Beispiel #13
0
        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;
        }