コード例 #1
0
        public void GetPCChildItems()
        {
            int iCnt = 0;

            foreach (var item in Browser.GetChildItems(KF_IID.ID_FOLDERID_ComputerFolder))
            {
                // First item is null if we are looking at an item under the desktop item
                var fullIdList = (item.ParentIdList != null ?
                                  PidlManager.Combine(item.ParentIdList, item.ChildIdList) :
                                  item.ChildIdList);

                IKnownFolderProperties props = null;
                using (var kf = KnownFolderHelper.FromPIDL(fullIdList))
                {
                    if (kf != null)
                    {
                        props = KnownFolderHelper.GetFolderProperties(kf.Obj);
                        Assert.IsTrue(props != null);
                    }
                }

                Assert.IsTrue(item != null);
                iCnt++;
            }

            Assert.IsTrue(iCnt > 0);
        }
コード例 #2
0
        /// <summary>
        /// Copy constructor
        /// </summary>
        /// <param name="copyThis"></param>
        public DirectoryBrowser(DirectoryBrowser copyThis)
        {
            if (copyThis == null)
            {
                return;
            }

            _ItemTypeIsInitialized = copyThis._ItemTypeIsInitialized;
            _ItemType = copyThis._ItemType;

            _KnownFolderIsInitialized = copyThis._KnownFolderIsInitialized;
            _KnownFolder = copyThis._KnownFolder;

            _IconResourceIdInitialized = copyThis._IconResourceIdInitialized;
            _IconResourceId            = copyThis._IconResourceId;

            Name      = copyThis.Name;
            ParseName = copyThis.ParseName;
            Label     = copyThis.Label;
            PathRAW   = copyThis.PathRAW;
            PathShell = copyThis.PathShell;

            _PIDLs_Initialized = copyThis._PIDLs_Initialized;
            _ChildIdList       = copyThis._ChildIdList;
            _ParentIdList      = copyThis._ParentIdList;

            SpecialPathId      = copyThis.SpecialPathId;
            IsSpecialParseItem = copyThis.IsSpecialParseItem;

            PathFileSystem = copyThis.PathFileSystem;

            FullName = copyThis.FullName;
        }
コード例 #3
0
        public void GetIconForFonts()
        {
            var path = KF_IID.ID_FOLDERID_Fonts;
            IKnownFolderProperties props = null;

            props = KnownFolderHelper.GetFolderPropertiesFromPath(path);

            Assert.IsTrue(props != null);
        }
コード例 #4
0
        private string LoadIconResourceId()
        {
            lock (resolvePropsLock)
            {
                if (_KnownFolderIsInitialized == false)
                {
                    _KnownFolderIsInitialized = true;
                    _KnownFolder = LoadKnownFolder();
                }
            }

            if (KnownFolder == null)
            {
                return(null);
            }

            bool isKFIconResourceIdValid = false;

            if (KnownFolder != null)
            {
                isKFIconResourceIdValid = KnownFolder.IsIconResourceIdValid();
            }

            if (isKFIconResourceIdValid == false)
            {
                IdList pidl = null;
                LoadPidls();

                if (ChildIdList != null || ParentIdList != null)
                {
                    pidl = PidlManager.CombineParentChild(ParentIdList, ChildIdList);
                }
                else
                {
                    pidl = IdList.Create();
                }

                string filename;
                int    index;

                if (IconHelper.GetIconResourceId(pidl, out filename, out index))
                {
                    // Store filename and index for Desktop Root ResourceId
                    return(string.Format("{0},{1}", filename, index));
                }
            }
            else
            {
                return(KnownFolder.IconResourceId);
            }

            return(null);
        }
コード例 #5
0
        /// <summary>
        /// Resolves remaining properties if <see cref="IsFullyInitialized"/> indicates
        /// missing values (useful for lazy initialization).
        /// </summary>
        public void LoadProperties()
        {
            lock (resolvePropsLock)
            {
                if (_KnownFolderIsInitialized == false)
                {
                    _KnownFolderIsInitialized = true;
                    _KnownFolder = LoadKnownFolder();
                }

                if (_ItemTypeIsInitialized == false)
                {
                    _ItemTypeIsInitialized = true;
                    _ItemType = LoadItemType();
                }

                if (_IconResourceIdInitialized == false)
                {
                    _IconResourceIdInitialized = true;
                    _IconResourceId            = LoadIconResourceId();
                }
            }
        }