Пример #1
0
        void PerformDragDrop(MouseEventArgs e, Point ptMouse)
        {
            // Remember what mi are selected. We may be deleting this if this is a move operation

            ArrayList alsmiSelected = m_lvld.Selection;

            IMapItem[] amiMove = (IMapItem[])alsmiSelected.ToArray(typeof(IMapItem));

            // Prepare a data object for drag drop

            LevelData ldat = PrepareLevelData(ptMouse.X, ptMouse.Y, GetTileSize(), (IMapItem[])alsmiSelected.ToArray(typeof(IMapItem)));

            // Normal operation is a move unless control key is press in which case it is
            // a copy

            DragDropEffects eff = DragDropEffects.Move;

            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
            {
                eff = DragDropEffects.Copy;
            }

            // Perform the drag drop. If it was cancelled, nothing to do.

            DragDropEffects effActual = DoDragDrop(ldat, eff);

            if (effActual == DragDropEffects.None)
            {
                return;
            }

            // If a move actually did occur, then remove the originals

            if ((effActual & DragDropEffects.Move) != 0)
            {
                m_lvld.RemoveMapItems(amiMove);
            }
        }