Exemplo n.º 1
0
        private void GetDragState(ref bool isDragTarget, ref Point dragLocation, DragEventArgs args)
        {
            ElementDesignerData data = args.Data as ElementDesignerData;

            if (data != null)
            {
                object element =
                    _grid
                    [
                        ClientToGrid(PointToClient(new Point(args.X, args.Y)))
                    ];
                if (element == null)
                {
                    dragLocation = ClientToGrid(PointToClient(new Point(args.X, args.Y)));
                    isDragTarget = true;
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnDragDrop(DragEventArgs args)
        {
            base.OnDragDrop(args);

            SetDragState(false, Point.Empty);

            bool  isDragTarget = false;
            Point dragLocation = Point.Empty;

            GetDragState(ref isDragTarget, ref dragLocation, args);
            if (isDragTarget)
            {
                ElementDesignerData data = args.Data as ElementDesignerData;
                if (data != null)
                {
                    _grid[_grid.GetPosition(data.Element)] = null;
                    _grid[dragLocation] = data.Element;
                    UpdateRange();
                    UpdateDesigners(true);
                    UpdateScrollBars();
                    PerformLayout();
                }
            }
        }