Example #1
0
        DropEffects IDropTarget.DragOver(HtmlMouseEvent e)
        {
            base.DragOver(e);
            if (Feedback == FeedbackMode.None)
            {
                return(DropEffects.None);
            }
            object node = HitNode;

            if (!Observable.Equals(this.node, node))
            {
                this.node   = node;
                dropEffects = DropEffects.None;
                if (listItems != null)
                {
                    ListNode list = node as ListNode;
                    if (list != null)
                    {
                        dropEffects = ListItemsDropUtility.DropEffects(listItems, list.RootFolder);
                    }
                    else
                    {
                        FolderNode folder = node as FolderNode;
                        if (folder != null)
                        {
                            dropEffects = ListItemsDropUtility.DropEffects(listItems, folder);
                        }
                    }
                }
            }

            return(dropEffects & DropEffects.Move);
        }
 void IDropTarget.Drop(HtmlMouseEvent e, DropEffects dropEffect)
 {
     try
     {
         base.Drop(e);
         ListItemsDropUtility.Drop(source, targetFolder != null ? targetFolder : itemsPane.Data.FolderItems.ParentFolder);
     }
     catch (Exception ex)
     {
         LazyWindow.ShowError(ex);
     }
 }
Example #3
0
        void IDropTarget.Drop(HtmlMouseEvent e, DropEffects dropEffect)
        {
            TreeViewHit hit = base.Drop(e);

            if (Feedback != FeedbackMode.None)
            {
                try
                {
                    object   node = hit.Nodes.List[hit.Index];
                    ListNode list = node as ListNode;
                    ListItemsDropUtility.Drop(listItems, list != null ? list.RootFolder : node as Folder);
                }
                catch (Exception ex)
                {
                    LazyWindow.ShowError(ex);
                }
            }
        }
        void IDropTarget.Drop(HtmlMouseEvent e, DropEffects dropEffect)
        {
            RootNodes rootNodes = (RootNodes)treeView.NodeSource;
            RootNode  rootNode  = webNode.RootNode;
            long      index     = hit != null ? hit.Index : -1;

            if (index >= 0 && 2 * (clientY - hit.Rect.Top) >= hit.Rect.Height)
            {
                index++;
            }

            if (dropEffect == DropEffects.Move)
            {
                int pos = 0;
                while (rootNodes[pos] != rootNode)
                {
                    pos++;
                }

                rootNodes.RemoveRootNode(pos);
                if (index > pos)
                {
                    index--;
                }
            }
            else
            {
                rootNode = new RootNode()
                {
                    Url = webNode.Url, Title = webNode.Title, IsSite = rootNode != null && rootNode.IsSite, RootNodes = rootNodes
                };
            }

            if (index >= 0)
            {
                rootNodes.InsertRootNode(index, rootNode);
            }
            else
            {
                rootNodes.Configuration.Roots.Add(rootNode);
            }
        }
Example #5
0
        internal ListItemsDragSource(IList <ListItem> listItems)
        {
            this.listItems = listItems;
            dropEffects    = DropEffects.Copy | DropEffects.Link;
            int i = 0;

            for (; i < listItems.Count; i++)
            {
                ListItem listItem = listItems[i];
                if ((listItem.EffectiveBasePermissions & BasePermissions.DeleteListItems) != BasePermissions.DeleteListItems ||
                    (listItem.EffectiveBasePermissions & BasePermissions.EditListItems) != BasePermissions.EditListItems)
                {
                    break;
                }
            }

            if (i == listItems.Count)
            {
                dropEffects |= DropEffects.Move;
            }
        }
        /// <summary>
        /// Called as soon as the mouse drags an item over a new hierarchy or hierarchy window
        /// </summary>
        /// <param name="dataObject">reference to interface IDataObject of the item being dragged</param>
        /// <param name="keyState">Current state of the keyboard and the mouse modifier keys. See docs for a list of possible values</param>
        /// <param name="itemId">Item identifier for the item currently being dragged</param>
        /// <param name="effect">On entry, a pointer to the current DropEffect. On return, must contain the new valid DropEffect</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
        public override int DragEnter(IOleDataObject dataObject, uint keyState, uint itemId, ref DropEffects effect)
        {
            effect = DropEffects.None;

            if(this.SourceDraggedOrCutOrCopied)
            {
                return VSConstants.S_OK;
            }

            this._dropDataType = QueryDropDataType(dataObject);
            if(this._dropDataType != DropDataType.None)
            {
                effect = this.QueryDropEffect(this._dropDataType, keyState);
            }

            return VSConstants.S_OK;
        }
 internal ItemsOverviewDropTarget(ItemsPane itemsPane, IList <ListItem> source) : base(itemsPane.Overview)
 {
     this.itemsPane = itemsPane;
     this.source    = source;
     dropEffects    = ListItemsDropUtility.DropEffects(source, itemsPane.Data.FolderItems.ParentFolder);
 }
        /// <summary>
        /// Called after your cut/copied items has been pasted
        /// </summary>
        ///<param name="wasCut">If true, then the IDataObject has been successfully pasted into a target hierarchy. 
        /// If false, then the cut or copy operation was cancelled.</param>
        /// <param name="dropEffect">Visual effects associated with the drag and drop operation, such as cursors, bitmaps, and so on. 
        /// These should be the same visual effects used in OnDropNotify</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
        public virtual int OnPaste(bool wasCut, DropEffects dropEffect)
        {
            if(!this.SourceDraggedOrCutOrCopied)
            {
                return VSConstants.S_FALSE;
            }

            if(dropEffect == DropEffects.None)
            {
                return OnClear(wasCut);
            }

            this.CleanupSelectionDataObject(false, wasCut, dropEffect == DropEffects.Move);
            this.SourceDraggedOrCutOrCopied = false;
            return VSConstants.S_OK;
        }
        /// <summary>
        /// Notifies clients that the dragged item was dropped. 
        /// </summary>
        /// <param name="dropped">If true, then the dragged item was dropped on the target. If false, then the drop did not occur.</param>
        /// <param name="effect">Visual effects associated with the drag-and-drop operation, such as cursors, bitmaps, and so on. 
        /// The value of dwEffects passed to the source object via OnDropNotify method is the value of pdwEffects returned by Drop method.</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
        public override int OnDropNotify(bool dropped, DropEffects effect)
        {
            if(!this.SourceDraggedOrCutOrCopied)
            {
                return VSConstants.S_FALSE;
            }

            this.CleanupSelectionDataObject(dropped, false, effect == DropEffects.Move);

            this.SourceDraggedOrCutOrCopied = false;

            return VSConstants.S_OK;
        }
        /// <summary>
        /// Allows the drag source to prompt to save unsaved items being dropped. 
        /// Notifies the source hierarchy that information dragged from it is about to be dropped on a target. 
        /// This method is called immediately after the mouse button is released on a drop. 
        /// </summary>
        /// <param name="dataObject">Reference to the IDataObject interface on the item being dragged. 
        /// This data object contains the data being transferred in the drag-and-drop operation. 
        /// If the drop occurs, then this data object (item) is incorporated into the hierarchy window of the new hierarchy.</param>
        /// <param name="effect">Current state of the keyboard and the mouse modifier keys.</param>
        /// <param name="cancelDrop">If true, then the drop is cancelled by the source hierarchy. If false, then the drop can continue.</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
        public override int OnBeforeDropNotify(IOleDataObject dataObject, DropEffects effect, out bool cancelDrop)
        {
            // If there is nothing to be dropped just return that drop should be cancelled.
            if(this.ItemsDraggedOrCutOrCopied == null)
            {
                cancelDrop = true;
                return VSConstants.S_OK;
            }

            cancelDrop = false;
            bool dirty = false;
            foreach(HierarchyNode node in this.ItemsDraggedOrCutOrCopied)
            {
                bool isDirty, isOpen, isOpenedByUs;
                uint docCookie;
                IVsPersistDocData ppIVsPersistDocData;
                DocumentManager manager = node.GetDocumentManager();
                if(manager != null)
                {
                    manager.GetDocInfo(out isOpen, out isDirty, out isOpenedByUs, out docCookie, out ppIVsPersistDocData);
                    if(isDirty && isOpenedByUs)
                    {
                        dirty = true;
                        break;
                    }
                }
            }

            // if there are no dirty docs we are ok to proceed
            if(!dirty)
            {
                return VSConstants.S_OK;
            }

            // Prompt to save if there are dirty docs
            string message = SR.GetString(SR.SaveModifiedDocuments, CultureInfo.CurrentUICulture);
            string title = string.Empty;
            OLEMSGICON icon = OLEMSGICON.OLEMSGICON_WARNING;
            OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL;
            OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
            int result = VsShellUtilities.ShowMessageBox(Site, title, message, icon, buttons, defaultButton);
            switch(result)
            {
                case DialogResult.Yes:
                    break;

                case DialogResult.No:
                    return VSConstants.S_OK;

                case DialogResult.Cancel: goto default;

                default:
                    cancelDrop = true;
                    return VSConstants.S_OK;
            }

            // Save all dirty documents
            foreach(HierarchyNode node in this.ItemsDraggedOrCutOrCopied)
            {
                DocumentManager manager = node.GetDocumentManager();
                if(manager != null)
                {
                    manager.Save(true);
                }
            }

            return VSConstants.S_OK;
        }
        /// <summary>
        /// This is overridden to handle drop operations correctly in a help file builder project
        /// </summary>
        /// <inheritdoc />
        public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref DropEffects pdwEffect)
        {
            DropDataType dropDataType = DropDataType.None;

            if (pDataObject == null)
            {
                return(VSConstants.E_INVALIDARG);
            }

            pdwEffect = DropEffects.None;

            // If the source is within the project, let the base class handle it
            if (this.SourceDraggedOrCutOrCopied)
            {
                return(base.Drop(pDataObject, grfKeyState, itemid, ref pdwEffect));
            }

            // Get the node that is being dragged over and ask it which node should handle this call
            HierarchyNode targetNode = NodeFromItemId(itemid);

            if (targetNode == null)
            {
                return(VSConstants.S_FALSE);
            }

            targetNode = targetNode.GetDragTargetHandlerNode();

            dropDataType = this.HandleSelectionDataObject(pDataObject, targetNode);

            // Since we can get a mix of files that may not necessarily be moved into the project (i.e.
            // documentation sources and references), we'll always act as if they were copied.
            pdwEffect = DropEffects.Copy;

            return((dropDataType != DropDataType.Shell) ? VSConstants.E_FAIL : VSConstants.S_OK);
        }
Example #12
0
 public Task <IEnumerable <ICopyPasteItem> > ProcessDataObjectAsync(object dataObject, IProjectTree dropTarget, IProjectTreeProvider currentProvider, DropEffects effect)
 {
     _dropTarget = dropTarget;
     return(PasteProcessor.ProcessDataObjectAsync(dataObject, dropTarget, currentProvider, effect));
 }
Example #13
0
 public bool PromptForAnyOverwrites(IEnumerable <ICopyPasteItem> items, ref DropEffects effect)
 {
     return(PasteHandler.PromptForAnyOverwrites(items, ref effect));
 }
Example #14
0
        public async Task <PasteItemsResult> PasteItemsAsync(IEnumerable <ICopyPasteItem> items, DropEffects effect)
        {
            Assumes.NotNull(_dropTarget);

            ImmutableHashSet <string> previousIncludes = await OrderingHelper.GetAllEvaluatedIncludes(_configuredProject, _accessor);

            PasteItemsResult result = await PasteHandler.PasteItemsAsync(items, effect);

            await OrderingHelper.Move(_configuredProject, _accessor, previousIncludes, _dropTarget !, OrderingMoveAction.MoveToTop);

            return(result);
        }
Example #15
0
 void IDragSource.Complete(DropEffects dropEffects)
 {
 }
        /// <summary>
        /// This is overridden to handle drop operations correctly in a help file builder project
        /// </summary>
        /// <inheritdoc />
        public override int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref DropEffects pdwEffect)
        {
            DropDataType dropDataType = DropDataType.None;

            if(pDataObject == null)
                return VSConstants.E_INVALIDARG;

            pdwEffect = DropEffects.None;

            // If the source is within the project, let the base class handle it
            if(this.SourceDraggedOrCutOrCopied)
                return base.Drop(pDataObject, grfKeyState, itemid, ref pdwEffect);

            // Get the node that is being dragged over and ask it which node should handle this call
            HierarchyNode targetNode = NodeFromItemId(itemid);

            if(targetNode == null)
                return VSConstants.S_FALSE;

            targetNode = targetNode.GetDragTargetHandlerNode();

            dropDataType = this.HandleSelectionDataObject(pDataObject, targetNode);

            // Since we can get a mix of files that may not necessarily be moved into the project (i.e.
            // documentation sources and references), we'll always act as if they were copied.
            pdwEffect = DropEffects.Copy;

            return (dropDataType != DropDataType.Shell) ? VSConstants.E_FAIL : VSConstants.S_OK;
        }
Example #17
0
        async Task <IEnumerable <ICopyPasteItem> > IPasteDataObjectProcessor.ProcessDataObjectAsync(object dataObject, IProjectTree dropTarget, IProjectTreeProvider currentProvider, DropEffects effect)
        {
            var pasteItems = await _underlyingProcessor.ProcessDataObjectAsync(dataObject, dropTarget, currentProvider, effect);

            // For some reason, the default system paste processor (Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.WindowsPasteProcessor)
            // completely ignores DropEffects.Link, so we set IsLinked and LinkPath manually.
            if (effect == DropEffects.Link)
            {
                foreach (var item in pasteItems)
                {
                    var sourceProp   = item.GetType().GetProperty("Source");
                    var isLinkedProp = item.GetType().GetProperty("IsLinked");
                    var linkPathProp = item.GetType().GetProperty("LinkPath");
                    if (sourceProp != null && isLinkedProp != null && linkPathProp != null)
                    {
                        var sourcePath = (string)sourceProp.GetValue(item);
                        var linkName   = Path.GetFileName(sourcePath);

                        isLinkedProp.SetValue(item, true);
                        linkPathProp.SetValue(item, linkName);
                    }
                }
            }
            return(pasteItems);
        }
Example #18
0
 public virtual void OnDrop()
 {
     DropEffects.Run(Carrier, Context);
 }
Example #19
0
        public async Task <PasteItemsResult> PasteItemsAsync(IEnumerable <ICopyPasteItem> items, DropEffects effect)
        {
            Assumes.NotNull(_dropTarget);

            // ConfigureAwait is true because we need to come back for PasteItemsAsync to work. If not, PasteItemsAsync will throw.
            ImmutableHashSet <string> previousIncludes = await OrderingHelper.GetAllEvaluatedIncludes(_configuredProject, _accessor).ConfigureAwait(true);

            PasteItemsResult result = await PasteHandler.PasteItemsAsync(items, effect).ConfigureAwait(false);

            await OrderingHelper.Move(_configuredProject, _accessor, previousIncludes, _dropTarget, OrderingMoveAction.MoveToTop).ConfigureAwait(false);

            return(result);
        }
        /// <summary>
        /// Called when one or more items are dragged over the target hierarchy or hierarchy window. 
        /// </summary>
        /// <param name="keyState">Current state of the keyboard keys and the mouse modifier buttons. See <seealso cref="IVsHierarchyDropDataTarget"/></param>
        /// <param name="itemId">Item identifier of the drop data target over which the item is being dragged</param>
        /// <param name="effect"> On entry, reference to the value of the pdwEffect parameter of the IVsHierarchy object, identifying all effects that the hierarchy supports. 
        /// On return, the pdwEffect parameter must contain one of the effect flags that indicate the result of the drop operation. For a list of pwdEffects values, see <seealso cref="DragEnter"/></param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
        public override int DragOver(uint keyState, uint itemId, ref DropEffects effect)
        {
            effect = (uint)DropEffects.None;

            // Dragging items to a project that is being debugged is not supported
            // (see VSWhidbey 144785)
            DBGMODE dbgMode = VsShellUtilities.GetDebugMode(this.Site) & ~DBGMODE.DBGMODE_EncMask;
            if(dbgMode == DBGMODE.DBGMODE_Run || dbgMode == DBGMODE.DBGMODE_Break)
            {
                return VSConstants.S_OK;
            }

            if(this.isClosed || this._site == null)
            {
                return VSConstants.E_UNEXPECTED;
            }

            // We should also analyze if the node being dragged over can accept the drop.
            if(!this.CanTargetNodeAcceptDrop(itemId))
            {
                return VSConstants.E_NOTIMPL;
            }

            if(this._dropDataType != DropDataType.None)
            {
                effect = this.QueryDropEffect(this._dropDataType, keyState);
            }

            return VSConstants.S_OK;
        }
Example #21
0
 public Task <IEnumerable <string> > ValidateItemListAsync(IEnumerable <ICopyPasteItem> items, DropEffects effect)
 {
     return(PasteHandler.ValidateItemListAsync(items, effect));
 }
        /// <summary>
        /// Called when one or more items are dropped into the target hierarchy or hierarchy window when the mouse button is released.
        /// </summary>
        /// <param name="dataObject">Reference to the IDataObject interface on the item being dragged. This data object contains the data being transferred in the drag-and-drop operation. 
        /// If the drop occurs, then this data object (item) is incorporated into the target hierarchy or hierarchy window.</param>
        /// <param name="keyState">Current state of the keyboard and the mouse modifier keys. See <seealso cref="IVsHierarchyDropDataTarget"/></param>
        /// <param name="itemId">Item identifier of the drop data target over which the item is being dragged</param>
        /// <param name="effect">Visual effects associated with the drag-and drop-operation, such as a cursor, bitmap, and so on. 
        /// The value of dwEffects passed to the source object via the OnDropNotify method is the value of pdwEffects returned by the Drop method</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
        public override int Drop(IOleDataObject dataObject, uint keyState, uint itemId, ref DropEffects effect)
        {
            if(dataObject == null)
            {
                return VSConstants.E_INVALIDARG;
            }

            effect = DropEffects.None;

            // Get the node that is being dragged over and ask it which node should handle this call
            HierarchyNode targetNode = NodeFromItemId(itemId);
            if(targetNode != null)
            {
                targetNode = targetNode.GetDragTargetHandlerNode();
            }
            else
            {
                // There is no target node. The drop can not be completed.
                return VSConstants.S_FALSE;
            }

            int returnValue;
            try
            {
                DropDataType dropDataType = DropDataType.None;
                dropDataType = ProcessSelectionDataObject(dataObject, targetNode);
                effect = this.QueryDropEffect(dropDataType, keyState);

                // If it is a drop from windows and we get any kind of error we return S_FALSE and dropeffect none. This
                // prevents bogus messages from the shell from being displayed
                returnValue = (dropDataType != DropDataType.Shell) ? VSConstants.E_FAIL : VSConstants.S_OK;
            }
            catch(System.IO.FileNotFoundException e)
            {
                Trace.WriteLine("Exception : " + e.Message);

                if(!Utilities.IsInAutomationFunction(this.Site))
                {
                    string message = e.Message;
                    string title = string.Empty;
                    OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL;
                    OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK;
                    OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
                    VsShellUtilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton);
                }

                returnValue = VSConstants.E_FAIL;
            }

            return returnValue;
        }
Example #23
0
 public void FilterItemList(IEnumerable <ICopyPasteItem> items, DropEffects effect)
 {
     PasteHandler.FilterItemList(items, effect);
 }
        /// <summary>
        /// Returns information about one or more of the items being dragged
        /// </summary>
        /// <param name="effects">Pointer to a DWORD value describing the effects displayed while the item is being dragged, 
        /// such as cursor icons that change during the drag-and-drop operation. 
        /// For example, if the item is dragged over an invalid target point 
        /// (such as the item's original location), the cursor icon changes to a circle with a line through it. 
        /// Similarly, if the item is dragged over a valid target point, the cursor icon changes to a file or folder.</param>
        /// <param name="dataObject">Pointer to the IDataObject interface on the item being dragged. 
        /// This data object contains the data being transferred in the drag-and-drop operation. 
        /// If the drop occurs, then this data object (item) is incorporated into the target hierarchy or hierarchy window.</param>
        /// <param name="dropSource">Pointer to the IDropSource interface of the item being dragged.</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
        public override int GetDropInfo(out DropEffects effects, out IOleDataObject dataObject, out IDropSource dropSource)
        {
            //init out params
            effects = (uint)DropEffects.None;
            dataObject = null;
            dropSource = null;

            IOleDataObject selectionDataObject = PackageSelectionDataObject(false);
            if(selectionDataObject == null)
            {
                return VSConstants.E_NOTIMPL;
            }

            this.SourceDraggedOrCutOrCopied = true;

            effects = DropEffects.Move | DropEffects.Copy;

            dataObject = selectionDataObject;
            return VSConstants.S_OK;
        }