public void AddPopupPanel(Control _TargetControl, Control _PopupControl, PopupEvent _PStyle, int _width, int _height) { PopupContent popup = new PopupContent(); popup.TargetControl = _TargetControl; popup.PopupControl = _PopupControl; popup.PType = PopupType.Panel; popup.PStyle = _PStyle; popup.WStyle = WindowStyle.Default; popup.Width = _width; popup.Height = _height; popup.IsMCHide = true; popup.WindowTitle = ""; _PopupControl.Tag = this; if (popup.PStyle == PopupEvent.Click) { _TargetControl.Click += new EventHandler(_TargetControl_Click); } else if (popup.PStyle == PopupEvent.Mouse) { _TargetControl.MouseEnter += new EventHandler(_TargetControl_MouseEnter); _TargetControl.MouseLeave += new EventHandler(_TargetControl_MouseLeave); } else { } popupList.Add(popup); _PopupControl.Hide(); }
private void BindParentEvent(Control _TargetControl, PopupContent _popup) { CleanParentEvent(_TargetControl, _popup); if (_popup.IsMCHide == true) { Control ctrl = _TargetControl.FindForm(); EnumControls(ctrl, true); ctrl.MouseDown += new MouseEventHandler(Parent_LostFocus); for (int i = 0; i < popupList.Count; i++) { popupList[i].TargetControl.MouseDown -= new MouseEventHandler(Parent_LostFocus); popupList[i].TargetControl.MouseDown += new MouseEventHandler(Parent_LostFocus); } _TargetControl.MouseDown -= new MouseEventHandler(Parent_LostFocus); } }
private void CleanParentEvent(Control _TargetControl, PopupContent _popup) { Control ctrl = _TargetControl.FindForm(); EnumControls(ctrl, false); ctrl.MouseDown -= new MouseEventHandler(Parent_LostFocus); for (int i = 0; i < popupList.Count; i++) { popupList[i].TargetControl.MouseDown -= new MouseEventHandler(Parent_LostFocus); } }
public void ShowWindow(Control _TargetForm, Control _PopupForm, int width, int height, WindowStyle _WStyle,string title) { Hide(); PopupContent popup = new PopupContent(); popup.TargetControl = _TargetForm; popup.PopupControl = _PopupForm; popup.PType = PopupType.Window; popup.PStyle = PopupEvent.Custom; popup.WStyle = _WStyle; popup.Width = _PopupForm.Width; popup.Height = _PopupForm.Height; popup.IsMCHide = true;//点击隐藏 popup.WindowTitle = title; panelContainer.Tag = popup; if (width != -1) popup.Width = width; if (height != -1) popup.Height = height; panelContainer.Width = popup.Width; panelContainer.Height = popup.Height; if (popup.PopupControl is Form) { (popup.PopupControl as Form).TopLevel = false; (popup.PopupControl as Form).FormBorderStyle = FormBorderStyle.None; //(popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged); } if (popup.PType == PopupType.Window) { panelContainer.Padding = new Padding(2); panelContainer.Controls.Add(popup.PopupControl); panelContainer.Controls.Add(picTitle); picTitle.Height = 20; picTitle.Dock = DockStyle.Top; popup.PopupControl.Dock = DockStyle.Fill; rect_close = new Rectangle(panelContainer.Width - 22, 0, 20, 20); rect_titletext = new Rectangle(0, 0, panelContainer.Width - 50, 18); popup.PopupControl.Show(); } if (popup.WStyle == WindowStyle.Default) { SetPopupCenter(_TargetForm); panelContainer.Show(); if (popup.PopupControl is Form) { (popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged); } } else if (popup.WStyle == WindowStyle.Shadow) { SetPopupCenter(_TargetForm); panelContainer.Width = 0; panelContainer.Height = 0; Thread ts = new Thread(new ThreadStart(ShadowPanel)); ts.IsBackground = true; ts.Priority = ThreadPriority.Normal; ts.Start(); } else if (popup.WStyle == WindowStyle.Task) { SetPopupTask(_TargetForm); Thread ts = new Thread(new ThreadStart(TaskPanel)); ts.IsBackground = true; ts.Priority = ThreadPriority.Normal; ts.Start(); } if (doShow != null) doShow(); BindParentEvent(_TargetForm, popup); }
public void ShowWindow(Control _TargetForm, Control _PopupForm, int width, int height, WindowStyle _WStyle, string title) { Hide(); PopupContent popup = new PopupContent(); popup.TargetControl = _TargetForm; popup.PopupControl = _PopupForm; popup.PType = PopupType.Window; popup.PStyle = PopupEvent.Custom; popup.WStyle = _WStyle; popup.Width = _PopupForm.Width; popup.Height = _PopupForm.Height; popup.IsMCHide = true;//点击隐藏 popup.WindowTitle = title; panelContainer.Tag = popup; if (width != -1) { popup.Width = width; } if (height != -1) { popup.Height = height; } panelContainer.Width = popup.Width; panelContainer.Height = popup.Height; if (popup.PopupControl is Form) { (popup.PopupControl as Form).TopLevel = false; (popup.PopupControl as Form).FormBorderStyle = FormBorderStyle.None; //(popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged); } if (popup.PType == PopupType.Window) { panelContainer.Padding = new Padding(2); panelContainer.Controls.Add(popup.PopupControl); panelContainer.Controls.Add(picTitle); picTitle.Height = 20; picTitle.Dock = DockStyle.Top; popup.PopupControl.Dock = DockStyle.Fill; rect_close = new Rectangle(panelContainer.Width - 22, 0, 20, 20); rect_titletext = new Rectangle(0, 0, panelContainer.Width - 50, 18); popup.PopupControl.Show(); } if (popup.WStyle == WindowStyle.Default) { SetPopupCenter(_TargetForm); panelContainer.Show(); if (popup.PopupControl is Form) { (popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged); } } else if (popup.WStyle == WindowStyle.Shadow) { SetPopupCenter(_TargetForm); panelContainer.Width = 0; panelContainer.Height = 0; Thread ts = new Thread(new ThreadStart(ShadowPanel)); ts.IsBackground = true; ts.Priority = ThreadPriority.Normal; ts.Start(); } else if (popup.WStyle == WindowStyle.Task) { SetPopupTask(_TargetForm); Thread ts = new Thread(new ThreadStart(TaskPanel)); ts.IsBackground = true; ts.Priority = ThreadPriority.Normal; ts.Start(); } if (doShow != null) { doShow(); } BindParentEvent(_TargetForm, popup); }
public void Show(Control _TargetControl, int width, int height) { Hide(); if (popupList.FindIndex(x => x.TargetControl.Equals(_TargetControl)) == -1) { throw new Exception("当前控件并没有设置弹出面板!"); } PopupContent popup = popupList.Find(x => x.TargetControl.Equals(_TargetControl)); panelContainer.Tag = popup; if (width != -1) { popup.Width = width; } if (height != -1) { popup.Height = height; } panelContainer.Width = popup.Width; panelContainer.Height = popup.Height; if (popup.PopupControl is Form) { (popup.PopupControl as Form).TopLevel = false; (popup.PopupControl as Form).FormBorderStyle = FormBorderStyle.None; //(popup.PopupControl as Form).VisibleChanged+=new EventHandler(Popup_VisibleChanged); } if (popup.PType == PopupType.Panel) { panelContainer.Padding = new Padding(0); panelContainer.Controls.Add(popup.PopupControl); popup.PopupControl.Dock = DockStyle.Fill; popup.PopupControl.Show(); SetPopupLocation(_TargetControl); //panelContainer.Show(); } else if (popup.PType == PopupType.Window) { panelContainer.Padding = new Padding(2); panelContainer.Controls.Add(popup.PopupControl); panelContainer.Controls.Add(picTitle); picTitle.Height = 20; picTitle.Dock = DockStyle.Top; popup.PopupControl.Dock = DockStyle.Fill; rect_close = new Rectangle(panelContainer.Width - 22, 0, 20, 20); popup.PopupControl.Show(); SetPopupCenter(_TargetControl); } if (popup.WStyle == WindowStyle.Default) { panelContainer.Show(); if (popup.PopupControl is Form) { (popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged); } } else if (popup.WStyle == WindowStyle.Shadow) { SetPopupCenter(_TargetControl); panelContainer.Width = 0; panelContainer.Height = 0; Thread ts = new Thread(new ThreadStart(ShadowPanel)); ts.IsBackground = true; ts.Priority = ThreadPriority.Normal; ts.Start(); } else if (popup.WStyle == WindowStyle.Task) { SetPopupTask(_TargetControl); Thread ts = new Thread(new ThreadStart(TaskPanel)); ts.IsBackground = true; ts.Priority = ThreadPriority.Normal; ts.Start(); } if (doShow != null) { doShow(); } BindParentEvent(_TargetControl, popup); }