private void BtnSave_Click(object sender, RoutedEventArgs e) { WaitBox wb = null; var t = new Thread(() => { wb = new WaitBox(); wb.ShowDialog();//不能用Show }); t.SetApartmentState(ApartmentState.STA); t.Start(); List <CircuitInfo> allCircuits; CacheGraph.GetCircuits(out allCircuits); var dbCircuits = allCircuits.Where(circuit => circuit.ParentCableId == Cable.CableId).ToList(); var curCircuits = _circuits.Select(circuit => circuit.Info).ToList(); CacheGraph.AddCircuits(curCircuits.Except(dbCircuits).ToList()); CacheGraph.DelCircuits(dbCircuits.Except(curCircuits).ToList()); List <DotInfo> alldots; CacheGraph.GetDos(out alldots); var dbDots = alldots.Where(dot => dot.ParentCableId == Cable.CableId).ToList(); var curDots = _dots.Select(dot => dot.Info).ToList(); CacheGraph.AddDots(curDots.Except(dbDots).ToList()); CacheGraph.DelDots(dbDots.Except(curDots).ToList()); CacheGraph.CacheSaveCable(); wb.Dispatcher.Invoke((Action)(() => wb.Close())); InfoBox.InfoMsg("保存成功"); }
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(); }
private void BtnStart_Click(object sender, RoutedEventArgs e) { WaitBox wb = null; var t = new Thread(() => { wb = new WaitBox(); wb.ShowDialog();//不能用Show }); t.SetApartmentState(ApartmentState.STA); t.Start(); _viewModel.Sample(); wb.Dispatcher.Invoke((Action)(() => wb.Close())); }
private void ManualCheck() { WaitBox wb = null; var t = new Thread(() => { wb = new WaitBox(); wb.ShowDialog();//不能用Show }); t.SetApartmentState(ApartmentState.STA); t.Start(); int pointNo; int circuitNo; List <string[]> shortCircuitList; List <string[]> openCircuitList; if (!SampleCheck.ManualCheck(_circuitLoop, out pointNo, out circuitNo, out shortCircuitList, out openCircuitList)) { wb.Dispatcher.Invoke((Action)(() => wb.Close())); return; } List <List <string> > shortCircuitResult; List <List <string> > openCircuitResult; CpldControl.DataParser.CommonParser.PointToCircuit(shortCircuitList, out shortCircuitResult); CpldControl.DataParser.CommonParser.PointToPair(openCircuitList, out openCircuitResult); RemoveErrorLine(); var isCheckOk = true; //0-NG, 1-OK if (!(shortCircuitList.Count == 0 && openCircuitList.Count == 0)) { isCheckOk = false; DrawErrorLines(shortCircuitResult, openCircuitResult); } string tmp; InfoBox.RichTextMsg(out tmp, isCheckOk, pointNo, circuitNo, shortCircuitResult, openCircuitList, _phyAddrMapToDot); TbInfo.Text = tmp; wb.Dispatcher.Invoke((Action)(() => wb.Close())); HandleCheckResult(isCheckOk, shortCircuitResult, openCircuitList); }
private void btnExport_Click(object sender, RoutedEventArgs e) { var sfdSaveFile = new Microsoft.Win32.SaveFileDialog { RestoreDirectory = true, DefaultExt = "xlsx", Filter = "Excel文件(*.xlsx)|*.xlsx", FileName = "*.xlsx" }; //设置保存文件的格式 if (sfdSaveFile.ShowDialog() != true) { return; } if (File.Exists(sfdSaveFile.FileName)) { var vHandle = _lopen(sfdSaveFile.FileName, OfReadwrite | OfShareDenyNone); if (vHandle == HfileError) { InfoBox.ErrorMsg("文件已打开,请关闭后导出!"); CloseHandle(vHandle); return; } CloseHandle(vHandle); File.Delete(sfdSaveFile.FileName); } WaitBox wb = null; var t = new Thread(() => { wb = new WaitBox(); wb.ShowDialog();//不能用Show }); t.SetApartmentState(ApartmentState.STA); t.Start(); InfoBox.InfoMsg(WriteExcelToFile(sfdSaveFile.FileName)?"导出成功":"导出失败"); wb.Dispatcher.Invoke((Action)(() => wb.Close())); }