private void SetViewTo(SubWindow subWindow) { log.InfoFormat("switch view to {0}", subWindow.ToString()); this.gridViewHolder.Children.Clear(); bool thisBatchLastOne = GlobalMethods.IsLastBatch(); ProcessState thisStepState = thisBatchLastOne ? ProcessState.Finished : ProcessState.Doing; switch (subWindow) { case SubWindow.Setting: this.gridViewHolder.Children.Add(settingWindow); ChangeWindowState(SubWindow.Setting, ProcessState.Doing); break; case SubWindow.Measure: //create or show if (measureWindow == null) { measureWindow = new MeasureWindow(); measureWindow.onFinished += new MeasureWindow.Finish(measureWindow_onFinished); } else { measureWindow.Visibility = Visibility.Visible; } ChangeWindowState(SubWindow.ScanBarcode, thisStepState); ChangeWindowState(SubWindow.Measure, ProcessState.Doing); this.gridViewHolder.Children.Add(measureWindow); break; case SubWindow.ScanBarcode: //create or show if (inputBarcodeWindow == null) { inputBarcodeWindow = new InputBarcode(); inputBarcodeWindow.onFinished += new InputBarcode.Finish(inputBarcodeWindow_onFinished); } else { inputBarcodeWindow.Visibility = Visibility.Visible; } if (GlobalVals.curBatch == 1) //first time { ChangeWindowState(SubWindow.Setting, ProcessState.Finished); ChangeWindowState(SubWindow.ScanBarcode, ProcessState.Doing); } else { ChangeWindowState(SubWindow.ScanBarcode, thisStepState); ChangeWindowState(SubWindow.Measure, ProcessState.Doing); } this.gridViewHolder.Children.Add(inputBarcodeWindow); break; case SubWindow.AdjustPostion: //create or show if (adjustWindow == null) { adjustWindow = new AdjustLayout(); adjustWindow.onFinished += new AdjustLayout.Finish(adjustWindow_onFinished); } else { adjustWindow.Visibility = Visibility.Visible; } ChangeWindowState(SubWindow.Measure, thisStepState); ChangeWindowState(SubWindow.AdjustPostion, ProcessState.Doing); this.gridViewHolder.Children.Add(adjustWindow); break; case SubWindow.Report: if (reportWindow == null) { reportWindow = new ReportWindow(); reportWindow.onFinished += new ReportWindow.Finish(reportWindow_onFinished); } if (thisBatchLastOne) { ChangeWindowState(SubWindow.AdjustPostion, ProcessState.Finished); ChangeWindowState(SubWindow.Measure, ProcessState.Finished); } ChangeWindowState(SubWindow.Report, ProcessState.Doing); this.gridViewHolder.Children.Add(reportWindow); break; default: break; } }
private void ChangeWindowState(SubWindow subWindow, ProcessState processState) { string windowName = ""; Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add(SubWindow.Setting.ToString(), "1 设置样品"); dict.Add(SubWindow.ScanBarcode.ToString(), "2 扫描条码"); dict.Add(SubWindow.Measure.ToString(), "3 测量液面"); dict.Add(SubWindow.AdjustPostion.ToString(), "4 放置载架"); dict.Add(SubWindow.Report.ToString(), "5 报告结果"); windowName = dict[subWindow.ToString()]; foreach (var item in navigator.Items) { ShortNameConverter nameConverter = new ShortNameConverter(); string sCurItem = (string)nameConverter.Convert(item, typeof(string), null, null); if (sCurItem == dict[subWindow.ToString()]) { ListBoxItem container = navigator.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem; if (processState == ProcessState.Finished) { EnumVisual(container, Brushes.LightBlue); container.IsSelected = true; } if (processState == ProcessState.Doing) { EnumVisual(container, Brushes.OrangeRed); } return; } } }