/// <summary> /// 页面按键抬起事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PageContainer_PreviewKeyUp(object sender, KeyEventArgs e) { //偏移量 int num = 50; switch ((int)e.Key) { //tab键-切换焦点区域 case 3: #region focusArea = ((int)focusArea + 1).Equals(3) ? 0 : (FocusAreaEnum)((int)focusArea + 1); Border border = new Border(); border.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 255, 255)); border.BorderThickness = new Thickness(2); switch (focusArea) { case FocusAreaEnum.LeftFocus: for (int i = 0; i < tbDrawingList.Children.Count; i++) { if (tbDrawingList.Children[i] is Border) { tbDrawingList.Children.Remove(tbDrawingList.Children[i]); } } tbMaterialInfo.Children.Add(border); break; case FocusAreaEnum.CenterFocus: for (int i = 0; i < tbMaterialInfo.Children.Count; i++) { if (tbMaterialInfo.Children[i] is Border) { tbMaterialInfo.Children.Remove(tbMaterialInfo.Children[i]); } } tbDrawingShow.Children.Add(border); break; case FocusAreaEnum.RightFocus: for (int i = 0; i < tbDrawingShow.Children.Count; i++) { if (tbDrawingShow.Children[i] is Border) { tbDrawingShow.Children.Remove(tbDrawingShow.Children[i]); } } tbDrawingList.Children.Add(border); gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(240, 0, 240)); break; default: break; } #endregion break; //左 case 23: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.CenterFocus: pointX += num; axMxDrawX.ZoomCenter(pointX, pointY); break; case FocusAreaEnum.RightFocus: break; default: break; } #endregion break; //上 case 24: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.CenterFocus: pointY -= num; axMxDrawX.ZoomCenter(pointX, pointY); break; case FocusAreaEnum.RightFocus: #region gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(65, 65, 65)); gridDrawingIndex = (gridDrawingIndex - 1).Equals(-1) ? gridDrawings.Length - 1 : (gridDrawingIndex - 1); gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(240, 0, 240)); //详情 if (gridDrawingIndex.Equals(0)) { Grid pInfoGrid = new Grid() { Margin = new Thickness(0, 1, 0, 0), Background = new SolidColorBrush(Color.FromRgb(65, 65, 65)) }; TextBlock pInfoTextBlock = new TextBlock() { Foreground = new SolidColorBrush(Color.FromRgb(240, 240, 240)), Margin = new Thickness(5), FontSize = 14, TextWrapping = TextWrapping.Wrap, Text = StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.ProcessDesc }; pInfoGrid.Children.Add(pInfoTextBlock); projectInfo.Children.Add(pInfoGrid); } //地图 else { if (projectInfo.Children.Count > 0) { projectInfo.Children.Clear(); } OpenDrawing(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[gridDrawingIndex - 1].FileName)); } #endregion break; default: break; } #endregion break; //右 case 25: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.CenterFocus: pointX -= num; axMxDrawX.ZoomCenter(pointX, pointY); break; case FocusAreaEnum.RightFocus: break; default: break; } #endregion break; //下 case 26: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.CenterFocus: pointY += num; axMxDrawX.ZoomCenter(pointX, pointY); break; case FocusAreaEnum.RightFocus: #region gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(65, 65, 65)); gridDrawingIndex = (gridDrawingIndex + 1).Equals(gridDrawings.Length) ? 0 : (gridDrawingIndex + 1); gridDrawings[gridDrawingIndex].Background = new SolidColorBrush(Color.FromRgb(240, 0, 240)); //详情 if (gridDrawingIndex.Equals(0)) { Grid pInfoGrid = new Grid() { Margin = new Thickness(0, 1, 0, 0), Background = new SolidColorBrush(Color.FromRgb(65, 65, 65)) }; TextBlock pInfoTextBlock = new TextBlock() { Foreground = new SolidColorBrush(Color.FromRgb(240, 240, 240)), Margin = new Thickness(5), FontSize = 14, TextWrapping = TextWrapping.Wrap, Text = StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.ProcessDesc }; pInfoGrid.Children.Add(pInfoTextBlock); projectInfo.Children.Add(pInfoGrid); } //地图 else { if (projectInfo.Children.Count > 0) { projectInfo.Children.Clear(); } OpenDrawing(string.Format(@"{0}\{1}", ConfigInfoModel.DocDirName, StoreInfoModel.ProducePlanInfo.GetPartFiles[gridDrawingIndex - 1].FileName)); } #endregion break; default: break; } #endregion break; //- case 143: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.CenterFocus: MouseSimulateWheelEvent(-120); break; case FocusAreaEnum.RightFocus: break; default: break; } #endregion break; //+ case 141: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.CenterFocus: MouseSimulateWheelEvent(120); break; case FocusAreaEnum.RightFocus: break; default: break; } #endregion break; //Ctrl键-在图纸界面焦点区域:弹出是否完工,暂停,取消对话框 case 118: case 119: #region if (focusArea.Equals(FocusAreaEnum.CenterFocus)) { //MessageBoxResult dr = MessageBox.Show("如果“完工”,请选择“是”;\n如果“暂停”,请选择“否”;\n如果误操作,请选择“取消”;", "提示", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); ProduceStateWindow window = new ProduceStateWindow(); window.ShowDialog(); MessageBoxResult dr = window.Result; //完工 if (dr == MessageBoxResult.Yes) { //物料出库 ResultModel OutPutResult = new BLL.ExtraBLL.MaterialInfoBLL().MaterialInventory(BLL.ExtraBLL.MaterialInfoBLL.MaterialStateEnum.OtherOutput); if (!OutPutResult.Result) { MessageBox.Show(OutPutResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } //记录生产转序入库数量 StoreInfoModel.ProducePlanInfo.GetProjectProduceDetial.Quantity = window.Num; //录入计划实际结束时间 ResultModel actualDateResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ActualProducePlanDate(BLL.ExtraBLL.ProducePlanInfoBLL.ProducePlanStateEnum.End); //获取工艺路线,判断是否需要报检 var IsInspectionReport = StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.IsInspectionReport ?? 0; //不需要报检 if (IsInspectionReport.Equals(1)) { if (string.IsNullOrEmpty(StoreInfoModel.ProducePlanInfo.GetProductProcessRoute.WarehouseName)) { MessageBox.Show(@"你生产的那啥没人要啊!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning); } else { //转序入库 ResultModel TurnInputResult = new BLL.ExtraBLL.MaterialInfoBLL().MaterialInventory(BLL.ExtraBLL.MaterialInfoBLL.MaterialStateEnum.TurnInput); if (!TurnInputResult.Result) { MessageBox.Show(TurnInputResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } } } //需要报检 else { //生成报检单 ResultModel result = new BLL.ExtraBLL.MaterialInfoBLL().InspectionReport(); } //记录生产日志 ResultModel logResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ProduceLog(BLL.ExtraBLL.ProducePlanInfoBLL.ProduceLogTypeEnum.End); //跳转至选择任务计划页面 NavigationService.GetNavigationService(this).Navigate(new Uri("ProductPlanPage.xaml", UriKind.Relative)); } //暂停 else if (dr == MessageBoxResult.No) { //记录生产日志 ResultModel logResult = new BLL.ExtraBLL.ProducePlanInfoBLL().ProduceLog(BLL.ExtraBLL.ProducePlanInfoBLL.ProduceLogTypeEnum.Pause); //跳转至选择任务计划页面 NavigationService.GetNavigationService(this).Navigate(new Uri("ProductPlanPage.xaml", UriKind.Relative)); } //取消 else { } } #endregion break; default: break; } }
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; }
/// <summary> /// 页面按键抬起事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PageContainer_PreviewKeyUp(object sender, KeyEventArgs e) { //获取焦点后的边框 Border border = new Border(); border.BorderBrush = new SolidColorBrush(Color.FromRgb(158, 183, 241)); border.BorderThickness = new Thickness(2); switch ((int)e.Key) { //tab键-切换焦点区域 case 3: #region focusArea = ((int)focusArea + 1).Equals(2) ? 0 : (FocusAreaEnum)((int)focusArea + 1); Border focusBorder = new Border(); focusBorder.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 255, 255)); focusBorder.BorderThickness = new Thickness(2); switch (focusArea) { case FocusAreaEnum.LeftFocus: for (int i = 0; i < tbPlanInfoContainer.Children.Count; i++) { if (tbPlanInfoContainer.Children[i] is Border) { tbPlanInfoContainer.Children.Remove(tbPlanInfoContainer.Children[i]); } } tbPlanInfoList.Children.Add(focusBorder); break; case FocusAreaEnum.RightFocus: for (int i = 0; i < tbPlanInfoList.Children.Count; i++) { if (tbPlanInfoList.Children[i] is Border) { tbPlanInfoList.Children.Remove(tbPlanInfoList.Children[i]); } } tbPlanInfoContainer.Children.Add(focusBorder); break; default: break; } #endregion break; //enter键-回车 case 6: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.RightFocus: StoreInfoModel.ProducePlanInfo = planGridContainers[planGridIndex].Tag as ProducePlanInfoModel.DataModel; //初始化-加载该生产计划所需物料详情 var getMaterialInfo = new BLL.ExtraBLL.MaterialInfoBLL().GetMaterialDetail(); if (!getMaterialInfo.Result) { MessageBox.Show(getMaterialInfo.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } //下载图纸文件 var drawResult = new BLL.ExtraBLL.ProducePlanInfoBLL().DownLoadDrawing(); if (!drawResult.Result) { MessageBox.Show(drawResult.Msg, "提示", MessageBoxButton.OK, MessageBoxImage.Warning); } NavigationService.GetNavigationService(this).Navigate(new Uri("ProductProcessPage.xaml", UriKind.Relative)); break; default: break; } #endregion break; //左 case 23: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.RightFocus: if (planGridContainers.Length > 0) { for (int i = 0; i < planGridContainers[planGridIndex].Children.Count; i++) { if (planGridContainers[planGridIndex].Children[i] is Border) { planGridContainers[planGridIndex].Children.Remove(planGridContainers[planGridIndex].Children[i]); } } planGridIndex = (planGridIndex - 1).Equals(-1) ? (planGridContainers.Length - 1) : (planGridIndex - 1); planGridContainers[planGridIndex].Children.Add(border); } break; default: break; } #endregion break; //上 case 24: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: int n = lvwPlanInfo.SelectedIndex; n = (n - 1) <= -1 ? (lvwPlanInfo.Items.Count - 1) : (n - 1); lvwPlanInfo.SelectedIndex = n; break; case FocusAreaEnum.RightFocus: double ah = svPInfoContainer.VerticalOffset; double num = svPInfoContainer.ScrollableHeight / 10; ah = (ah - num) < 0 ? 0 : (ah - num); svPInfoContainer.ScrollToVerticalOffset(ah); break; default: break; } #endregion break; //右 case 25: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: break; case FocusAreaEnum.RightFocus: if (planGridContainers.Length > 0) { for (int i = 0; i < planGridContainers[planGridIndex].Children.Count; i++) { if (planGridContainers[planGridIndex].Children[i] is Border) { planGridContainers[planGridIndex].Children.Remove(planGridContainers[planGridIndex].Children[i]); } } planGridIndex = (planGridIndex + 1).Equals(planGridContainers.Length) ? 0 : (planGridIndex + 1); planGridContainers[planGridIndex].Children.Add(border); } break; default: break; } #endregion break; //下 case 26: #region switch (focusArea) { case FocusAreaEnum.LeftFocus: int n = lvwPlanInfo.SelectedIndex; n = (n + 1).Equals(lvwPlanInfo.Items.Count) ? 0 : (n + 1); lvwPlanInfo.SelectedIndex = n; break; case FocusAreaEnum.RightFocus: double ah = svPInfoContainer.VerticalOffset; double num = svPInfoContainer.ScrollableHeight / 10; ah = (ah + num) > svPInfoContainer.ScrollableHeight ? svPInfoContainer.ScrollableHeight : (ah + num); svPInfoContainer.ScrollToVerticalOffset(ah); break; default: break; } #endregion break; default: break; } }