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); } } } }
public bool SelectionAvailable() { using (FVWrapper w = GetFolderView()) { int items; return(w != null && w.FolderView.ItemCount(1, out items) == 0); } }
public IDLWrapper GetShellPath() { using (FVWrapper w = GetFolderView()) { return(w == null ? new IDLWrapper(IntPtr.Zero) : GetShellPath(w.FolderView)); } }
public int GetSelectedCount() { int count; using (FVWrapper w = GetFolderView()) { w.FolderView.ItemCount(1, out count); } return(count); }
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 */ } } }
public int GetFocusedIndex() { using (FVWrapper w = GetFolderView()) { int focusedIndex; if (w.FolderView.GetFocusedItem(out focusedIndex) == 0) { return(focusedIndex); } } return(-1); }
public int GetItemCount() { int count; using (FVWrapper w = GetFolderView()) { if (w == null) { return(0); } w.FolderView.ItemCount(2, out count); } return(count); }
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); } } }
public IDLWrapper GetShellPath() { using (FVWrapper w = GetFolderView()) { return(GetShellPath(w.FolderView)); } }