Beispiel #1
0
 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;
 }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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));
            }
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
 internal ShellItem(IdList pidl, ShellItemKnownInfo knownInfo)
 {
     nativeItem = SHCreateItemFromIDList <IShellItem>(pidl);
     Init(knownInfo);
 }
Beispiel #7
0
 internal ShellItem(IShellItem nativeItem, ShellItemKnownInfo knownInfo)
 {
     this.nativeItem = nativeItem;
     Init(knownInfo);
 }
Beispiel #8
0
 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);
 }
Beispiel #9
0
 internal ShellItem(IdList pidl, ShellItemKnownInfo knownInfo)
 {
     nativeItem = SHCreateItemFromIDList<IShellItem>(pidl);
     Init(knownInfo);
 }
Beispiel #10
0
 internal ShellItem(IShellItem nativeItem, ShellItemKnownInfo knownInfo)
 {
     this.nativeItem = nativeItem;
     Init(knownInfo);
 }