public bool Sample() { bool isNoShortCircuit; int pointNo; int circuitNo; if (!SampleCheck.BeginSampleCheck(out isNoShortCircuit, out _shortCircuitInfoResult, out pointNo, out circuitNo)) { InfoBox.ErrorMsg("取样失败,请检查设备连接"); return(false); } CircuitCount = circuitNo; PointCount = pointNo; CheckResults.Clear(); if (!isNoShortCircuit) { var id = 0; foreach (var tmpList in _shortCircuitInfoResult) { CommonCheck.OrderCheckResult(tmpList); var tmpCircuitLoop = tmpList.Aggregate("", (current, tmp) => current + (tmp + "-")); ++id; CheckResults.Add(new BindCheckResult { Id = id, CheckResult = tmpCircuitLoop.Remove(tmpCircuitLoop.Length - 1, 1) }); } } InfoBox.PlaySound(true); return(true); }
private void btnOk_Click(object sender, RoutedEventArgs e) { BtnOk.IsEnabled = false; WaitBox wb = null; var t = new Thread(() => { wb = new WaitBox(); wb.ShowDialog();//不能用Show }); t.SetApartmentState(ApartmentState.STA); t.Start(); int pointNo; int circuitNo; List <List <string> > shortCircuitInfoResult; bool isSelfCheckOk; if (!SampleCheck.BeginSampleCheck(out isSelfCheckOk, out shortCircuitInfoResult, out pointNo, out circuitNo)) { InfoBox.ErrorMsg("自检失败,请检查设备连接"); wb.Dispatcher.Invoke((Action)(() => wb.Close())); return; } if (!isSelfCheckOk) { CheckResults.Clear(); var id = 0; foreach (var tmpList in shortCircuitInfoResult) { var tmpResult = tmpList.Aggregate("", (current, tmp) => current + (tmp + "-")); ++id; CheckResults.Add(new BindCheckResult { Id = id, CheckResult = tmpResult.Remove(tmpResult.Length - 1, 1) }); } } BtnOk.IsEnabled = true; wb.Dispatcher.Invoke((Action)(() => wb.Close())); InfoBox.PlaySound(isSelfCheckOk); new ResultPopUp(isSelfCheckOk, true, true).ShowDialog(); }