internal ShellFolder(IShellItem shellItem, IShellFolder shellFolder, ShellItemKnownInfo knownInfo) : base(GetShellItemFromFolder(shellItem, shellFolder), knownInfo) { if (shellFolder == null) { shellFolder = (IShellFolder)shellItem.BindToHandler(null, ShellConsts.BHID_SFObject, typeof(IShellFolder).GUID); } NativeFolder = shellFolder; }
internal ShellFolder(IShellItem shellItem, IShellFolder shellFolder, ShellItemKnownInfo knownInfo) : base(GetShellItemFromFolder(shellItem, shellFolder), knownInfo) { if (shellFolder == null) { shellFolder = (IShellFolder)shellItem.BindToHandler(null, ShellConsts.BHID_SFObject, typeof(IShellFolder).GUID); } NativeFolder = shellFolder; }
private void Init(ShellItemKnownInfo knownInfo) { _loadedAttrs = knownInfo.LoadedAttributes; _attrs = knownInfo.Attributes; _parentParsePath = knownInfo.ParentParsePath; _pidl = new Lazy<IdList>(() => SHGetIDListFromObject(nativeItem)); _parentFolder = new Lazy<ShellFolder>(() => { var nativeParent = nativeItem.GetParent(); if (nativeParent == null) return null; return new ShellFolder(nativeParent, null, new ShellItemKnownInfo()); }); _desktopAbsoluteParsePath = new Lazy<string>(() => nativeItem.GetDisplayName(SIGDN.DesktopAbsoluteParsing)); _parseName = new Lazy<string>(() => nativeItem.GetDisplayName(SIGDN.ParentRelativeParsing)); _parsePath = new Lazy<string>(() => { if (Pidl.Parts.Count == 0) // The actual desktop return ""; try { if (_parentParsePath != null) { string normParentPath = _parentParsePath.Trim('\\'); if (normParentPath != "") normParentPath += "\\"; return normParentPath + ParseName; } else return DesktopAbsoluteParsePath; } catch (ArgumentException) { IdList childPidl = new IdList(Pidl.Parts[Pidl.Parts.Count - 1]); return GetParentFolder().NativeFolder.GetDisplayNameOf(childPidl, SHGDNF.ForParsing); } }); _fullParsePath = new Lazy<string>(() => { if (GetParentFolder() == null) return ""; string parentParsePath = GetParentFolder().FullParsePath.TrimEnd('\\'); if (parentParsePath != "") parentParsePath += "\\"; return parentParsePath + nativeItem.GetDisplayName(SIGDN.ParentRelativeParsing); }); /*_displayName = new Lazy<string>(() => GetParentFolder().NativeFolder.GetDisplayNameOf( new IdList(Pidl.Parts[Pidl.Parts.Count - 1]), SHGDNF.InFolder | SHGDNF.Normal));*/ _displayName = new Lazy<string>(() => nativeItem.GetDisplayName(SIGDN.NormalDisplay)); }
internal static ShellItem GetShellItem(IdList pidl, ShellItemKnownInfo knownInfo) { IShellItem nativeItem = SHCreateItemFromIDList <IShellItem>(pidl); knownInfo.Attributes = LoadMissingAttributes(nativeItem, knownInfo.LoadedAttributes, knownInfo.Attributes, SFGAO.Browsable | SFGAO.Folder); knownInfo.LoadedAttributes |= SFGAO.Browsable | SFGAO.Folder; if ((knownInfo.Attributes & (SFGAO.Browsable | SFGAO.Folder)) != SFGAO.None) { return(new ShellFolder(nativeItem, null, knownInfo)); } else { return(new ShellItem(nativeItem, knownInfo)); } }
private void Init(ShellItemKnownInfo knownInfo) { _loadedAttrs = knownInfo.LoadedAttributes; _attrs = knownInfo.Attributes; _parentParsePath = knownInfo.ParentParsePath; _pidl = new Lazy <IdList>(() => SHGetIDListFromObject(nativeItem)); _parentFolder = new Lazy <ShellFolder>(() => { var nativeParent = nativeItem.GetParent(); if (nativeParent == null) { return(null); } return(new ShellFolder(nativeParent, null, new ShellItemKnownInfo())); }); _desktopAbsoluteParsePath = new Lazy <string>(() => nativeItem.GetDisplayName(SIGDN.DesktopAbsoluteParsing)); _parseName = new Lazy <string>(() => nativeItem.GetDisplayName(SIGDN.ParentRelativeParsing)); _parsePath = new Lazy <string>(() => { if (Pidl.Parts.Count == 0) // The actual desktop { return(""); } try { if (_parentParsePath != null) { string normParentPath = _parentParsePath.Trim('\\'); if (normParentPath != "") { normParentPath += "\\"; } return(normParentPath + ParseName); } else { return(DesktopAbsoluteParsePath); } } catch (ArgumentException) { IdList childPidl = new IdList(Pidl.Parts[Pidl.Parts.Count - 1]); return(GetParentFolder().NativeFolder.GetDisplayNameOf(childPidl, SHGDNF.ForParsing)); } }); _fullParsePath = new Lazy <string>(() => { if (GetParentFolder() == null) { return(""); } string parentParsePath = GetParentFolder().FullParsePath.TrimEnd('\\'); if (parentParsePath != "") { parentParsePath += "\\"; } return(parentParsePath + nativeItem.GetDisplayName(SIGDN.ParentRelativeParsing)); }); /*_displayName = new Lazy<string>(() => GetParentFolder().NativeFolder.GetDisplayNameOf( * new IdList(Pidl.Parts[Pidl.Parts.Count - 1]), * SHGDNF.InFolder | SHGDNF.Normal));*/ _displayName = new Lazy <string>(() => nativeItem.GetDisplayName(SIGDN.NormalDisplay)); }
internal ShellItem(IdList pidl, ShellItemKnownInfo knownInfo) { nativeItem = SHCreateItemFromIDList <IShellItem>(pidl); Init(knownInfo); }
internal ShellItem(IShellItem nativeItem, ShellItemKnownInfo knownInfo) { this.nativeItem = nativeItem; Init(knownInfo); }
internal static ShellItem GetShellItem(IdList pidl, ShellItemKnownInfo knownInfo) { IShellItem nativeItem = SHCreateItemFromIDList<IShellItem>(pidl); knownInfo.Attributes = LoadMissingAttributes(nativeItem, knownInfo.LoadedAttributes, knownInfo.Attributes, SFGAO.Browsable | SFGAO.Folder); knownInfo.LoadedAttributes |= SFGAO.Browsable | SFGAO.Folder; if ((knownInfo.Attributes & (SFGAO.Browsable | SFGAO.Folder)) != SFGAO.None) return new ShellFolder(nativeItem, null, knownInfo); else return new ShellItem(nativeItem, knownInfo); }
internal ShellItem(IdList pidl, ShellItemKnownInfo knownInfo) { nativeItem = SHCreateItemFromIDList<IShellItem>(pidl); Init(knownInfo); }
internal ShellItem(IShellItem nativeItem, ShellItemKnownInfo knownInfo) { this.nativeItem = nativeItem; Init(knownInfo); }