123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace IMCS.Config
- {
- public class UserControlBase : UserControl
- {
- public short UserTag { get; set; }
- public DevExpress.XtraBars.PopupMenu popupMenu1;
- public delegate void Delegate_MouseDownTag(int value);
- public virtual event Delegate_MouseDownTag UserControlMouseDown;
- public delegate void Delegate_DragDropTag(int value);
- public virtual event Delegate_DragDropTag UserControlDragDropTag;
- public UserControlBase()
- {
- this.Load += (s, e) => { AllowDrop = true;
- };
- //this.MouseDown += (s, e) =>
- //{
- // UserControlBase userControl = s as UserControlBase;
- // if ((e.Button == System.Windows.Forms.MouseButtons.Left))
- // {
- // userControl.DoDragDrop(userControl, DragDropEffects.Copy | DragDropEffects.Move);
- // System.Console.WriteLine($"UserControlBase;=>{userControl.UserTag}");
- // //形成拖拽效果,移动+拷贝的组合效果
- // }
- //};
- //this.DragEnter += (s, e) =>
- //{
- // System.Console.WriteLine($"DragEnter--->UserControlBase--->>{UserTag}");
- // e.Effect = DragDropEffects.Copy;
- //};
- //this.DragDrop += (s, e) =>
- //{
- // System.Console.WriteLine($"DragDrop--->UserControlBase--->>{UserTag}");
- //};
- }
- public virtual void EventMoudeDown(int value)
- {
- if (UserControlMouseDown != null)
- {
- UserControlMouseDown(value);
- }
- }
- public virtual void EventMoudeDrag(int value)
- {
- if (UserControlDragDropTag != null)
- {
- UserControlDragDropTag(value);
- }
- }
- }
- public class LabelBase : Label
- {
- public short UserTag { get; set; }
- public LabelBase()
- {
- this.AllowDrop = true;
- this.MouseDown += (s, e) =>
- {
- LabelBase userControl = s as LabelBase;
- if ((e.Button == System.Windows.Forms.MouseButtons.Left))
- {
- userControl.DoDragDrop(userControl, DragDropEffects.Copy | DragDropEffects.Move);
- System.Console.WriteLine($"LabelBase;=>{userControl.Tag}");
- //形成拖拽效果,移动+拷贝的组合效果
- }
- };
- this.DragEnter += (s, e) =>
- {
- System.Console.WriteLine($"DragEnter--->LabelBase--->>{UserTag}");
- e.Effect = DragDropEffects.Copy;
- };
- //this.DragDrop += (s, e) =>
- //{
- // System.Console.WriteLine($"DragDrop--->LabelBase--->>{UserTag}");
- //};
- }
- }
- public class PanelBase : Panel
- {
- public short UserTag { get; set; }
- public PanelBase()
- {
- this.AllowDrop = true;
- this.MouseDown += (s, e) =>
- {
- PanelBase userControl = s as PanelBase;
- if ((e.Button == System.Windows.Forms.MouseButtons.Left))
- {
- userControl.DoDragDrop(userControl, DragDropEffects.Copy | DragDropEffects.Move);
- System.Console.WriteLine($"PanelBase;=>{userControl.Tag}");
- //形成拖拽效果,移动+拷贝的组合效果
- }
- };
- this.DragEnter += (s, e) =>
- {
- System.Console.WriteLine($"DragEnter--->PanelBase--->>{UserTag}");
- e.Effect = DragDropEffects.Copy;
- };
- //this.DragDrop += (s, e) =>
- //{
- // System.Console.WriteLine($"DragDrop--->PanelBase--->>{UserTag}");
- //};
- }
- }
- }
|