当前位置: 首页>>代码示例>>C#>>正文


C# FORMATETC类代码示例

本文整理汇总了C#中FORMATETC的典型用法代码示例。如果您正苦于以下问题:C# FORMATETC类的具体用法?C# FORMATETC怎么用?C# FORMATETC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FORMATETC类属于命名空间,在下文中一共展示了FORMATETC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: STATDATA

 // IDataObject methods
 int IDataObject.DAdvise(FORMATETC[] e, uint adv, IAdviseSink sink, out uint cookie) {
   STATDATA sdata = new STATDATA();
   sdata.ADVF = adv;
   sdata.FORMATETC = e[0];
   sdata.pAdvSink = sink;
   cookie = this.map.Add(sdata);
   sdata.dwConnection = cookie;
   return 0;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:10,代码来源:DataObject.cs

示例2: ArgumentNullException

        int IDataObject.DAdvise(FORMATETC[] e, uint adv, IAdviseSink sink, out uint cookie)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            STATDATA sdata = new STATDATA();

            sdata.ADVF = adv;
            sdata.FORMATETC = e[0];
            sdata.pAdvSink = sink;
            cookie = this.map.Add(sdata);
            sdata.dwConnection = cookie;
            return 0;
        }
开发者ID:tunnelvisionlabs,项目名称:MPFProj10,代码行数:16,代码来源:DataObject.cs

示例3: GetDataHere

        /// <summary>
        /// Gets the specified data.
        /// </summary>
        /// <param name="format">The requested data format.</param>
        /// <param name="medium">When the function returns, contains the requested data.</param>
        /// <remarks>Differs from GetData only in that the STGMEDIUM storage is
        /// allocated and owned by the caller.</remarks>
        public void GetDataHere(ref FORMATETC format, ref STGMEDIUM medium)
        {
            // Locate the data
            KeyValuePair<FORMATETC, STGMEDIUM> dataEntry;
            if (GetDataEntry(ref format, out dataEntry))
            {
                STGMEDIUM source = dataEntry.Value;
                medium = CopyMedium(ref source);
                return;
            }

            // Didn't find it. Return an empty data medium.
            medium = default(STGMEDIUM);
        }
开发者ID:applejian,项目名称:cyberduck,代码行数:21,代码来源:DragDropLib.cs

示例4:

        int IEnumFORMATETC.Next(uint celt, FORMATETC[] d, uint[] fetched) {
            uint rc = 0;
            //uint size = (fetched != null) ? fetched[0] : 0;
            for (uint i = 0; i < celt; i++) {
                if (e.MoveNext()) {
                    DataCacheEntry entry = (DataCacheEntry)e.Current;

                    rc++;
                    if (d != null && d.Length > i) {
                        d[i] = entry.Format;
                    }
                } else {
                    return VSConstants.S_FALSE;
                }
            }

            if (fetched != null && fetched.Length > 0)
                fetched[0] = rc;
            return VSConstants.S_OK;
        }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:20,代码来源:DataObject.cs

示例5: QueryGetData

 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;
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:10,代码来源:DataObject.cs

示例6: QueryGetData

        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)
            {
                Trace.WriteLine("COMException : " + e.Message);
                returnValue = e.ErrorCode;
            }

            return returnValue;
        }
开发者ID:borota,项目名称:JTVS,代码行数:22,代码来源:DataObject.cs

示例7: EnumFORMATETC

 /// <summary>
 /// Creates an instance from an array of FORMATETC's.
 /// </summary>
 /// <param name="formats">Array of formats to enumerate.</param>
 private EnumFORMATETC(FORMATETC[] formats)
 {
     // Get the formats as a copy of the array
     this.formats = new FORMATETC[formats.Length];
     formats.CopyTo(this.formats, 0);
 }
开发者ID:applejian,项目名称:cyberduck,代码行数:10,代码来源:DragDropLib.cs

示例8: AdviseEntry

 public AdviseEntry(ref FORMATETC format, ADVF advf, IAdviseSink sink)
 {
     this.format = format;
     this.advf = advf;
     this.sink = sink;
 }
开发者ID:applejian,项目名称:cyberduck,代码行数:6,代码来源:DragDropLib.cs

示例9: IsFormatCompatible

 /// <summary>
 /// Determines if the formats are compatible.
 /// </summary>
 /// <param name="format1">A FORMATETC.</param>
 /// <param name="format2">A FORMATETC.</param>
 /// <returns>True if the formats are compatible, otherwise False.</returns>
 /// <remarks>Compatible formats have the same DVASPECT, same format ID, and share
 /// at least one TYMED.</remarks>
 private bool IsFormatCompatible(ref FORMATETC format1, ref FORMATETC format2)
 {
     return ((format1.tymed & format2.tymed) > 0
             && format1.dwAspect == format2.dwAspect
             && format1.cfFormat == format2.cfFormat);
 }
开发者ID:applejian,项目名称:cyberduck,代码行数:14,代码来源:DragDropLib.cs

示例10: GetDataEntry

        /// <summary>
        /// Gets a data entry by the specified format.
        /// </summary>
        /// <param name="pFormatetc">The format to locate the data entry for.</param>
        /// <param name="dataEntry">The located data entry.</param>
        /// <returns>True if the data entry was found, otherwise False.</returns>
        private bool GetDataEntry(ref FORMATETC pFormatetc, out KeyValuePair<FORMATETC, STGMEDIUM> dataEntry)
        {
            foreach (KeyValuePair<FORMATETC, STGMEDIUM> entry in storage)
            {
                FORMATETC format = entry.Key;
                if (IsFormatCompatible(ref pFormatetc, ref format))
                {
                    dataEntry = entry;
                    return true;
                }
            }

            // Not found... default allocate the out param
            dataEntry = default(KeyValuePair<FORMATETC, STGMEDIUM>);
            return false;
        }
开发者ID:applejian,项目名称:cyberduck,代码行数:22,代码来源:DragDropLib.cs

示例11: SetData

        /// <summary>
        /// Sets data in the specified format into storage.
        /// </summary>
        /// <param name="formatIn">The format of the data.</param>
        /// <param name="medium">The data.</param>
        /// <param name="release">If true, ownership of the medium's memory will be transferred
        /// to this object. If false, a copy of the medium will be created and maintained, and
        /// the caller is responsible for the memory of the medium it provided.</param>
        public void SetData(ref FORMATETC formatIn, ref STGMEDIUM medium, bool release)
        {
            // If the format exists in our storage, remove it prior to resetting it
            foreach (KeyValuePair<FORMATETC, STGMEDIUM> pair in storage)
            {
                if ((pair.Key.tymed & formatIn.tymed) > 0
                    && pair.Key.dwAspect == formatIn.dwAspect
                    && pair.Key.cfFormat == formatIn.cfFormat)
                {
                    STGMEDIUM releaseMedium = pair.Value;
                    ReleaseStgMedium(ref releaseMedium);
                    storage.Remove(pair);
                    break;
                }
            }

            // If release is true, we'll take ownership of the medium.
            // If not, we'll make a copy of it.
            STGMEDIUM sm = medium;
            if (!release)
                sm = CopyMedium(ref medium);

            // Add it to the internal storage
            KeyValuePair<FORMATETC, STGMEDIUM> addPair = new KeyValuePair<FORMATETC, STGMEDIUM>(formatIn, sm);
            storage.Add(addPair);

            RaiseDataChanged(ref addPair);
        }
开发者ID:applejian,项目名称:cyberduck,代码行数:36,代码来源:DragDropLib.cs

示例12: QueryGetData

        /// <summary>
        /// Determines if data of the requested format is present.
        /// </summary>
        /// <param name="format">The request data format.</param>
        /// <returns>Returns the status of the request. If the data is present, S_OK is returned.
        /// If the data is not present, an error code with the best guess as to the reason is returned.</returns>
        public int QueryGetData(ref FORMATETC format)
        {
            // We only support CONTENT aspect
            if ((DVASPECT.DVASPECT_CONTENT & format.dwAspect) == 0)
                return DV_E_DVASPECT;

            int ret = DV_E_TYMED;

            // Try to locate the data
            // TODO: The ret, if not S_OK, is only relevant to the last item
            foreach (KeyValuePair<FORMATETC, STGMEDIUM> pair in storage)
            {
                if ((pair.Key.tymed & format.tymed) > 0)
                {
                    if (pair.Key.cfFormat == format.cfFormat)
                    {
                        // Found it, return S_OK;
                        return 0;
                    }
                    else
                    {
                        // Found the medium type, but wrong format
                        ret = DV_E_CLIPFORMAT;
                    }
                }
                else
                {
                    // Mismatch on medium type
                    ret = DV_E_TYMED;
                }
            }

            return ret;
        }
开发者ID:applejian,项目名称:cyberduck,代码行数:40,代码来源:DragDropLib.cs

示例13: GetClipboardFormat

 /// <summary>
 /// Asks the given list item to renders a specific clipboard format that it supports.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="grfFlags"></param>
 /// <param name="pFormatetc"></param>
 /// <param name="pMedium"></param>
 /// <returns></returns>
 public int GetClipboardFormat(uint index, uint grfFlags, FORMATETC[] pFormatetc, STGMEDIUM[] pMedium)
 {
     throw new NotImplementedException();
 }
开发者ID:klewin,项目名称:NDjango,代码行数:12,代码来源:SymbolNode.cs

示例14: Next

            /// <summary>
            /// Retrieves the next elements from the enumeration.
            /// </summary>
            /// <param name="celt">The number of elements to retrieve.</param>
            /// <param name="rgelt">An array to receive the formats requested.</param>
            /// <param name="pceltFetched">An array to receive the number of element fetched.</param>
            /// <returns>If the fetched number of formats is the same as the requested number, S_OK is returned.
            /// There are several reasons S_FALSE may be returned: (1) The requested number of elements is less than
            /// or equal to zero. (2) The rgelt parameter equals null. (3) There are no more elements to enumerate.
            /// (4) The requested number of elements is greater than one and pceltFetched equals null or does not
            /// have at least one element in it. (5) The number of fetched elements is less than the number of
            /// requested elements.</returns>
            public int Next(int celt, FORMATETC[] rgelt, int[] pceltFetched)
            {
                // Start with zero fetched, in case we return early
                if (pceltFetched != null && pceltFetched.Length > 0)
                    pceltFetched[0] = 0;

                // This will count down as we fetch elements
                int cReturn = celt;

                // Short circuit if they didn't request any elements, or didn't
                // provide room in the return array, or there are not more elements
                // to enumerate.
                if (celt <= 0 || rgelt == null || currentIndex >= formats.Length)
                    return 1; // S_FALSE

                // If the number of requested elements is not one, then we must
                // be able to tell the caller how many elements were fetched.
                if ((pceltFetched == null || pceltFetched.Length < 1) && celt != 1)
                    return 1; // S_FALSE

                // If the number of elements in the return array is too small, we
                // throw. This is not a likely scenario, hence the exception.
                if (rgelt.Length < celt)
                    throw new ArgumentException(
                        "The number of elements in the return array is less than the number of elements requested");

                // Fetch the elements.
                for (int i = 0; currentIndex < formats.Length && cReturn > 0; i++, cReturn--, currentIndex++)
                    rgelt[i] = formats[currentIndex];

                // Return the number of elements fetched
                if (pceltFetched != null && pceltFetched.Length > 0)
                    pceltFetched[0] = celt - cReturn;

                // cReturn has the number of elements requested but not fetched.
                // It will be greater than zero, if multiple elements were requested
                // but we hit the end of the enumeration.
                return (cReturn == 0) ? 0 : 1; // S_OK : S_FALSE
            }
开发者ID:applejian,项目名称:cyberduck,代码行数:51,代码来源:DragDropLib.cs

示例15: SetData

 internal void SetData(FORMATETC format, IntPtr data) {
     this.entries.Add(new DataCacheEntry(format, data, DATADIR.DATADIR_SET));
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:3,代码来源:DataObject.cs


注:本文中的FORMATETC类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。