Exemplo n.º 1
0
        public int DragEnter(IntPtr pDataObj, NativeShellAPI.MK grfKeyState, NativeShellAPI.POINT pt, ref DragDropEffects pdwEffect)
        {
            mouseButtons = grfKeyState;
            startEffects = pdwEffect;

            br.FileView.Focus();
            br.SelectionChange = false;
            ReleaseCom();

            dropDataObject = pDataObj;

            #region Get DropItem
            Point point = br.FileView.PointToClient(new Point(pt.x, pt.y));
            ListViewHitTestInfo hitTest = br.FileView.HitTest(point);
            if (hitTest.Item != null &&
                (br.FileView.View != View.Details || hitTest.SubItem == null || hitTest.Item.Name == hitTest.SubItem.Name) &&
                (hitTest.Location == ListViewHitTestLocations.Image ||
                 hitTest.Location == ListViewHitTestLocations.Label ||
                 hitTest.Location == ListViewHitTestLocations.StateImage))
            {
                dropListItem = hitTest.Item;

                wasSelected           = dropListItem.Selected;
                dropListItem.Selected = true;

                ShellItem item = (ShellItem)dropListItem.Tag;
                parentDropItem = item;

                ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget);
            }
            else
            {
                dropListItem   = null;
                parentDropItem = br.CurrentDirectory;
                ShellHelper.GetIDropTarget(br.CurrentDirectory, out dropTargetPtr, out dropTarget);
            }
            #endregion

            if (dropTarget != null)
            {
                dropTarget.DragEnter(pDataObj, grfKeyState, pt, ref pdwEffect);
            }

            if (dropHelper != null)
            {
                dropHelper.DragEnter(br.Handle, pDataObj, ref pt, pdwEffect);
            }

            return(NativeShellAPI.S_OK);
        }
Exemplo n.º 2
0
        public int DragEnter(IntPtr pDataObj, NativeShellAPI.MK grfKeyState, NativeShellAPI.POINT pt, ref DragDropEffects pdwEffect)
        {
            mouseButtons = grfKeyState;

            br.FolderView.Focus();
            br.SelectionChange = false;
            lastSelectedNode   = br.FolderView.SelectedNode;

            ReleaseCom();

            dropDataObject = pDataObj;

            #region Get DropItem

            Point point = br.FolderView.PointToClient(new Point(pt.x, pt.y));
            TreeViewHitTestInfo hitTest = br.FolderView.HitTest(point);

            dropNode = hitTest.Node;
            br.FolderView.SelectedNode = dropNode;

            if (dropNode != null)
            {
                ShellItem item = (ShellItem)dropNode.Tag;
                parentDropItem = item;

                if (ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget))
                {
                    dropTarget.DragEnter(pDataObj, grfKeyState, pt, ref pdwEffect);
                }
            }

            #endregion

            if (dropHelper != null)
            {
                dropHelper.DragEnter(br.Handle, pDataObj, ref pt, pdwEffect);
            }

            return(NativeShellAPI.S_OK);
        }
Exemplo n.º 3
0
 public int QueryContinueDrag(bool fEscapePressed, NativeShellAPI.MK grfKeyState)
 {
     if (fEscapePressed)
     {
         return(NativeShellAPI.DRAGDROP_S_CANCEL);
     }
     else
     {
         if ((startButton & MouseButtons.Left) != 0 && (grfKeyState & NativeShellAPI.MK.LBUTTON) == 0)
         {
             return(NativeShellAPI.DRAGDROP_S_DROP);
         }
         else if ((startButton & MouseButtons.Right) != 0 && (grfKeyState & NativeShellAPI.MK.RBUTTON) == 0)
         {
             return(NativeShellAPI.DRAGDROP_S_DROP);
         }
         else
         {
             return(NativeShellAPI.S_OK);
         }
     }
 }
Exemplo n.º 4
0
        public int DragDrop(IntPtr pDataObj, NativeShellAPI.MK grfKeyState, NativeShellAPI.POINT pt, ref DragDropEffects pdwEffect)
        {
            OnDrop(new DropEventArgs(mouseButtons, br.FileView));

            if (!((mouseButtons & NativeShellAPI.MK.RBUTTON) != 0 ||
                  grfKeyState == NativeShellAPI.MK.CONTROL ||
                  grfKeyState == NativeShellAPI.MK.ALT ||
                  grfKeyState == (NativeShellAPI.MK.CONTROL | NativeShellAPI.MK.SHIFT)) && ShellItem.Equals(parentDragItem, parentDropItem))
            {
                ResetDrop();
                ReleaseCom();
                pdwEffect = DragDropEffects.None;

                if (dropHelper != null)
                {
                    dropHelper.Drop(pDataObj, ref pt, pdwEffect);
                }

                return(NativeShellAPI.S_OK);
            }

            ResetDrop();
            if (dropTarget != null)
            {
                dropTarget.DragDrop(pDataObj, grfKeyState, pt, ref pdwEffect);

                ReleaseCom();
                dropDataObject = IntPtr.Zero;
            }

            if (dropHelper != null)
            {
                dropHelper.Drop(pDataObj, ref pt, pdwEffect);
            }

            return(NativeShellAPI.S_OK);
        }
Exemplo n.º 5
0
 public DropEventArgs(NativeShellAPI.MK mouseButtons, Control dragStartControl)
 {
     this.mouseButtons     = mouseButtons;
     this.dragStartControl = dragStartControl;
 }
Exemplo n.º 6
0
        public int DragOver(NativeShellAPI.MK grfKeyState, NativeShellAPI.POINT pt, ref DragDropEffects pdwEffect)
        {
            bool reset = false;

            #region Get DropItem

            Point point = br.FileView.PointToClient(new Point(pt.x, pt.y));
            ListViewHitTestInfo hitTest = br.FileView.HitTest(point);
            if (hitTest.Item != null &&
                (br.FileView.View != View.Details || hitTest.SubItem == null || hitTest.Item.Name == hitTest.SubItem.Name) &&
                (hitTest.Location == ListViewHitTestLocations.Image ||
                 hitTest.Location == ListViewHitTestLocations.Label ||
                 hitTest.Location == ListViewHitTestLocations.StateImage))
            {
                if (!hitTest.Item.Equals(dropListItem))
                {
                    if (dropTarget != null)
                    {
                        dropTarget.DragLeave();
                    }

                    ReleaseCom();

                    if (dropListItem != null)
                    {
                        dropListItem.Selected = wasSelected;
                    }

                    dropListItem          = hitTest.Item;
                    wasSelected           = dropListItem.Selected;
                    dropListItem.Selected = true;

                    ShellItem item = (ShellItem)dropListItem.Tag;
                    parentDropItem = item;

                    ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget);
                    reset = true;
                }
            }
            else
            {
                if (dropListItem != null)
                {
                    if (dropTarget != null)
                    {
                        dropTarget.DragLeave();
                    }

                    ReleaseCom();

                    dropListItem.Selected = wasSelected;

                    dropListItem   = null;
                    parentDropItem = br.CurrentDirectory;

                    ShellHelper.GetIDropTarget(br.CurrentDirectory, out dropTargetPtr, out dropTarget);
                    reset = true;
                }
            }

            #endregion

            if (dropTarget != null)
            {
                if (reset)
                {
                    dropTarget.DragEnter(dropDataObject, grfKeyState, pt, ref pdwEffect);
                }
                else
                {
                    dropTarget.DragOver(grfKeyState, pt, ref pdwEffect);
                }
            }
            else
            {
                pdwEffect = DragDropEffects.None;
            }

            if (dropHelper != null)
            {
                dropHelper.DragOver(ref pt, pdwEffect);
            }

            return(NativeShellAPI.S_OK);
        }
Exemplo n.º 7
0
        public int DragOver(NativeShellAPI.MK grfKeyState, NativeShellAPI.POINT pt, ref DragDropEffects pdwEffect)
        {
            bool reset = false;

            #region Get DropItem

            Point point = br.FolderView.PointToClient(new Point(pt.x, pt.y));
            TreeViewHitTestInfo hitTest = br.FolderView.HitTest(point);
            if (!TreeNode.Equals(dropNode, hitTest.Node))
            {
                if (dropTarget != null)
                {
                    dropTarget.DragLeave();
                }

                ReleaseCom();

                dropNode = hitTest.Node;
                br.FolderView.SelectedNode = dropNode;

                if (dropNode == null)
                {
                    pdwEffect = DragDropEffects.None;

                    if (dropHelper != null)
                    {
                        dropHelper.DragOver(ref pt, pdwEffect);
                    }

                    return(NativeShellAPI.S_OK);
                }
                else
                {
                    ShellItem item = (ShellItem)dropNode.Tag;
                    parentDropItem = item;

                    ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget);
                    reset = true;
                }
            }
            else if (dropNode == null)
            {
                if (dropTarget != null)
                {
                    dropTarget.DragLeave();
                }

                ReleaseCom();

                dropNode = null;
                br.CurrentDirectoryNode = null;

                pdwEffect = DragDropEffects.None;

                if (dropHelper != null)
                {
                    dropHelper.DragOver(ref pt, pdwEffect);
                }

                return(NativeShellAPI.S_OK);
            }

            #endregion

            if (dropTarget != null)
            {
                if (reset)
                {
                    dropTarget.DragEnter(dropDataObject, grfKeyState, pt, ref pdwEffect);
                }
                else
                {
                    dropTarget.DragOver(grfKeyState, pt, ref pdwEffect);
                }
            }
            else
            {
                pdwEffect = DragDropEffects.None;
            }

            if (dropHelper != null)
            {
                dropHelper.DragOver(ref pt, pdwEffect);
            }

            return(NativeShellAPI.S_OK);
        }
Exemplo n.º 8
0
 public DropEventArgs(NativeShellAPI.MK mouseButtons, Control dragStartControl)
 {
     this.mouseButtons = mouseButtons;
     this.dragStartControl = dragStartControl;
 }
Exemplo n.º 9
0
        public int DragEnter(IntPtr pDataObj, NativeShellAPI.MK grfKeyState, NativeShellAPI.POINT pt, ref DragDropEffects pdwEffect)
        {
            mouseButtons = grfKeyState;
            startEffects = pdwEffect;

            br.FileView.Focus();
            br.SelectionChange = false;
            ReleaseCom();

            dropDataObject = pDataObj;

            #region Get DropItem
            Point point = br.FileView.PointToClient(new Point(pt.x, pt.y));
            ListViewHitTestInfo hitTest = br.FileView.HitTest(point);
            if (hitTest.Item != null &&
                (br.FileView.View != View.Details || hitTest.SubItem == null || hitTest.Item.Name == hitTest.SubItem.Name) &&
                (hitTest.Location == ListViewHitTestLocations.Image ||
                 hitTest.Location == ListViewHitTestLocations.Label ||
                 hitTest.Location == ListViewHitTestLocations.StateImage))
            {
                dropListItem = hitTest.Item;

                wasSelected = dropListItem.Selected;
                dropListItem.Selected = true;

                ShellItem item = (ShellItem)dropListItem.Tag;
                parentDropItem = item;

                ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget);
            }
            else
            {
                dropListItem = null;
                parentDropItem = br.CurrentDirectory;
                ShellHelper.GetIDropTarget(br.CurrentDirectory, out dropTargetPtr, out dropTarget);
            }
            #endregion

            if (dropTarget != null)
                dropTarget.DragEnter(pDataObj, grfKeyState, pt, ref pdwEffect);

            if (dropHelper != null)
                dropHelper.DragEnter(br.Handle, pDataObj, ref pt, pdwEffect);

            return NativeShellAPI.S_OK;
        }
Exemplo n.º 10
0
        public int DragEnter(IntPtr pDataObj, NativeShellAPI.MK grfKeyState, NativeShellAPI.POINT pt, ref DragDropEffects pdwEffect)
        {
            mouseButtons = grfKeyState;

            br.FolderView.Focus();
            br.SelectionChange = false;
            lastSelectedNode = br.FolderView.SelectedNode;

            ReleaseCom();

            dropDataObject = pDataObj;

            #region Get DropItem

            Point point = br.FolderView.PointToClient(new Point(pt.x, pt.y));
            TreeViewHitTestInfo hitTest = br.FolderView.HitTest(point);

            dropNode = hitTest.Node;
            br.FolderView.SelectedNode = dropNode;

            if (dropNode != null)
            {
                ShellItem item = (ShellItem)dropNode.Tag;
                parentDropItem = item;

                if (ShellHelper.GetIDropTarget(item, out dropTargetPtr, out dropTarget))
                {
                    dropTarget.DragEnter(pDataObj, grfKeyState, pt, ref pdwEffect);
                }
            }

            #endregion

            if (dropHelper != null)
                dropHelper.DragEnter(br.Handle, pDataObj, ref pt, pdwEffect);

            return NativeShellAPI.S_OK;
        }