Esempio n. 1
0
        internal override string[] ProcessVistaFiles(IFileDialog dialog)
        {
            var openDialog = (IFileOpenDialog)dialog;

            if (Multiselect)
            {
                IShellItemArray results = openDialog.GetResults();
                uint            count   = results.GetCount();
                string[]        paths   = new string[count];
                for (uint i = 0; i < count; ++i)
                {
                    IShellItem item = results.GetItemAt(i);
                    paths[i] = item.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING);
                }
                return(paths);
            }
            else
            {
                IShellItem item = openDialog.GetResult();
                return(new[] { item.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING) });
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Converts an <see cref="IShellItemArray"/> into a IShellItem[]
        /// </summary>
        /// <param name="shellItemArray">The Interface you want to convert</param>
        /// <returns></returns>
        public static IShellItem[] ToArray(this IShellItemArray shellItemArray)
        {
            var items = new List <IShellItem>();

            if (shellItemArray == null)
            {
                return(items.ToArray());
            }
            try {
                uint itemCount = 0;
                shellItemArray.GetCount(out itemCount);
                for (uint index = 0; index < itemCount; index++)
                {
                    IShellItem iShellItem = null;
                    shellItemArray.GetItemAt(index, out iShellItem);
                    items.Add(iShellItem);
                }
            } finally {
                //Marshal.ReleaseComObject(shellItemArray);
            }
            return(items.ToArray());
        }
Esempio n. 3
0
        internal override string[] ProcessVistaFiles(IFileDialog dialog)
        {
            IFileOpenDialog fileOpenDialog = (IFileOpenDialog)dialog;

            if (this.Multiselect)
            {
                IShellItemArray results = fileOpenDialog.GetResults();
                uint            count   = results.GetCount();
                string[]        array   = new string[count];
                for (uint num = 0U; num < count; num += 1U)
                {
                    IShellItem itemAt = results.GetItemAt(num);
                    array[(int)num] = itemAt.GetDisplayName((SIGDN)2147647488U);
                }
                return(array);
            }
            IShellItem result = fileOpenDialog.GetResult();

            return(new string[]
            {
                result.GetDisplayName((SIGDN)2147647488U)
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a ShellObject collection from an IShellItemArray
        /// </summary>
        /// <param name="iArray">IShellItemArray pointer</param>
        /// <param name="readOnly">Indicates whether the collection shouldbe read-only or not</param>
        internal ShellObjectCollection(IShellItemArray iArray, bool readOnly)
        {
            this.readOnly = readOnly;

            if (iArray != null)
            {
                try
                {
                    uint itemCount = 0;
                    iArray.GetCount(out itemCount);
                    content.Capacity = (int)itemCount;
                    for (uint index = 0; index < itemCount; index++)
                    {
                        IShellItem iShellItem = null;
                        iArray.GetItemAt(index, out iShellItem);
                        content.Add(ShellObjectFactory.Create(iShellItem));
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(iArray);
                }
            }
        }