Ejemplo n.º 1
0
            /// <summary>
            /// Creates a clone of this enumerator.
            /// </summary>
            /// <param name="newEnum">When this function returns, contains a new instance of IEnumFORMATETC.</param>
            public void Clone(out IEnumFORMATETC newEnum)
            {
                var ret = new EnumFORMATETC(formats);

                ret.currentIndex = currentIndex;
                newEnum          = ret;
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Creates a clone of this enumerator.
            /// </summary>
            /// <param name="newEnum">When this function returns, contains a new instance of IEnumFORMATETC.</param>
            public void Clone(out IEnumFORMATETC newEnum)
            {
                EnumFORMATETC _ret = new EnumFORMATETC(m_formats);

                _ret.m_currentIndex = m_currentIndex;
                newEnum             = _ret;
            }
Ejemplo n.º 3
0
 public void Clone(out IEnumFORMATETC newEnum)
 {
     newEnum = (IEnumFORMATETC) new Advent.Common.Interop.DataObject.EnumFORMATETC(this.formats)
     {
         currentIndex = this.currentIndex
     };
 }
Ejemplo n.º 4
0
        public IEnumerable <DataObjectFormat> GetFormats()
        {
            IEnumFORMATETC enumFormatEtc = null !;

            try
            {
                enumFormatEtc = DataObject.EnumFormatEtc(DATADIR.DATADIR_GET);
                if (enumFormatEtc == null)
                {
                    return(Array.Empty <DataObjectFormat>());
                }
                enumFormatEtc.Reset();
                var fe = new FORMATETC[1];
                var fs = new List <DataObjectFormat>();
                while (enumFormatEtc.Next(1, fe, null) == 0)
                {
                    fs.Add(new DataObjectFormat(fe[0]));
                }
                return(fs);
            }
            finally
            {
                if (enumFormatEtc != null)
                {
                    Marshal.ReleaseComObject(enumFormatEtc);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Clone the current enumerator by returning another enumerator with its
        /// position the same as the current one
        /// </summary>
        /// <returns></returns>
        public void Clone(out IEnumFORMATETC ppenum)
        {
            EnumFORMATETC clone = new EnumFORMATETC(oleDataEntries);

            clone.currentItem = currentItem;
            ppenum            = clone;
        }
Ejemplo n.º 6
0
 public void Clone(out IEnumFORMATETC newEnum)
 {
     newEnum = new FormatEnumerator(m_formats)
     {
         m_currentIndex = m_currentIndex
     };
 }
            private static int Next(IntPtr thisPtr, int celt, FORMATETC *rgelt, int *pceltFetched)
            {
                try
                {
                    IEnumFORMATETC instance    = ComInterfaceDispatch.GetInstance <IEnumFORMATETC>((ComInterfaceDispatch *)thisPtr);
                    FORMATETC[]    elt         = new FORMATETC[celt];
                    int[]          celtFetched = new int[1];

                    // Eliminate null bang after https://github.com/dotnet/runtime/pull/68537 lands, or
                    // IEnumFORMATETC annotations would be corrected.
                    var result = instance.Next(celt, elt, pceltFetched is null ? null ! : celtFetched);
                    for (var i = 0; i < celt; i++)
                    {
                        rgelt[i] = elt[i];
                    }

                    if (pceltFetched is not null)
                    {
                        *pceltFetched = celtFetched[0];
                    }

                    return(result);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    return(ex.HResult);
                }
            }
Ejemplo n.º 8
0
 public void Clone(out IEnumFORMATETC ppenum)
 {
     Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "FormatEnumerator: Clone");
     FORMATETC[] temp = new FORMATETC[formats.Count];
     formats.CopyTo(temp, 0);
     ppenum = new FormatEnumerator(parent, temp);
 }
            public void Clone(out IEnumFORMATETC newEnum)
            {
                IntPtr resultPtr;

                ((delegate * unmanaged <IntPtr, IntPtr *, HRESULT>)(*(*(void ***)_wrappedInstance + 6)))
                    (_wrappedInstance, &resultPtr).ThrowIfFailed();
                newEnum = (IEnumFORMATETC)WinFormsComWrappers.Instance.GetOrCreateObjectForComInstance(resultPtr, CreateObjectFlags.Unwrap);
            }
Ejemplo n.º 10
0
            /// <summary>
            /// Creates a clone of this enumerator.
            /// </summary>
            /// <param name="newEnum">When this function returns, contains a new instance of IEnumFORMATETC.</param>
            public void Clone(out IEnumFORMATETC newEnum)
            {
                EnumFORMATETC ret = new EnumFORMATETC(formats)
                {
                    currentIndex = currentIndex
                };

                newEnum = ret;
            }
Ejemplo n.º 11
0
            public virtual string[] GetFormats(bool autoConvert)
            {
                Debug.Assert(innerData != null, "You must have an innerData on all DataObjects");

                IEnumFORMATETC enumFORMATETC = null;

                // Since we are only adding elements to the HashSet, the order will be preserved.
                HashSet <string> distinctFormats = new HashSet <string>();

                try
                {
                    enumFORMATETC = innerData.EnumFormatEtc(DATADIR.DATADIR_GET);
                }
                catch
                {
                }

                if (enumFORMATETC != null)
                {
                    enumFORMATETC.Reset();

                    FORMATETC[] formatetc = new FORMATETC[] { new FORMATETC() };
                    int[]       retrieved = new int[] { 1 };

                    while (retrieved[0] > 0)
                    {
                        retrieved[0] = 0;
                        try
                        {
                            enumFORMATETC.Next(1, formatetc, retrieved);
                        }
                        catch
                        {
                        }

                        if (retrieved[0] > 0)
                        {
                            string name = DataFormats.GetFormat(formatetc[0].cfFormat).Name;
                            if (autoConvert)
                            {
                                string[] mappedFormats = GetMappedFormats(name);
                                for (int i = 0; i < mappedFormats.Length; i++)
                                {
                                    distinctFormats.Add(mappedFormats[i]);
                                }
                            }
                            else
                            {
                                distinctFormats.Add(name);
                            }
                        }
                    }
                }

                return(distinctFormats.ToArray());
            }
Ejemplo n.º 12
0
            public virtual string[] GetFormats(bool autoConvert)
            {
                Debug.Assert(innerData != null, "You must have an innerData on all DataObjects");

                IEnumFORMATETC enumFORMATETC = null;
                ArrayList      formats       = new ArrayList();

                try
                {
                    enumFORMATETC = innerData.EnumFormatEtc(DATADIR.DATADIR_GET);
                }
                catch
                {
                }

                if (enumFORMATETC != null)
                {
                    enumFORMATETC.Reset();

                    FORMATETC[] formatetc = new FORMATETC[] { new FORMATETC() };
                    int[]       retrieved = new int[] { 1 };

                    while (retrieved[0] > 0)
                    {
                        retrieved[0] = 0;
                        try
                        {
                            enumFORMATETC.Next(1, formatetc, retrieved);
                        }
                        catch
                        {
                        }

                        if (retrieved[0] > 0)
                        {
                            string name = DataFormats.GetFormat(formatetc[0].cfFormat).Name;
                            if (autoConvert)
                            {
                                string[] mappedFormats = GetMappedFormats(name);
                                for (int i = 0; i < mappedFormats.Length; i++)
                                {
                                    formats.Add(mappedFormats[i]);
                                }
                            }
                            else
                            {
                                formats.Add(name);
                            }
                        }
                    }
                }

                string[] temp = new string[formats.Count];
                formats.CopyTo(temp, 0);
                return(GetDistinctStrings(temp));
            }
            private static int Skip(IntPtr thisPtr, int celt)
            {
                IEnumFORMATETC instance = ComInterfaceDispatch.GetInstance <IEnumFORMATETC>((ComInterfaceDispatch *)thisPtr);

                try
                {
                    return(instance.Skip(celt));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    return(ex.HResult);
                }
            }
 private static int Reset(IntPtr thisPtr)
 {
     try
     {
         IEnumFORMATETC instance = ComInterfaceDispatch.GetInstance <IEnumFORMATETC>((ComInterfaceDispatch *)thisPtr);
         instance.Reset();
         return(S_OK);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
         return(ex.HResult);
     }
 }
 private static int Clone(IntPtr thisPtr, IntPtr *ppenum)
 {
     try
     {
         IEnumFORMATETC instance = ComInterfaceDispatch.GetInstance <IEnumFORMATETC>((ComInterfaceDispatch *)thisPtr);
         instance.Clone(out var cloned);
         *ppenum = WinFormsComWrappers.Instance.GetComPointer(cloned, IID.IEnumFORMATETC);
         return(S_OK);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
         return(ex.HResult);
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates and returns a pointer to an object to enumerate the FORMATETC
        /// supported by the data object
        /// </summary>
        /// <param name="dwDirection">Direction of the data through a value from
        /// the enumeration DATADIR</param>
        /// <param name="ppEnumFormatEtc">Address of IEnumFORMATETC* pointer variable
        /// that receives the interface pointer to the new enumerator object</param>
        public int EnumFormatEtc(DATADIR dwDirection, out IEnumFORMATETC ppEnumFormatEtc)
        {
            // don't support enumeration of set formats
            if (dwDirection == DATADIR.SET)
            {
                ppEnumFormatEtc = null;
                return(HRESULT.E_NOTIMPL);
            }

            // return a new enumerator for our data entries
            IEnumFORMATETC enumerator = new EnumFORMATETC(oleDataEntries);

            enumerators.Add(enumerator);
            ppEnumFormatEtc = enumerator;
            return(HRESULT.S_OK);
        }
Ejemplo n.º 17
0
 public static extern int SHCreateStdEnumFmtEtc(uint cfmt, FORMATETC[] afmt, out IEnumFORMATETC ppenumFormatEtc);
Ejemplo n.º 18
0
 public static int SHCreateStdEnumFmtEtc(uint cfmt, FORMATETC[] afmt, out IEnumFORMATETC ppenumFormatEtc)
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     ppenumFormatEtc = null;
     return(0);
 }
Ejemplo n.º 19
0
 public static extern int SHCreateStdEnumFmtEtc(uint cfmt, FORMATETC[] afmt, out IEnumFORMATETC ppenumFormatEtc);
Ejemplo n.º 20
0
 public uint EnumFormatEtc(uint dwDirection, IEnumFORMATETC penum)
 {
     return(S_OK);
 }
Ejemplo n.º 21
0
		public uint EnumFormatEtc(uint dwDirection, IEnumFORMATETC penum)
		{
			Trace.WriteLine("EnumFormatEtc");

			return (int)S_OK;
		}
Ejemplo n.º 22
0
 /// <summary>
 /// Creates a clone of this enumerator.
 /// </summary>
 /// <param name="newEnum">When this function returns, contains a new instance of IEnumFORMATETC.</param>
 public void Clone(out IEnumFORMATETC newEnum)
 {
     EnumFORMATETC ret = new EnumFORMATETC(formats);
     ret.currentIndex = currentIndex;
     newEnum = ret;
 }
Ejemplo n.º 23
0
 int IDataObject.EnumFormatEtc(uint direction, out IEnumFORMATETC penum)
 {
     penum = new EnumFORMATETC((DATADIR)direction, (IEnumerable)this.entries);
     return(0);
 }
Ejemplo n.º 24
0
 public void Clone(out IEnumFORMATETC newEnum)
 {
     newEnum = new EnumFormatEtc(this);
 }
Ejemplo n.º 25
0
 void IEnumFORMATETC.Clone(out IEnumFORMATETC clone)
 {
     clone = new EnumFORMATETC(this.dir, this.cache);
 }
 /// <summary>
 /// Clone the current enumerator by returning another enumerator with its
 /// position the same as the current one
 /// </summary>
 /// <returns></returns>
 public void Clone(out IEnumFORMATETC ppenum)
 {
     EnumFORMATETC clone = new EnumFORMATETC(oleDataEntries);
     clone.currentItem = currentItem;
     ppenum = clone;
 }
Ejemplo n.º 27
0
 public void Clone(out IEnumFORMATETC newEnum)
 {
     //Create new enumerators
     newEnum = new FormatEtcEnumerator(formats);
 }
Ejemplo n.º 28
0
 public void Clone(out IEnumFORMATETC newEnum)
 {
     newEnum = (IEnumFORMATETC)new Advent.Common.Interop.DataObject.EnumFORMATETC(this.formats)
     {
         currentIndex = this.currentIndex
     };
 }
Ejemplo n.º 29
0
 public void Clone(out IEnumFORMATETC ppenum) {
     Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "FormatEnumerator: Clone");
     FORMATETC[] temp = new FORMATETC[formats.Count];
     formats.CopyTo(temp, 0);
     ppenum = new FormatEnumerator(parent, temp);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Creates a new enumerator that contains the same enumeration state as the current enumerator.
 /// </summary>
 /// <param name="ppenum">When this method returns, contains a reference to the newly created enumerator.</param>
 public void Clone(out IEnumFORMATETC ppenum)
 {
     ppenum = new FormatEnumerator(this);
 }
Ejemplo n.º 31
0
 public static extern int CreateAsyncBindCtx(
     [MarshalAs(UnmanagedType.U4)] uint dwReserved,
     [MarshalAs(UnmanagedType.Interface)] IBindStatusCallback pbsc,
     [MarshalAs(UnmanagedType.Interface)] IEnumFORMATETC penumfmtetc,
     [Out, MarshalAs(UnmanagedType.Interface)] out IBindCtx ppbc);
 public void Clone(out IEnumFORMATETC ppenum)
 {
     Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "FormatEnumerator: Clone");
     ppenum = new FormatEnumerator(this);
 }
Ejemplo n.º 33
0
        public int EnumFormatEtc(DATADIR direction, out IEnumFORMATETC ppenumFormatEtc)
        {
            IEnumFORMATETC origEnum = null;

            try
            {
                log.DebugFormat("IDataObject.EnumFormatEtc called -- direction {0}", direction);
                switch (direction)
                {
                case DATADIR.DATADIR_GET:
                    //Get original enumerator
                    int result = innerData.EnumFormatEtc(direction, out origEnum);
                    if (result != NativeMethods.S_OK)
                    {
                        ppenumFormatEtc = null;
                        return(result);
                    }

                    //Enumerate original formats
                    List <FORMATETC> formats = new List <FORMATETC>();
                    FORMATETC[]      buffer  = new FORMATETC[] { new FORMATETC() };
                    while (origEnum.Next(1, buffer, null) == NativeMethods.S_OK)
                    {
                        //Convert format from short to unsigned short
                        ushort cfFormat = (ushort)buffer[0].cfFormat;

                        //Do not return text formats -- some applications try to get text before files
                        if (cfFormat != NativeMethods.CF_TEXT && cfFormat != NativeMethods.CF_UNICODETEXT && cfFormat != (ushort)DataObjectHelper.GetClipboardFormat("Csv"))
                        {
                            formats.Add(buffer[0]);
                        }
                    }

                    //Add CF_HDROP format
                    FORMATETC format = new FORMATETC();
                    format.cfFormat = NativeMethods.CF_HDROP;
                    format.dwAspect = DVASPECT.DVASPECT_CONTENT;
                    format.lindex   = -1;
                    format.ptd      = IntPtr.Zero;
                    format.tymed    = TYMED.TYMED_HGLOBAL;
                    formats.Add(format);

                    //Return new enumerator for available formats
                    ppenumFormatEtc = new FormatEtcEnumerator(formats.ToArray());
                    return(NativeMethods.S_OK);

                case DATADIR.DATADIR_SET:
                    //Return original enumerator
                    return(innerData.EnumFormatEtc(direction, out ppenumFormatEtc));

                default:
                    //Invalid direction
                    ppenumFormatEtc = null;
                    return(NativeMethods.E_INVALIDARG);
                }
            }
            catch (Exception ex)
            {
                log.Error("Exception in IDataObject.EnumFormatEtc", ex);
                ppenumFormatEtc = null;
                return(NativeMethods.E_UNEXPECTED);
            }
            finally
            {
                //Release all unmanaged objects
                if (origEnum != null)
                {
                    Marshal.ReleaseComObject(origEnum);
                }
            }
        }
Ejemplo n.º 34
0
 public void Clone(out IEnumFORMATETC newEnum)
 {
     newEnum = new FormatEnumerator(_formats, _current);
 }
 int IDataObject.EnumFormatEtc(uint direction, out IEnumFORMATETC penum) {
     penum = new EnumFORMATETC((DATADIR)direction, (IEnumerable)this.entries);
     return 0;
 }
        /// <summary>
        /// Creates and returns a pointer to an object to enumerate the FORMATETC
        /// supported by the data object
        /// </summary>
        /// <param name="dwDirection">Direction of the data through a value from
        /// the enumeration DATADIR</param>
        /// <param name="ppEnumFormatEtc">Address of IEnumFORMATETC* pointer variable
        /// that receives the interface pointer to the new enumerator object</param>
        public int EnumFormatEtc(DATADIR dwDirection, out IEnumFORMATETC ppEnumFormatEtc)
        {
            // don't support enumeration of set formats
            if (dwDirection == DATADIR.SET)
            {
                ppEnumFormatEtc = null;
                return HRESULT.E_NOTIMPL;
            }

            // return a new enumerator for our data entries
            IEnumFORMATETC enumerator = new EnumFORMATETC(oleDataEntries);
            enumerators.Add(enumerator);
            ppEnumFormatEtc = enumerator;
            return HRESULT.S_OK;
        }
Ejemplo n.º 37
0
 void IEnumFORMATETC.Clone(out IEnumFORMATETC clone)
 {
     clone = new EnumFORMATETC(dir, cache);
 }
Ejemplo n.º 38
0
 // IEnumFORMATETC.Clone implementation.
 public void Clone(out IEnumFORMATETC ppenum)
 {
     ppenum = new FormatEnumerator(this);
 }
 void IEnumFORMATETC.Clone(out IEnumFORMATETC clone) {
     clone = new EnumFORMATETC(dir, cache);
 }
Ejemplo n.º 40
0
 public void Clone(out IEnumFORMATETC newEnum)
 {
     newEnum = new FormatEnumerator(m_formats)
     {
         m_currentIndex = m_currentIndex
     };
 }