VsTeXProject.VisualStudio.Project.ProjectNode.PasteFromClipboard C# (CSharp) Method

PasteFromClipboard() protected method

Handle the Paste operation to a targetNode
protected PasteFromClipboard ( HierarchyNode targetNode ) : int
targetNode HierarchyNode
return int
        protected internal override int PasteFromClipboard(HierarchyNode targetNode)
        {
            var returnValue = (int) OleConstants.OLECMDERR_E_NOTSUPPORTED;

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

            //Get the clipboardhelper service and use it after processing dataobject
            var clipboardHelper = (IVsUIHierWinClipboardHelper) GetService(typeof (SVsUIHierWinClipboardHelper));
            if (clipboardHelper == null)
            {
                return VSConstants.E_FAIL;
            }

            try
            {
                //Get dataobject from clipboard
                IOleDataObject dataObject = null;
                ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out dataObject));
                if (dataObject == null)
                {
                    return VSConstants.E_UNEXPECTED;
                }

                var dropEffect = DropEffect.None;
                var dropDataType = DropDataType.None;
                try
                {
                    dropDataType = ProcessSelectionDataObject(dataObject, targetNode.GetDragTargetHandlerNode());
                    dropEffect = QueryDropEffect(dropDataType, 0);
                }
                catch (ExternalException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);

                    // If it is a drop from windows and we get any kind of error ignore it. This
                    // prevents bogus messages from the shell from being displayed
                    if (dropDataType != DropDataType.Shell)
                    {
                        throw;
                    }
                }
                finally
                {
                    // Inform VS (UiHierarchyWindow) of the paste
                    returnValue = clipboardHelper.Paste(dataObject, (uint) dropEffect);
                }
            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception : " + e.Message);

                returnValue = e.ErrorCode;
            }

            return returnValue;
        }
ProjectNode