private void Window_Loaded(object sender, RoutedEventArgs e) { if (null == _item) { return; } _MAX_CAM = Global.deviceHole.SxtCount - 1; _listSampleNum = new List <TextBox>(); int sampleNum = _item.SampleNum; int holeUse = 0; // 添加布局 for (int i = 0; i < Global.deviceHole.SxtCount; ++i) { UIElement element = GenerateChannelLayout(i, String.Format("{0:D5}", sampleNum), _item.Hole[i].SampleName); WrapPanelChannel.Children.Add(element); if (_item.Hole[i].Use) { holeUse += 1; sampleNum++; _listSampleNum.Add(UIUtils.GetChildObject <TextBox>(element, "sampleNum")); } else { element.Visibility = System.Windows.Visibility.Collapsed; _listSampleNum.Add(null); } } if (holeUse < 4) { if (holeUse == 1) { this.WrapPanelChannel.Width = 190; } else if (holeUse == 2) { this.WrapPanelChannel.Width = 380; } else if (holeUse == 3) { this.WrapPanelChannel.Width = 570; } } // 初始化辅助方框及TC线的参数 _bTCLineNeedSetting = new bool[Global.deviceHole.SxtCount]; _helpBoxes = new HelpBox[Global.deviceHole.SxtCount]; for (int i = 0; i < _bTCLineNeedSetting.Length; ++i) { _bTCLineNeedSetting[i] = false; _helpBoxes[i] = new HelpBox(); } // 初始化灰阶值存储位置 _bRGBValuesNeedRead = new bool[Global.deviceHole.SxtCount]; _listRGBValues = new List <byte[]>(); for (int i = 0; i < _bRGBValuesNeedRead.Length; ++i) { _bRGBValuesNeedRead[i] = false; _listRGBValues.Add(null); } // 启动线程 _updateCAMThread = new UpdateCAMThread(this); _updateCAMThread.Start(); _bTimerWork = true; _msgReadCAMReplyed = true; _timerThread = new TimerThread(this); _timerThread.Start(); Message msg = new Message() { what = MsgCode.MSG_TIMER_WORK }; _timerThread.SendMessage(msg, null); }