Exemplo n.º 1
0
        /// <summary>
        /// Determines if the paste command should be allowed.
        /// </summary>
        /// <returns></returns>
        protected internal override bool AllowPasteCommand()
        {
            IOleDataObject dataObject = null;

            try
            {
                ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out dataObject));
                if (dataObject == null)
                {
                    return(false);
                }

                // First see if this is a set of storage based items
                FORMATETC format = DragDropHelper.CreateFormatEtc((ushort)DragDropHelper.CF_VSSTGPROJECTITEMS);
                if (dataObject.QueryGetData(new FORMATETC[] { format }) == VSConstants.S_OK)
                {
                    return(true);
                }
                // Try reference based items
                format = DragDropHelper.CreateFormatEtc((ushort)DragDropHelper.CF_VSREFPROJECTITEMS);
                if (dataObject.QueryGetData(new FORMATETC[] { format }) == VSConstants.S_OK)
                {
                    return(true);
                }
                // Try windows explorer files format
                format = DragDropHelper.CreateFormatEtc((ushort)NativeMethods.CF_HDROP);
                return(dataObject.QueryGetData(new FORMATETC[] { format }) == VSConstants.S_OK);
            }
            // We catch External exceptions since it might be that it is not our data on the clipboard.
            catch (ExternalException e)
            {
                Trace.WriteLine("Exception :" + e.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        int OleInterop.IDataObject.QueryGetData(OleInterop.FORMATETC[] pFormatetc)
        {
            if (null != oleData)
            {
                return(oleData.QueryGetData(pFormatetc));
            }

            if ((null == pFormatetc) || (1 != pFormatetc.Length))
            {
                throw new ArgumentException();
            }

            BclComTypes.FORMATETC bclFormat = StructConverter.OleFormatETC2Bcl(ref pFormatetc[0]);
            return(bclData.QueryGetData(ref bclFormat));
        }
Exemplo n.º 3
0
 public static void QueryGetData(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, ref FORMATETC fmtetc)
 {
     FORMATETC[] af = new FORMATETC[1];
     af[0] = fmtetc;
     pDataObject.QueryGetData(af);
     fmtetc = af[0];
 }
Exemplo n.º 4
0
        public static int QueryGetData(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, ref FORMATETC fmtetc)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            int returnValue = VSConstants.E_FAIL;

            FORMATETC[] af = new FORMATETC[1];
            af[0] = fmtetc;
            try
            {
                int result = ErrorHandler.ThrowOnFailure(pDataObject.QueryGetData(af));
                if (result == VSConstants.S_OK)
                {
                    fmtetc      = af[0];
                    returnValue = VSConstants.S_OK;
                }
            }
            catch (COMException e)
            {
                // do not display exception. We see this also when trying to ask for a Clipboard operation
                // when the actual change was a drag/drop
                returnValue = e.ErrorCode;
            }

            return(returnValue);
        }
Exemplo n.º 5
0
        public static int QueryGetData(Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject, ref FORMATETC fmtetc)
        {
            if (dataObject == null)
            {
                throw new ArgumentNullException("dataObject");
            }

            int returnValue = VSConstants.E_FAIL;

            FORMATETC[] af = new FORMATETC[1];
            af[0] = fmtetc;
            try
            {
                int result = ErrorHandler.ThrowOnFailure(dataObject.QueryGetData(af));
                if (result == VSConstants.S_OK)
                {
                    fmtetc      = af[0];
                    returnValue = VSConstants.S_OK;
                }
            }
            catch (COMException e)
            {
                Trace.WriteLine("COMException : " + e.Message);
                returnValue = e.ErrorCode;
            }

            return(returnValue);
        }
Exemplo n.º 6
0
        public static int QueryGetData(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, ref FORMATETC fmtetc)
        {
            FORMATETC[] af = new FORMATETC[1];
            af[0] = fmtetc;
            int hr = pDataObject.QueryGetData(af);

            fmtetc = af[0];
            return(hr);
        }
        public static int QueryGetData(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, ref FORMATETC fmtetc)
        {
            FORMATETC[] af = new FORMATETC[1];
            af[0] = fmtetc;
            int result = pDataObject.QueryGetData(af);

            if (result == VSConstants.S_OK)
            {
                fmtetc = af[0];
                return(VSConstants.S_OK);
            }
            return(result);
        }
Exemplo n.º 8
0
        public static int QueryGetData(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, ref FORMATETC fmtetc)
        {
            int returnValue = VSConstants.E_FAIL;

            FORMATETC[] af = new FORMATETC[1];
            af[0] = fmtetc;
            try
            {
                int result = ErrorHandler.ThrowOnFailure(pDataObject.QueryGetData(af));
                if (result == VSConstants.S_OK)
                {
                    fmtetc      = af[0];
                    returnValue = VSConstants.S_OK;
                }
            }
            catch (COMException e)
            {
                XSharpProjectPackage.Instance.DisplayException(e);
                returnValue = e.ErrorCode;
            }

            return(returnValue);
        }