public ProceStateViewModel(WindowProceState _window) { window = _window; num = StoreInfoModel.MaterialInfo.GetMaterialDetail.PartQuantity; CompleteCommand = new DelegateCommand(obj => Complete(obj)); StopCommand = new DelegateCommand(obj => Stop(obj)); CancelCommand = new DelegateCommand(obj => Cancel(obj)); UpNumCommand = new DelegateCommand(obj => UpNum(obj)); DownNumCommand = new DelegateCommand(obj => DownNum(obj)); RdbChangeCommand = new DelegateCommand(obj => RdbChange(obj)); window.btnCancel.Focus(); }
//梦想CAD控件操作 public void MxDrawOperate(object obj) { //https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.input.key?view=netframework-4.5 switch (obj) { case Key.Enter: //弹出扫码界面 //WindowMaterialScan windowA = new WindowMaterialScan(); //windowA.ShowDialog(); WindowHelper.MaterialScanWindow = new WindowMaterialScan(); WindowHelper.MaterialScanWindow.ShowDialog(); new SerialPortScanCode().Start(); WindowHelper.IsOpenMaterialScanWindow = false; //重加载物料数据 new MaterialInfoBLL().GetMaterialDetail(); Maintains = ConvertCommon.ToObservable(GetMaintainData()); if (Maintains.Count > 0) { SelectMaintainIndex = 0; } if ((WindowHelper.MaterialScanWindow as WindowMaterialScan).OperateType.Equals(0)) { //不操作 } else { //弹出选择 完工/暂停/取消 窗口 WindowProceState windowB = new WindowProceState(); windowB.ShowDialog(); //完工 if (windowB.SelectState.Equals(0)) { ResultModel resultA = ProduceProceInfoBLL.IsLastProcess(); if (resultA.Result) { //是最后一道工序 if (Convert.ToBoolean(resultA.Data)) { //判断物料是否扫码完成 bool isComplete = true; foreach (var item in Maintains) { if (!item.PartQuantity.Equals(item.PartAlreadyScanQuantity)) { isComplete = false; break; } } if (!isComplete) { MessageBox.Show(@"物料未扫完,禁止完工!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } else { //提示打码 MessageBoxResult boxResult = MessageBox.Show("是否打码?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (boxResult == MessageBoxResult.OK) { //获取条码 ResultModel resultE = ProduceProceInfoBLL.GenerateBarCode(StoreInfoModel.MaterialInfo.GetProcessBom.InventoryCode); if (resultE.Result) { int PointX = -25; //起始点X坐标 int PointY = 0; //起始点Y坐标 //string PrintName = "Honeywell PC42t (203 dpi) - DP";//打印机名称 string PrintName = ConfigInfoModel.PrintMachineName; //打印机名称 string ContractName = StoreInfoModel.ProducePlanInfo.GetProjectProduceDetial.ContractCode; //合同 string ProductName = StoreInfoModel.ProducePlanInfo.GetProjectDetail.ProductName; //产品 string PartCode = StoreInfoModel.MaterialInfo.GetProcessBom.PartFigureCode; //零件图号 string PartName = StoreInfoModel.MaterialInfo.GetProcessBom.PartName; //零件名称 string MaterialName = StoreInfoModel.MaterialInfo.GetProcessBom.MaterialCode; //材质 string BarCode = resultE.Data.ToString(); //条码 bool isOK = CsBarCodePrint.BarCodePrint(PrintName, PointX, PointY, ContractName, ProductName, PartCode, PartName, MaterialName, BarCode); if (isOK) { MessageBox.Show("打印成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk); ResultModel resultD = ProduceProceInfoBLL.ProduceProceResult(0, windowB.SelectNum, ProduceProceInfoBLL.ProduceProceStateEnum.CompleteTask); if (resultD.Result) { WindowHelper.ShowPageProducePlan(); } else { MessageBox.Show(resultD.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("打印失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show(resultE.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } } } //不是最后一道工序 else { ResultModel resultB = ProduceProceInfoBLL.ProduceProceResult(0, windowB.SelectNum, ProduceProceInfoBLL.ProduceProceStateEnum.CompleteTask); if (resultB.Result) { WindowHelper.ShowPageProducePlan(); } else { MessageBox.Show(resultB.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } } else { MessageBox.Show(resultA.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } //暂停 else if (windowB.SelectState.Equals(1)) { ResultModel resultC = ProduceProceInfoBLL.ProduceProceResult(windowB.PauseReson, 0, ProduceProceInfoBLL.ProduceProceStateEnum.PauseTask); if (resultC.Result) { WindowHelper.ShowPageProducePlan(); } else { MessageBox.Show(resultC.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } //取消 else { } } break; case Key.Up: pointY -= drawMoveOffset; axMxDrawX.ZoomCenter(pointX, pointY); break; case Key.Down: pointY += drawMoveOffset; axMxDrawX.ZoomCenter(pointX, pointY); break; case Key.Left: pointX += drawMoveOffset; axMxDrawX.ZoomCenter(pointX, pointY); break; case Key.Right: pointX -= drawMoveOffset; axMxDrawX.ZoomCenter(pointX, pointY); break; case Key.OemPlus: //+ case Key.Add: //+ case Key.OemCloseBrackets: //} MouseSimulateWheelEvent(150); break; case Key.OemMinus: //- case Key.Subtract: //- case Key.OemOpenBrackets: //{ MouseSimulateWheelEvent(-120); break; default: break; } }