private void lv_Items_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (lv_Items.SelectedItems.Count == 1) { if (m_UseSafetyOperations) { PopupControlHost _regionHost; RegionControl _regionControl = new RegionControl(); _regionControl.label1.Visible = true; _regionControl.label2.Visible = true; _regionControl.lbl_Address.Visible = true; _regionControl.lbl_Line.Visible = true; _regionControl.btn_Run.Visible = true; _regionControl.btn_Run.Text = "手动"; _regionControl.lbl_Address.Text = ((DevListViewItem)lv_Items.SelectedItems[0]).uAddress.ToString(); _regionControl.lbl_Line.Text = ((DevListViewItem)lv_Items.SelectedItems[0]).uLine.ToString(); //if (((DevListViewItem)lv_Items.SelectedItems[0]).uPowerFlash > 0) //{ // _regionControl.btn_PowerSwitch.Visible = false; // _regionControl.btn_PowerFlash.Visible = true; // _regionControl.btn_Flash.Visible = true; // if (((DevListViewItem)lv_Items.SelectedItems[0]).bFlash) // { // //_regionControl.btn_Flash.Text = "停止闪烁"; // _regionControl.btn_Flash.Enabled = false; // _regionControl.btn_PowerFlash.Enabled = false; // } // else // { // //_regionControl.btn_Flash.Text = "闪烁"; // _regionControl.btn_Flash.Enabled = true; // _regionControl.btn_PowerFlash.Enabled = true; // } //} //if (((DevListViewItem)lv_Items.SelectedItems[0]).uPowerFlash == 0) //{ // _regionControl.btn_PowerSwitch.Visible = true; // _regionControl.btn_Flash.Visible = false; // _regionControl.btn_PowerFlash.Visible = false; if (((DevListViewItem)lv_Items.SelectedItems[0]).ImageIndex == 3 * ((DevListViewItem)lv_Items.SelectedItems[0]).ImgGroup + 1) { _regionControl.btn_PowerSwitch.Text = "停止"; //_regionControl.btn_PowerFlash.Enabled = false; //_regionControl.btn_Flash.Visible = false; } else { _regionControl.btn_PowerSwitch.Text = "启动"; //_regionControl.btn_PowerFlash.Enabled = true; //_regionControl.btn_Flash.Visible = true; } //} _regionControl.btn_Run.MouseDown += delegate(object s, MouseEventArgs ee) { PowerON(); }; _regionControl.btn_Run.MouseUp += delegate(object s, MouseEventArgs ee) { PowerOFF(); }; _regionControl.btn_PowerSwitch.Click += delegate(object s, EventArgs ee) { PowerSwitch(); }; _regionControl.btn_PowerFlash.Click += delegate(object s, EventArgs ee) { OnPowerFlash(); }; _regionControl.btn_Flash.Click += delegate(object s, EventArgs ee) { OnFlash(); }; _regionHost = new PopupControlHost(_regionControl); _regionHost.ChangeRegion = true;//设置显示区域。 _regionHost.Opacity = 0.8F;//设置透明度。 Rectangle rc = new Rectangle(); rc = lv_Items.SelectedItems[0].Bounds; _regionHost.Show(lv_Items, rc, true); P_regionControl = _regionControl; } else { if (((DevListViewItem)lv_Items.SelectedItems[0]).uPowerFlash > 0) { OnPowerFlash(); } else { if (((DevListViewItem)lv_Items.SelectedItems[0]).ImageIndex == 3 * ((DevListViewItem)lv_Items.SelectedItems[0]).ImgGroup + 1) { PowerOFF(); } else { PowerON(); } } } } } else { //MessageBox.Show("你按下鼠标右键", "提示"); } }
private void SetOwnerItem(Control control) { if (control == null) { return; } if (control is PopupControlHost) { PopupControlHost popupControl = control as PopupControlHost; _ownerPopup = popupControl; _ownerPopup._childPopup = this; OwnerItem = popupControl.Items[0]; return; } if (control.Parent != null) { SetOwnerItem(control.Parent); } }