Example #1
0
        void ISectionHost.DoDragDropOperation(Section sectionToDrag)
        {
            _draggingSections = sectionToDrag.GetExpandedDragList();
            object[] data = sectionToDrag.GetDragObjects();

            _imageWindowOffX = sectionToDrag.HostBasedRectangle.X - CursorClientPosition.X;
            _imageWindowOffY = sectionToDrag.HostBasedRectangle.Y - CursorClientPosition.Y;

            _imageWindow = CreateDragImageWindow(_draggingSections, data.Length != _draggingSections.Length);

            if (DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Move) == DragDropEffects.None)
            {
                Point cursorPos = PointToClient(Cursor.Position);
                if (_lastDragAction == DragAction.Drop)
                {
                    Rectangle rc = Rectangle.Empty;
                    foreach (Section s in _draggingSections)
                    {
                        if (rc == Rectangle.Empty)
                        {
                            rc = s.HostBasedRectangle;
                        }
                        else
                        {
                            rc = Rectangle.Union(rc, s.HostBasedRectangle);
                        }
                    }
                    foreach (Section s in _draggingSections)
                    {
                        if (s.CanDropInVoid && !rc.Contains(cursorPos))
                        {
                            s.DroppedInVoid();
                        }
                    }
                }
            }
            FinishDropOperation();
        }
        void ISectionHost.DoDragDropOperation( Section sectionToDrag )
        {
            _draggingSections = sectionToDrag.GetExpandedDragList();
            object[] data = sectionToDrag.GetDragObjects();

            _imageWindowOffX = sectionToDrag.HostBasedRectangle.X - CursorClientPosition.X;
            _imageWindowOffY = sectionToDrag.HostBasedRectangle.Y - CursorClientPosition.Y;

            _imageWindow = CreateDragImageWindow( _draggingSections, data.Length != _draggingSections.Length );

            if( DoDragDrop( data, DragDropEffects.Copy | DragDropEffects.Move ) == DragDropEffects.None )
            {
                Point cursorPos = PointToClient( Cursor.Position );
                if( _lastDragAction == DragAction.Drop )
                {
                    Rectangle rc = Rectangle.Empty;
                    foreach( Section s in _draggingSections )
                    {
                        if( rc == Rectangle.Empty )
                        {
                            rc = s.HostBasedRectangle;
                        }
                        else
                        {
                            rc = Rectangle.Union( rc, s.HostBasedRectangle );
                        }
                    }
                    foreach( Section s in _draggingSections )
                    {
                        if( s.CanDropInVoid && !rc.Contains( cursorPos ) )
                        {
                            s.DroppedInVoid();
                        }
                    }
                }
            }
            FinishDropOperation();
        }