private void MainPage_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            int n = (int)e.Key;

            switch (e.Key)
            {
            case Key.Tab:
                #region
                focusArea = ((int)focusArea + 1).Equals(4) ? 0 : (FocusAreaEnum)((int)focusArea + 1);
                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:
                    RemoveTabBorder(tbDrawingList);
                    AddTabBorder(tbWorkStepsInfo);
                    break;

                case FocusAreaEnum.CenterFocus:
                    RemoveTabBorder(tbWorkStepsInfo);
                    AddTabBorder(mxDraw);
                    break;

                case FocusAreaEnum.RightFocus:
                    RemoveTabBorder(mxDraw);
                    AddTabBorder(materielList);
                    break;

                case FocusAreaEnum.DownFocus:
                    RemoveTabBorder(materielList);
                    AddTabBorder(tbDrawingList);
                    break;
                }
                #endregion
                break;

            case Key.Up:

                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:
                    //WorkStepBar.Prev();
                    ShowWorkStepsInfo();
                    //workStepIndex = (workStepIndex - 1) <= -1 ? (workStepCount - 1) : (workStepIndex - 1);
                    workStepIndex               = (workStepIndex - 1) <= -1 ? 0 : (workStepIndex - 1);
                    dataContext.WorkStep        = dataContext.WorkSteps[workStepIndex];
                    WorkStepsList.SelectedIndex = workStepIndex;
                    break;

                case FocusAreaEnum.CenterFocus:
                    pointY -= drawMoveOffset;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus:
                    //RemoveTabBorder(mxDraw);
                    //AddTabBorder(materielList);
                    break;

                case FocusAreaEnum.DownFocus:

                    break;

                default: break;
                }

                break;

            case Key.Down:

                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:
                    //WorkStepBar.Next();
                    ShowWorkStepsInfo();
                    //workStepIndex = (workStepIndex + 1) >= workStepCount ? 0 : (workStepIndex + 1);
                    workStepIndex               = (workStepIndex + 1) >= workStepCount ? (workStepCount - 1) : (workStepIndex + 1);
                    dataContext.WorkStep        = dataContext.WorkSteps[workStepIndex];
                    WorkStepsList.SelectedIndex = workStepIndex;
                    break;

                case FocusAreaEnum.CenterFocus:
                    pointY += drawMoveOffset;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus:
                    //RemoveTabBorder(mxDraw);
                    //AddTabBorder(materielList);
                    break;

                case FocusAreaEnum.DownFocus:

                    break;

                default: break;
                }

                break;

            case Key.Left:

                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:

                    break;

                case FocusAreaEnum.CenterFocus:
                    pointX += drawMoveOffset;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus:

                    break;

                case FocusAreaEnum.DownFocus:
                    if (!drawingCount.Equals(0))
                    {
                        ContentPresenter cpA  = DrawCardItems.ItemContainerGenerator.ContainerFromIndex(drawingIndex) as ContentPresenter;
                        List <TextBlock> gdsA = Helpers.WpfHelper.FindVisualChildren <TextBlock>(cpA);
                        if (gdsA.Count > 0)
                        {
                            gdsA[0].Background = new SolidColorBrush(Color.FromRgb(65, 65, 65));
                        }

                        //CheckDrawListBtn(false);
                        drawingIndex = (drawingIndex - 1).Equals(-1) ? (drawingCount - 1) : (drawingIndex - 1);
                        OpenDrawing(drawFilePaths[drawingIndex]);

                        ContentPresenter cpB  = DrawCardItems.ItemContainerGenerator.ContainerFromIndex(drawingIndex) as ContentPresenter;
                        List <TextBlock> gdsB = Helpers.WpfHelper.FindVisualChildren <TextBlock>(cpB);
                        if (gdsB.Count > 0)
                        {
                            gdsB[0].Background = new SolidColorBrush(Color.FromRgb(250, 80, 70));
                        }

                        //OpenDrawing(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[drawingIndex].FileName));
                        //BLL.Helpers.ClientHelper.RecordOperateLog(string.Format(@"用户【{0}】切换了图纸!", StoreInfoModel.UserName));
                        //CheckDrawListBtn(true);
                    }
                    break;

                default: break;
                }

                break;

            case Key.Right:

                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:

                    break;

                case FocusAreaEnum.CenterFocus:
                    pointX -= drawMoveOffset;
                    axMxDrawX.ZoomCenter(pointX, pointY);
                    break;

                case FocusAreaEnum.RightFocus:

                    break;

                case FocusAreaEnum.DownFocus:
                    if (!drawingCount.Equals(0))
                    {
                        ContentPresenter cpA  = DrawCardItems.ItemContainerGenerator.ContainerFromIndex(drawingIndex) as ContentPresenter;
                        List <TextBlock> gdsA = Helpers.WpfHelper.FindVisualChildren <TextBlock>(cpA);
                        if (gdsA.Count > 0)
                        {
                            gdsA[0].Background = new SolidColorBrush(Color.FromRgb(65, 65, 65));
                        }

                        //CheckDrawListBtn(false);
                        drawingIndex = (drawingIndex - 1).Equals(-1) ? (drawingCount - 1) : (drawingIndex - 1);
                        OpenDrawing(drawFilePaths[drawingIndex]);

                        ContentPresenter cpB  = DrawCardItems.ItemContainerGenerator.ContainerFromIndex(drawingIndex) as ContentPresenter;
                        List <TextBlock> gdsB = Helpers.WpfHelper.FindVisualChildren <TextBlock>(cpB);
                        if (gdsB.Count > 0)
                        {
                            gdsB[0].Background = new SolidColorBrush(Color.FromRgb(250, 80, 70));
                        }

                        //OpenDrawing(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[drawingIndex].FileName));
                        //var temp = BLL.Helpers.ClientHelper.RecordOperateLog(string.Format(@"用户【{0}】切换了图纸!", StoreInfoModel.UserName));
                        //CheckDrawListBtn(true);
                    }
                    break;

                default: break;
                }

                break;

            //+
            case Key.OemPlus:
                if (focusArea.Equals(FocusAreaEnum.CenterFocus))
                {
                    MouseSimulateWheelEvent(120);
                }
                break;

            //-
            case Key.OemMinus:
                if (focusArea.Equals(FocusAreaEnum.CenterFocus))
                {
                    MouseSimulateWheelEvent(-120);
                }
                break;

            case Key.Enter:

                switch (focusArea)
                {
                case FocusAreaEnum.LeftFocus:

                    break;

                case FocusAreaEnum.CenterFocus:

                    break;

                case FocusAreaEnum.RightFocus:

                    break;

                default: break;
                }

                break;

            case Key.LeftCtrl:
            case Key.Multiply:

                WinView.ProceStateWindow window = new WinView.ProceStateWindow();
                window.ShowDialog();
                MessageBoxResult dr = window.Result;

                var temp = BLL.Helpers.ClientHelper.RecordOperateLog(new List <string>()
                {
                    string.Format(@"用户【{0}】在图纸上打开了选择生产状态窗口!", StoreInfoModel.UserName),
                    string.Format(@"用户【{0}】在选择生产状态窗口中选择了【{1}】!{2}",
                                  StoreInfoModel.UserName, dr == MessageBoxResult.Yes?"完工":dr == MessageBoxResult.No?"暂停":"取消", dr == MessageBoxResult.Yes?string.Format(@"并且输入的数量是【{0}】!", Convert.ToInt32(window.ProduceNum)):string.Empty),
                });

                //完工
                if (dr == MessageBoxResult.Yes)
                {
                    string msg    = string.Empty;
                    bool   result = new ProduceProceInfoBLL().ProduceProceResult(ref msg, Convert.ToInt32(window.ProduceNum), ProduceProceInfoBLL.ProduceProceStateEnum.CompleteTask);


                    if (!result)
                    {
                        MessageBox.Show(msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }

                    NavigationService.GetNavigationService(this).Navigate(new Uri("View/ProducePlanPage.xaml", UriKind.Relative));
                }
                //暂停
                else if (dr == MessageBoxResult.No)
                {
                    string msg    = string.Empty;
                    bool   result = new ProduceProceInfoBLL().ProduceProceResult(ref msg, 0, ProduceProceInfoBLL.ProduceProceStateEnum.PauseTask);

                    //跳转至选择任务计划页面
                    NavigationService.GetNavigationService(this).Navigate(new Uri("View/ProducePlanPage.xaml", UriKind.Relative));
                }
                //取消
                else
                {
                }

                break;

            case Key.ImeProcessed:

                return;

            default: break;
            }

            e.Handled = true;
        }
Ejemplo n.º 2
0
        //梦想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;
            }
        }