private void MoveTobutton_Click(object sender, EventArgs e) { var movedata = (string)listBox1.SelectedItem; var axisdata = movedata.Split(trimChars); if (axisdata.Length == 2) { var mx = TextConverter.SafeTextToFloat(axisdata[0].Trim(trimChars)); var my = TextConverter.SafeTextToFloat(axisdata[1].Trim(trimChars)); logger1.AddLine("Moving to: " + mx.ToString("F3") + ", " + my.ToString("F3")); USB.MoveTo(mx, my); } }
public void asyncWorkerDoWork_DrillSelected(object sender, DoWorkEventArgs doWorkEventArgs) { var loc = doWorkEventArgs.Argument as PointF? ?? PointF.Empty; USB.MoveTo(loc.X, loc.Y); var success = USB.Check_Limit_Switches(); asyncWorker.ReportProgress(50); //start drill from top if (!asyncWorker.CancellationPending) { if (success && USB.IsOpen && USB.Check_Limit_Switches()) { success = Initiate_Drill_From_Top(20, 50); } asyncWorker.ReportProgress(75); } else { doWorkEventArgs.Cancel = true; } //wait for drill to reach back top if (!asyncWorker.CancellationPending) { if (success && USB.IsOpen && USB.Check_Limit_Switches()) { success = Wait_For_Drill_To_Top(20, 50); } asyncWorker.ReportProgress(100); } else { doWorkEventArgs.Cancel = true; } doWorkEventArgs.Result = success; }