Exemplo n.º 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left) //左键
            {
                bool flag = false;
                foreach (Control c in DesingerHost.Controls) //遍历控件容器 看是否选中其中某一控件
                {
                    Rectangle r = c.Bounds;
                    r = DesingerHost.RectangleToScreen(r);
                    r = this.RectangleToClient(r);
                    Rectangle rr = r;
                    rr.Inflate(10, 10);
                    if (rr.Contains(e.Location))
                    {
                        recter.Rect  = r;
                        _currentCtrl = c;

                        recter.IsForm = false;
                        flag          = true;
                        Invalidate2(false);
                        break;
                    }
                }
                if (!flag) //没有控件被选中,判断是否选中控件容器
                {
                    Rectangle r = DesingerHost.Bounds;
                    r = Parent.RectangleToScreen(r);
                    r = this.RectangleToClient(r);
                    if (r.Contains(e.Location))
                    {
                        recter.Rect   = r;
                        recter.IsForm = true;
                        _currentCtrl  = null;

                        Invalidate2(false);
                    }
                }
                DragType dt = recter.GetMouseDragType(e.Location);  //判断是否可以进行鼠标操作
                if (dt != DragType.None)
                {
                    _mouseDown  = true;
                    _firstPoint = e.Location;
                    _dragType   = dt;
                }
            }
            base.OnMouseDown(e);
        }
Exemplo n.º 2
0
        private void DesingerLayer_DragDrop(object sender, DragEventArgs e)
        {
            DataRow dr = (DataRow)e.Data.GetData(typeof(DataRow));

            TableDesingerHandler tableDesingerHandler = new TableDesingerHandler();

            DBSubPlugin.process(new DataRow[] { dr }, tableDesingerHandler);
            TableDesingerUI t = new TableDesingerUI();

            t.TableInfo = tableDesingerHandler.tableInfos[0];
            t.init();
            t.Location = DesingerHost.PointToClient(new Point(e.X, e.Y));
            DesingerHost.Controls.Add(t);
            t.BringToFront();
            _currentCtrl = t;
            Rectangle r = DesingerHost.RectangleToScreen(t.Bounds);

            recter.Rect = this.RectangleToClient(r);

            //recter.Rect = t.Bounds;
            Invalidate2(false);
        }