public static IntPtr IdListToPidl(IdList idList) { // Turn the ID list into a set of raw bytes. var rawBytes = new List<byte>(); // Each item starts with it's length, then the data. The length includes // two bytes, as it counts the length as a short. foreach (var id in idList.Ids) { // Add the size and data. short length = (short)(id.Length + 2); rawBytes.AddRange(BitConverter.GetBytes(length)); rawBytes.AddRange(id.RawId); } // Write the null termination. rawBytes.Add(0); rawBytes.Add(0); // Allocate COM memory for the pidl. var ptr = Marshal.AllocCoTaskMem(rawBytes.Count); // Copy the raw bytes. for (var i = 0; i < rawBytes.Count; i++) { Marshal.WriteByte(ptr, i, rawBytes[i]); } // We've allocated the pidl, copied it and are ready to rock. return ptr; }
/// <summary> /// Determines whether two idlists are equal. /// </summary> /// <param name="idList">The ID list to compare against.</param> /// <returns>True if the id lists are equal, false otherwise.</returns> public bool Matches(IdList idList) { // We must have a valid set to match against. if (idList == null || idList.ids == null || idList.ids.Count != ids.Count) return false; // If there is any id that doesn't match, we return false. return !ids.Where((t, i) => !t.Equals(idList.ids[i])).Any(); }
public GithubContextMenu(IdList folderIdList, IdList[] folderItemIdLists) { _folderItemIdLists = folderItemIdLists; _folderIdList = folderIdList; }
public IContextMenu CreateContextMenu(IdList folderIdList, IdList[] folderItemIdLists) { return new GithubContextMenu(folderIdList, folderItemIdLists); }
public static IdList Combine(IdList folderIdList, IdList folderItemIdList) { var combined = new List<ShellId>(folderIdList.Ids); combined.AddRange(folderItemIdList.Ids); return IdList.Create(combined); }
private IShellNamespaceItem GetChildItem(IdList idList) { // Go through each item in the list. var currentFolder = proxyFolder; for (int depth = 0; depth < idList.Ids.Count; depth++) { // If we are NOT on the last item, we're looking for a folder. if (depth != idList.Ids.Count - 1) { currentFolder = GetChildFolder(currentFolder, idList.Ids[depth]); continue; } // We ARE looking for an item, so get it. var item = currentFolder .GetChildren(ShellNamespaceEnumerationFlags.Folders | ShellNamespaceEnumerationFlags.Items) .SingleOrDefault(i => i.GetShellId().Equals(idList.Ids[depth])); if (item == null) { var me = currentFolder.GetDisplayName(DisplayNameContext.Normal); var you = idList.Ids[depth].ToString(); return null; } return item; } return null; }
int IPersistFolder.Initialize(IntPtr pidl) { // Store the folder absolute pidl. idListAbsolute = PidlManager.PidlToIdlist(pidl); return WinError.S_OK; }