Ejemplo n.º 1
0
 public IDLWrapper GetItem(int idx, bool noAppend = false)
 {
     using (FVWrapper w = GetFolderView()) {
         if (w == null)
         {
             return(null);
         }
         IntPtr ppidl = IntPtr.Zero;
         try {
             w.FolderView.Item(idx, out ppidl);
             if (noAppend || ppidl == IntPtr.Zero)
             {
                 return(new IDLWrapper(ppidl));
             }
             using (IDLWrapper path = GetShellPath(w.FolderView)) {
                 return(new IDLWrapper(PInvoke.ILCombine(path.PIDL, ppidl)));
             }
         }
         finally {
             if (ppidl != IntPtr.Zero && !noAppend)
             {
                 PInvoke.CoTaskMemFree(ppidl);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public bool SelectionAvailable()
 {
     using (FVWrapper w = GetFolderView()) {
         int items;
         return(w != null && w.FolderView.ItemCount(1, out items) == 0);
     }
 }
Ejemplo n.º 3
0
 public IDLWrapper GetShellPath()
 {
     using (FVWrapper w = GetFolderView()) {
         return(w == null
                 ? new IDLWrapper(IntPtr.Zero)
                 : GetShellPath(w.FolderView));
     }
 }
Ejemplo n.º 4
0
        public int GetSelectedCount()
        {
            int count;

            using (FVWrapper w = GetFolderView()) {
                w.FolderView.ItemCount(1, out count);
            }
            return(count);
        }
Ejemplo n.º 5
0
 public void SelectItem(int idx)
 {
     using (FVWrapper w = GetFolderView()) {
         if (w != null)
         {
             w.FolderView.SelectItem(idx, 29);
             /* SVSI_SELECT | SVSI_DESELECTOTHERS | SVSI_ENSUREVISIBLE | SVSI_FOCUSED */
         }
     }
 }
Ejemplo n.º 6
0
 public int GetFocusedIndex()
 {
     using (FVWrapper w = GetFolderView()) {
         int focusedIndex;
         if (w.FolderView.GetFocusedItem(out focusedIndex) == 0)
         {
             return(focusedIndex);
         }
     }
     return(-1);
 }
Ejemplo n.º 7
0
        public int GetItemCount()
        {
            int count;

            using (FVWrapper w = GetFolderView()) {
                if (w == null)
                {
                    return(0);
                }
                w.FolderView.ItemCount(2, out count);
            }
            return(count);
        }
Ejemplo n.º 8
0
        public IEnumerable <IDLWrapper> GetItems(bool selectedOnly = false, bool noAppend = false)
        {
            Guid        guid = ExplorerGUIDs.IID_IEnumIDList;
            IEnumIDList list = null;

            try {
                using (FVWrapper w = GetFolderView())
                    using (IDLWrapper path = noAppend ? null : GetShellPath(w.FolderView)) {
                        if (w == null)
                        {
                            yield break;
                        }
                        w.FolderView.Items(0x80000000 | (selectedOnly ? 1u : 2u), ref guid, out list);
                        if (list == null)
                        {
                            yield break;
                        }
                        IntPtr ptr;
                        while (list.Next(1, out ptr, null) == 0)
                        {
                            using (IDLWrapper wrapper1 = new IDLWrapper(ptr)) {
                                if (!wrapper1.Available)
                                {
                                    continue;
                                }
                                if (noAppend)
                                {
                                    yield return(wrapper1);
                                }
                                else
                                {
                                    using (IDLWrapper wrapper2 = new IDLWrapper(PInvoke.ILCombine(path.PIDL, wrapper1.PIDL))) {
                                        yield return(wrapper2);
                                    }
                                }
                            }
                        }
                    }
            }
            finally {
                if (list != null)
                {
                    Marshal.ReleaseComObject(list);
                }
            }
        }
Ejemplo n.º 9
0
 public IDLWrapper GetShellPath()
 {
     using (FVWrapper w = GetFolderView()) {
         return(GetShellPath(w.FolderView));
     }
 }