public PlanExecuteStateViewModel(WindowPlanExecuteState _window) { num = StoreInfo.MaterialOneSelf == null ? 0 : StoreInfo.MaterialOneSelf.MaterialInfo.TotalQuantity; CompleteCommand = new DelegateCommand(new Action <object>(obj => { _window.SelectState = 0; _window.SelectNum = Num; _window.Close(); })); StopCommand = new DelegateCommand(new Action <object>(obj => { _window.SelectState = 1; int pauseReson; if (RdbA) { pauseReson = 1; } else if (RdbB) { pauseReson = 2; } else if (RdbC) { pauseReson = 3; } else { pauseReson = 0; } _window.PauseReson = pauseReson; _window.Close(); })); CancelCommand = new DelegateCommand(new Action <object>(obj => { _window.SelectState = 2; _window.Close(); })); UpNumCommand = new DelegateCommand(new Action <object>(obj => { Num++; })); DownNumCommand = new DelegateCommand(new Action <object>(obj => { if (Num > 0) { Num--; } })); RdbChangeCommand = new DelegateCommand(obj => RdbChange(obj)); _window.btnCancel.Focus(); }
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: if (WindowHelper.WorkShopType.Equals(EnumManager.WorkShopTypeEnum.BlankingShop)) { //弹出选择 完工/暂停/取消 窗口 WindowPlanExecuteState window = new WindowPlanExecuteState(); window.ShowDialog(); //完工 if (window.SelectState.Equals(0)) { var resultB = ApiManager.SetActualProducePlanDate(EnumManager.ProducePlanStateEnum.End); var resultC = ApiManager.SetProduceLog(EnumManager.ProduceLogTypeEnum.End, window.SelectNum); WindowHelper.ShowPagePlanCard(); } //暂停 else if (window.SelectState.Equals(1)) { ResultModel resultC = ApiManager.SetProduceLog(EnumManager.ProduceLogTypeEnum.Pause, window.SelectNum, (EnumManager.PauseResonEnum)window.PauseReson); if (resultC.Result) { WindowHelper.ShowPagePlanCard(); } else { MessageBox.Show(resultC.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } //取消 else { } return; } //弹出扫码界面 WindowHelper.MaterialScanWindow = new WindowMaterialScan(); WindowHelper.MaterialScanWindow.ShowDialog(); new SerialPortScanCode().Start(); WindowHelper.IsOpenMaterialScanWindow = false; //重加载物料数据 ResetMaterial(); if ((WindowHelper.MaterialScanWindow as WindowMaterialScan).OperateType.Equals(0)) { //不操作 } else { //弹出选择 完工/暂停/取消 窗口 WindowPlanExecuteState window = new WindowPlanExecuteState(); window.ShowDialog(); //完工 if (window.SelectState.Equals(0)) { ResultModel resultA = ApiManager.IsLastProcess(); if (resultA.Result) { //是最后一道工序 if (Convert.ToBoolean(resultA.Data)) { //判断物料是否扫码完成 bool isComplete = true; foreach (var item in Maintains) { if (!item.TotalQuantity.Equals(item.AlreadyScanQuantity)) { isComplete = false; break; } } if (!isComplete) { MessageBox.Show(@"物料未扫完,禁止完工!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } else { #region 弃用的打印功能 /*//提示打码 * MessageBoxResult boxResult = MessageBox.Show("是否打码?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question); * if (boxResult == MessageBoxResult.OK) * { * //获取条码 * ResultModel resultE = ApiManager.GenerateBarCode(); * if (resultE.Result) * { * int PointX = -25;//起始点X坐标 * int PointY = 0;//起始点Y坐标 * //string PrintName = "Honeywell PC42t (203 dpi) - DP";//打印机名称 * string PrintName = ConfigInfo.PrintMachineName;//打印机名称 * string ContractName = StoreInfo.CurrentWorkingTicket.ContractCode; //合同 * string ProductName = StoreInfo.CurrentWorkingTicket.ProductName; //产品 * string PartCode = StoreInfo.CurrentWorkingTicket.FigureNo; //零件图号 * string PartName = StoreInfo.CurrentWorkingTicket.PartName; //零件名称 * string MaterialName = StoreInfo.MaterialOneSelf.MaterialInfo.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); * * var resultB = ApiManager.SetActualProducePlanDate(EnumManager.ProducePlanStateEnum.End); * var resultC = ApiManager.SetProduceLog(EnumManager.ProduceLogTypeEnum.End, window.SelectNum); * * WindowHelper.ShowPagePlanCard(); * } * else * { * MessageBox.Show("打印失败!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); * } * } * else * { * MessageBox.Show(resultE.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); * } * }*/ #endregion var resultB = ApiManager.SetActualProducePlanDate(EnumManager.ProducePlanStateEnum.End); var resultC = ApiManager.SetProduceLog(EnumManager.ProduceLogTypeEnum.End, window.SelectNum); WindowHelper.ShowPagePlanCard(); } } //不是最后一道工序 else { var resultB = ApiManager.SetActualProducePlanDate(EnumManager.ProducePlanStateEnum.End); var resultC = ApiManager.SetProduceLog(EnumManager.ProduceLogTypeEnum.End, window.SelectNum); WindowHelper.ShowPagePlanCard(); } } else { MessageBox.Show(resultA.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } //暂停 else if (window.SelectState.Equals(1)) { ResultModel resultC = ApiManager.SetProduceLog(EnumManager.ProduceLogTypeEnum.Pause, window.SelectNum, (EnumManager.PauseResonEnum)window.PauseReson); if (resultC.Result) { WindowHelper.ShowPagePlanCard(); } 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: //} SimulationUserCommon.MouseSimulateWheelEvent(ConfigInfo.ZoomIn); break; case Key.OemMinus: //- case Key.Subtract: //- case Key.OemOpenBrackets: //{ SimulationUserCommon.MouseSimulateWheelEvent(ConfigInfo.ZoomOut); break; default: break; } }