コード例 #1
0
 internal EnumFORMATETC(BclComTypes.IEnumFORMATETC bclEnum)
 {
     if (null == bclEnum)
     {
         throw new ArgumentNullException("System.Runtime.InteropServices.ComTypes.IEnumFORMATETC");
     }
     this.oleEnum = bclEnum as OleInterop.IEnumFORMATETC;
     this.bclEnum = bclEnum;
 }
コード例 #2
0
 internal EnumFORMATETC(OleInterop.IEnumFORMATETC oleEnum)
 {
     if (null == oleEnum)
     {
         throw new ArgumentNullException("Microsoft.VisualStudio.OLE.Interop.IEnumFORMATETC");
     }
     this.oleEnum = oleEnum;
     this.bclEnum = oleEnum as BclComTypes.IEnumFORMATETC;
 }
コード例 #3
0
 void BclComTypes.IEnumFORMATETC.Clone(out BclComTypes.IEnumFORMATETC newEnum)
 {
     newEnum = null;
     if (null != bclEnum)
     {
         bclEnum.Clone(out newEnum);
     }
     else
     {
         OleInterop.IEnumFORMATETC oleCloned;
         oleEnum.Clone(out oleCloned);
         newEnum = oleCloned as BclComTypes.IEnumFORMATETC;
         if (null == newEnum)
         {
             newEnum = (BclComTypes.IEnumFORMATETC)(new EnumFORMATETC(oleCloned));
         }
     }
 }
コード例 #4
0
        BclComTypes.IEnumFORMATETC BclComTypes.IDataObject.EnumFormatEtc(BclComTypes.DATADIR direction)
        {
            if (bclData != null)
            {
                return(bclData.EnumFormatEtc(direction));
            }

            OleInterop.IEnumFORMATETC oleEnum;
            NativeMethods.ThrowOnFailure(oleData.EnumFormatEtc((uint)direction, out oleEnum));
            if (null == oleEnum)
            {
                return(null);
            }
            BclComTypes.IEnumFORMATETC bclEnum = oleEnum as BclComTypes.IEnumFORMATETC;
            if (null == bclEnum)
            {
                bclEnum = (BclComTypes.IEnumFORMATETC)(new EnumFORMATETC(oleEnum));
            }
            return(bclEnum);
        }
コード例 #5
0
        int OleInterop.IDataObject.EnumFormatEtc(uint dwDirection, out OleInterop.IEnumFORMATETC ppenumFormatEtc)
        {
            if (null != oleData)
            {
                return(oleData.EnumFormatEtc(dwDirection, out ppenumFormatEtc));
            }

            BclComTypes.IEnumFORMATETC bclEnum = bclData.EnumFormatEtc((BclComTypes.DATADIR)dwDirection);
            if (null == bclEnum)
            {
                ppenumFormatEtc = null;
            }
            else
            {
                ppenumFormatEtc = bclEnum as OleInterop.IEnumFORMATETC;
                if (null == ppenumFormatEtc)
                {
                    ppenumFormatEtc = (OleInterop.IEnumFORMATETC)(new EnumFORMATETC(bclEnum));
                }
            }
            return(NativeMethods.S_OK);
        }
コード例 #6
0
            long MsHtmHstInterop.IDropTarget.Drop(
                [In] System.Runtime.InteropServices.ComTypes.IDataObject pDataObject,
                [In] int grfKeyState,
                [In] POINTL pt,
                [In, Out] ref uint pdwEffect
                )
            {
                System.Runtime.InteropServices.ComTypes.IEnumFORMATETC pEnum = (System.Runtime.InteropServices.ComTypes.IEnumFORMATETC)pDataObject.EnumFormatEtc(DATADIR.DATADIR_GET);
                pEnum.Reset();
                FORMATETC[] etcs         = new FORMATETC[1];
                int[]       pceltFetched = new int[1];
                while (pEnum.Next(1, etcs, pceltFetched) == 0)
                {
                    if (etcs[0].cfFormat == 15)
                    {
                        STGMEDIUM data;
                        pDataObject.GetData(ref etcs[0], out data);
                        if (data.tymed == TYMED.TYMED_HGLOBAL)
                        {
                            string[] items = null;
                            IntPtr   pData = GlobalLock(data.unionmember);
                            try
                            {
                                int size = (int)GlobalSize(data.unionmember);
                                int len  = 0;
                                unsafe
                                {
                                    Int32 *pOffset    = (Int32 *)pData;
                                    Int16 *pFileNames = (Int16 *)((Int32)pData + (*pOffset));
                                    size -= *pOffset;
                                    while (true)
                                    {
                                        if (len >= size || (pFileNames[len] == 0 && pFileNames[len + 1] == 0))
                                        {
                                            break;
                                        }
                                        len += 2;
                                    }
                                    String s = Marshal.PtrToStringUni((IntPtr)pFileNames, len);
                                    items = s.Split(new char[] { (char)0 });
                                }
                            }
                            finally
                            {
                                GlobalUnlock(data.unionmember);
                            }
                            StringBuilder files = new StringBuilder();
                            foreach (string file in items)
                            {
                                if (System.IO.File.Exists(file))
                                {
                                    if (files.Length > 0)
                                    {
                                        files.Append('\0');
                                    }
                                    files.Append(file);
                                }
                            }
                            if (files.Length > 0)
                            {
                                _window.IWindow.OnDropFiles.Call(files.ToString());
                                return(S_OK);
                            }
                        }
                    }
                    else if (etcs[0].cfFormat == 13)
                    {
                        STGMEDIUM data;
                        pDataObject.GetData(ref etcs[0], out data);
                        String text = null;

                        if (data.tymed == TYMED.TYMED_HGLOBAL)
                        {
                            IntPtr hData = GlobalLock(data.unionmember);
                            try
                            {
                                int size = (int)GlobalSize(data.unionmember);
                                text = Marshal.PtrToStringUni(hData);
                            }
                            finally
                            {
                                GlobalUnlock(data.unionmember);
                            }
                        }

                        Hashtable data_json = null;
                        try
                        {
                            data_json = Utility.ParseJson(text) as Hashtable;
                        }
                        catch
                        {
                            data_json = null;
                        }

                        if (data_json != null && data_json.ContainsKey("__Type") && data_json.ContainsKey("__Data"))
                        {
                            string drop_type = data_json["__Type"].ToString();
                            string drop_data = data_json["__Data"].ToString();
                            _window.IWindow.OnDrop.CallAll(drop_type, drop_data);
                            return(S_OK);
                        }
                    }
                }
                if (m_pPreDropTarget != null)
                {
                    m_pPreDropTarget.Drop(pDataObject, grfKeyState, pt, ref pdwEffect);
                }
                return(S_OK);
            }
コード例 #7
0
ファイル: OleToBCL.cs プロジェクト: Graham-Pedersen/IronPlot
 internal EnumFORMATETC(BclComTypes.IEnumFORMATETC bclEnum)
 {
     if (null == bclEnum)
         throw new ArgumentNullException("System.Runtime.InteropServices.ComTypes.IEnumFORMATETC");
     this.oleEnum = bclEnum as OleInterop.IEnumFORMATETC;
     this.bclEnum = bclEnum;
 }
コード例 #8
0
ファイル: OleToBCL.cs プロジェクト: Graham-Pedersen/IronPlot
 internal EnumFORMATETC(OleInterop.IEnumFORMATETC oleEnum)
 {
     if (null == oleEnum)
         throw new ArgumentNullException("Microsoft.VisualStudio.OLE.Interop.IEnumFORMATETC");
     this.oleEnum = oleEnum;
     this.bclEnum = oleEnum as BclComTypes.IEnumFORMATETC;
 }