/// <summary> /// 标签显示模式 /// </summary> void ShowTab() { //先要清除Mdi模式,待添加代码 if (!Controls.Contains(_tabCtrl))//Add(_tabCtrl); { Controls.Add(_tabCtrl); } cmrLstToolStripMenuItem.Visible = false; //MDI模式下使用 _lstUpdateBts.Clear(); _lstCmrStatusLbs.Clear(); _lstUcCmrs.Clear(); _tabCtrl.TabPages.Clear(); if (null == _cmrNames) { return; } for (int i = 0; i < _cmrNames.Length; i++) { TabPage tp = new TabPage(_cmrNames[i]); Button btFlush = new Button(); btFlush.Text = "更新"; btFlush.Click += OnFlushButtonClick; _lstUpdateBts.Add(btFlush); Label lbInfo = new Label(); //lbInfo.Left = btFlush.Right + 5; lbInfo.Location = new Point(btFlush.Right + 5, btFlush.Top + 5); lbInfo.Text = "相机:" + _cmrNames[i]; lbInfo.AutoSize = true; IJFDevice_Camera cmr = JFHubCenter.Instance.InitorManager.GetInitor(_cmrNames[i]) as IJFDevice_Camera; if (null == cmr) { lbInfo.Text += " 在设备列表中不存在"; } _lstCmrStatusLbs.Add(lbInfo); UcCmr ucCmr = new UcCmr(); ucCmr.SetCamera(cmr); ucCmr.Top = btFlush.Bottom + 5; ucCmr.Width = tp.Width - 5; ucCmr.Height = tp.Height - 5; ucCmr.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; _lstUcCmrs.Add(ucCmr); tp.Controls.Add(btFlush); tp.Controls.Add(lbInfo); tp.Controls.Add(ucCmr); _tabCtrl.TabPages.Add(tp); } }
/// <summary>调试所选设备</summary> private void btDebug_Click(object sender, EventArgs e) { if (null == dgvDevs.SelectedRows || 0 == dgvDevs.SelectedRows.Count) { MessageBox.Show("请先选择需要调试的" + InitorCaption + "对象"); return; } IJFInitializable initor = JFHubCenter.Instance.InitorManager[dgvDevs.SelectedRows[0].Cells[0].Value.ToString()]; Type devType = initor.GetType(); if (chkSelfUI.Checked) { if (!typeof(IJFRealtimeUIProvider).IsAssignableFrom(devType)) { MessageBox.Show(InitorCaption + "对象未提供自带调试界面,请取消\"自带界面\"后重试!"); return; } if (typeof(IJFStation).IsAssignableFrom(devType)) { Form fmStationDebug = (initor as IJFStation).GenForm(); if (null == fmStationDebug) //工站自身未提供界面 { if (DialogResult.Cancel == MessageBox.Show("工站对象未提供调试界面,是否使用通用界面?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { return; } if (typeof(JFStationBase).IsAssignableFrom(devType)) { FormStationBaseDebug fmSB = new FormStationBaseDebug(); fmSB.Text = (initor as JFStationBase).Name + " Debug"; fmSB.SetStation(initor as JFStationBase); fmSB.TopMost = true; fmSB.Show(); return; } else { //JFRealtimeUI ucST = (initor as IJFRealtimeUIProvider).GetRealtimeUI(); //ucST.Dock = DockStyle.Fill; UcStationRealtimeUI ucST = new UcStationRealtimeUI(); ucST.Dock = DockStyle.Fill; ucST.AllowedStartStopCmd = true; ucST.SetStation(initor as IJFStation); FormJFRealTimeUI fmST = new FormJFRealTimeUI(); fmST.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug"; fmST.Size = ucST.Size; fmST.SetRTUI(ucST); //fm.Controls.Add(uc); fmST.Show(); return; } } else { fmStationDebug.FormBorderStyle = FormBorderStyle.Sizable; fmStationDebug.TopMost = true; fmStationDebug.Show(); return; } } JFRealtimeUI uc = (initor as IJFRealtimeUIProvider).GetRealtimeUI(); uc.Dock = DockStyle.Fill; FormJFRealTimeUI fm = new FormJFRealTimeUI(); fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug"; fm.Size = uc.Size; fm.SetRTUI(uc); //fm.Controls.Add(uc); fm.Show(); } else { if (typeof(IJFDevice_Camera).IsAssignableFrom(devType) || typeof(IJFDevice_LightController).IsAssignableFrom(devType) || typeof(IJFDevice_MotionDaq).IsAssignableFrom(devType) || typeof(IJFDevice_TrigController).IsAssignableFrom(devType) || typeof(IJFStation).IsAssignableFrom(devType)) { if (typeof(JFStationBase).IsAssignableFrom(devType)) { FormStationBaseDebug fmSB = new FormStationBaseDebug(); fmSB.Text = (initor as JFStationBase).Name + " Debug"; fmSB.SetStation(initor as JFStationBase); fmSB.Show(); return; } if (typeof(IJFStation).IsAssignableFrom(devType)) { UcStationRealtimeUI ucST = new UcStationRealtimeUI(); ucST.Dock = DockStyle.Fill; ucST.AllowedStartStopCmd = true; ucST.SetStation(initor as IJFStation); FormJFRealTimeUI fmST = new FormJFRealTimeUI(); fmST.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug"; fmST.Size = ucST.Size; fmST.SetRTUI(ucST); //fm.Controls.Add(uc); fmST.Show(); return; } FormJFRealTimeUI fm = new FormJFRealTimeUI(); fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + " Debug" + "待实现!!"; if (typeof(IJFDevice_MotionDaq).IsAssignableFrom(devType)) { UcMotionDaq uc = new UcMotionDaq(); fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口"; //uc.Parent = fm; uc.SetDevice(initor as IJFDevice_MotionDaq, dgvDevs.SelectedRows[0].Cells[0].Value.ToString()); //fm.Size = new Size(uc.Width + 20, uc.Height + 20); //fm.Controls.Add(uc); fm.SetRTUI(uc); } else if (typeof(IJFDevice_TrigController).IsAssignableFrom(devType))//HTM触发板控制器,一进多出(控制触发强度/时间) { fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口"; if (typeof(IJFDevice_LightController).IsAssignableFrom(devType))//带触发功能的光源控制器 { UcLightCtrl_T uc = new UcLightCtrl_T(); uc.SetModule(initor as IJFDevice_LightControllerWithTrig, null, null); uc.Dock = DockStyle.Fill; fm.SetRTUI(uc); } else //单纯的触发控制器 { UcTrigCtrl uc = new UcTrigCtrl(); uc.SetModuleInfo(initor as IJFDevice_TrigController); fm.SetRTUI(uc); } } else if (typeof(IJFDevice_LightController).IsAssignableFrom(devType)) //光源控制器 { fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口"; UcLightCtrl uc = new UcLightCtrl(); uc.SetModuleInfo(initor as IJFDevice_LightController); fm.SetRTUI(uc); } else if (typeof(IJFDevice_Camera).IsAssignableFrom(devType)) { fm.Text = dgvDevs.SelectedRows[0].Cells[0].Value.ToString() + "调试窗口"; UcCmr uc = new UcCmr(); uc.SetCamera(initor as IJFDevice_Camera); fm.SetRTUI(uc); } fm.Show(); } else { MessageBox.Show("无法为" + InitorCaption + "类型的对象提供调试界面"); return; } } }