Пример #1
0
        public static bool AttemptVsFormat(HierarchyNode activeNode, ushort cfFormat, Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, uint grfKeyState, out DropDataType pddt)
        {
            pddt = DropDataType.None;
            FORMATETC fmtetc = new FORMATETC();

            fmtetc.cfFormat = cfFormat;
            fmtetc.ptd      = IntPtr.Zero;
            fmtetc.dwAspect = (uint)DVASPECT.DVASPECT_CONTENT;
            fmtetc.lindex   = -1;
            fmtetc.tymed    = (uint)TYMED.TYMED_HGLOBAL;

            bool hasData = false;

            try
            {
                QueryGetData(pDataObject, ref fmtetc);
                hasData = true;
            }
            catch
            {
            }

            if (hasData)
            {
                try
                {
                    STGMEDIUM stgmedium = GetData(pDataObject, ref fmtetc);
                    if (stgmedium.tymed == (uint)TYMED.TYMED_HGLOBAL)
                    {
                        IntPtr hDropInfo = stgmedium.unionmember;
                        if (hDropInfo != IntPtr.Zero)
                        {
                            pddt = DropDataType.VsRef;
                            try
                            {
                                activeNode.AddFiles(UtilGetFilesFromPROJITEMDrop(hDropInfo));
                            }
                            finally
                            {
                                Marshal.FreeHGlobal(hDropInfo);
                            }
                            return(true);
                        }
                    }
                }
                catch (Exception e)
                {
                    Trace.WriteLine("Exception:" + e.Message);
                }
                catch
                {
                    Trace.WriteLine("Exception");
                }
            }
            return(false);
        }