private void btnABLineOk_Click(object sender, EventArgs e) { //save the ABLine mf.FileSaveABLine(); if (mf.ABLine.isABLineLoaded) { //save the ABLine mf.EnableYouTurnButtons(); } else { mf.DisableYouTurnButtons(); } //update the default mf.AB0.fieldName = mf.currentFieldDirectory; mf.AB0.heading = glm.toDegrees(mf.ABLine.abHeading); mf.AB0.X = mf.ABLine.refPoint1.easting; mf.AB0.Y = mf.ABLine.refPoint1.northing; if (mf.ABLine.tramPassEvery == 0) { mf.mc.relayData[mf.mc.rdTramLine] = 0; } Close(); }
private void btnAddAndGo_Click(object sender, EventArgs e) { if (mf.ABLine.isABLineSet) { if (tboxABLineName.Text.Length > 0) { mf.ABLine.lineArr.Add(new CABLines()); mf.ABLine.numABLines = mf.ABLine.lineArr.Count; mf.ABLine.numABLineSelected = mf.ABLine.numABLines; //index to last one. int idx = mf.ABLine.lineArr.Count - 1; mf.ABLine.lineArr[idx].heading = mf.ABLine.abHeading; //calculate the new points for the reference line and points mf.ABLine.lineArr[idx].origin.easting = mf.ABLine.refPoint1.easting; mf.ABLine.lineArr[idx].origin.northing = mf.ABLine.refPoint1.northing; //sin x cos z for endpoints, opposite for additional lines mf.ABLine.lineArr[idx].ref1.easting = mf.ABLine.lineArr[idx].origin.easting - (Math.Sin(mf.ABLine.lineArr[idx].heading) * 1600.0); mf.ABLine.lineArr[idx].ref1.northing = mf.ABLine.lineArr[idx].origin.northing - (Math.Cos(mf.ABLine.lineArr[idx].heading) * 1600.0); mf.ABLine.lineArr[idx].ref2.easting = mf.ABLine.lineArr[idx].origin.easting + (Math.Sin(mf.ABLine.lineArr[idx].heading) * 1600.0); mf.ABLine.lineArr[idx].ref2.northing = mf.ABLine.lineArr[idx].origin.northing + (Math.Cos(mf.ABLine.lineArr[idx].heading) * 1600.0); mf.ABLine.lineArr[idx].Name = tboxABLineName.Text.Trim(); mf.FileSaveABLines(); //Often only 1 ABLine so just return to field //if (mf.ABLine.numABLines == 1) mf.ABLine.abHeading = mf.ABLine.lineArr[idx].heading; mf.ABLine.refPoint1 = mf.ABLine.lineArr[idx].origin; mf.ABLine.SetABLineByHeading(); mf.EnableYouTurnButtons(); Close();//Go back with Line enabled } else { //MessageBox.Show("Currently no ABCurve name\n create ABCurve name"); var form2 = new FormTimedMessage(2000, gStr.gsNoNameEntered, gStr.gsEnterLineName); form2.Show(); } } else { //MessageBox.Show("Currently no ABCurve name\n create ABCurve name"); var form2 = new FormTimedMessage(2000, gStr.gsNoABLineActive, gStr.gsPleaseCompleteABLine); form2.Show(); } tboxABLineName.Clear(); }
private void btnABLineOk_Click(object sender, System.EventArgs e) { if (mf.curve.refList.Count < 3) { Close(); mf.btnCurve.PerformClick(); mf.curve.ResetCurveLine(); mf.DisableYouTurnButtons(); } else { mf.curve.isCurveSet = true; mf.EnableYouTurnButtons(); Close(); } }
private void btnABLineOk_Click(object sender, System.EventArgs e) { if (mf.curve.refList.Count < 3) { mf.curve.isCurveBtnOn = false; mf.btnCurve.Image = Properties.Resources.CurveOff; mf.curve.ResetCurveLine(); mf.DisableYouTurnButtons(); mf.FileSaveCurveLine(); Close(); } else { mf.curve.isCurveSet = true; mf.EnableYouTurnButtons(); mf.FileSaveCurveLine(); Close(); } }
private void btnABLineOk_Click(object sender, EventArgs e) { //save the ABLine mf.FileSaveABLine(); if (mf.ABLine.isABLineLoaded) { //save the ABLine mf.EnableYouTurnButtons(); } else { mf.DisableYouTurnButtons(); } if (mf.ABLine.tramPassEvery == 0) { mf.mc.relayData[mf.mc.rdTramLine] = 0; } Close(); }
private void btnListUse_Click(object sender, EventArgs e) { isClosing = true; mf.ABLine.moveDistance = 0; //reset to generate new reference mf.ABLine.isABValid = false; if (lvLines.SelectedItems.Count > 0) { int idx = lvLines.SelectedIndices[0]; mf.ABLine.numABLineSelected = idx + 1; mf.ABLine.abHeading = mf.ABLine.lineArr[idx].heading; mf.ABLine.refPoint1 = mf.ABLine.lineArr[idx].origin; mf.ABLine.SetABLineByHeading(); mf.EnableYouTurnButtons(); //Go back with Line enabled Close(); } //no item selected else { mf.btnABLine.Image = Properties.Resources.ABLineOff; mf.ABLine.isBtnABLineOn = false; mf.ABLine.isABLineSet = false; mf.ABLine.isABLineLoaded = false; mf.ABLine.numABLineSelected = 0; mf.DisableYouTurnButtons(); if (mf.isAutoSteerBtnOn) { mf.btnAutoSteer.PerformClick(); } if (mf.yt.isYouTurnBtnOn) { mf.btnAutoYouTurn.PerformClick(); } Close(); } }
private void btnBPoint_Click(object sender, System.EventArgs e) { mf.curve.aveLineHeading = 0; mf.curve.isOkToAddPoints = false; btnBPoint.Enabled = false; btnAPoint.Enabled = false; btnPausePlay.Enabled = false; btnCancel.Enabled = false; lvLines.Enabled = false; int cnt = mf.curve.refList.Count; if (cnt > 3) { //make sure distance isn't too big between points on Turn for (int i = 0; i < cnt - 1; i++) { int j = i + 1; //if (j == cnt) j = 0; double distance = glm.Distance(mf.curve.refList[i], mf.curve.refList[j]); if (distance > 1.2) { vec3 pointB = new vec3((mf.curve.refList[i].easting + mf.curve.refList[j].easting) / 2.0, (mf.curve.refList[i].northing + mf.curve.refList[j].northing) / 2.0, mf.curve.refList[i].heading); mf.curve.refList.Insert(j, pointB); cnt = mf.curve.refList.Count; i = -1; } } //calculate average heading of line double x = 0, y = 0; mf.curve.isCurveSet = true; foreach (var pt in mf.curve.refList) { x += Math.Cos(pt.heading); y += Math.Sin(pt.heading); } x /= mf.curve.refList.Count; y /= mf.curve.refList.Count; mf.curve.aveLineHeading = Math.Atan2(y, x); if (mf.curve.aveLineHeading < 0) { mf.curve.aveLineHeading += glm.twoPI; } //build the tail extensions mf.curve.AddFirstLastPoints(); SmoothAB(4); mf.curve.CalculateTurnHeadings(); mf.curve.isCurveSet = true; mf.EnableYouTurnButtons(); //mf.FileSaveCurveLine(); lblCurveExists.Text = gStr.gsCurveSet; ShowSavedPanel(true); btnAddAndGo.Enabled = true; btnAddToFile.Enabled = true; btnAPoint.Enabled = false; btnBPoint.Enabled = false; btnPausePlay.Enabled = false; textBox1.BackColor = Color.LightGreen; textBox1.Enabled = true; textBox1.Text = (Math.Round(glm.toDegrees(mf.curve.aveLineHeading), 1)).ToString(CultureInfo.InvariantCulture) + "\u00B0" + mf.FindDirection(mf.curve.aveLineHeading) + DateTime.Now.ToString("hh:mm:ss", CultureInfo.InvariantCulture); } else { mf.curve.isCurveSet = false; mf.curve.refList?.Clear(); lblCurveExists.Text = " > Off <"; ShowSavedPanel(true); btnNewCurve.Enabled = true; btnCancel.Enabled = true; lvLines.Enabled = true; } lvLines.SelectedItems.Clear(); }