Пример #1
0
        private void bgwCommand_DoWork(FolderIconCommandArguments arguments)
        {
            var parent = arguments.Directory.Parent;

            switch (arguments.Command)
            {
            case FolderIconCommand.GenerateSidecarFiles:
                var parentIcon = DesktopIniParser.GetIcon(parent.FullName);
                GenerateSidecarFilesImpl(arguments.Directory, parentIcon, arguments.PreviewMode, arguments.Recursive);
                break;

            case FolderIconCommand.SetIconTree:
                SetIconTreeImpl(arguments);
                break;

            case FolderIconCommand.SetIconsAuto:
                SetIconAutoImpl(arguments);
                break;

            case FolderIconCommand.FixAttributes:
            case FolderIconCommand.ApplyFolderIcons:
                var parentInfo = FolderIconInfo.Get(parent.FullName);
                ApplyFolderIconsImpl(arguments.Directory, parentInfo, arguments.PreviewMode, arguments.Command == FolderIconCommand.FixAttributes, arguments.Recursive);
                break;
            }
        }
Пример #2
0
        void ApplyFolderIconsImpl(DirectoryInfo current, IconReference parentIcon, bool previewMode, bool fixAttributesOnly = false, bool recursive = true)
        {
            var iniFile  = new DesktopIniParser(current.FullName);
            var icon     = iniFile.Icon;
            var iconInfo = FolderIconInfo.Get(current.FullName);

            //IconReference finalIcon;
            //var isNew = GetCurrentIcon(current, icon, parentIcon, iconInfo, out finalIcon);
            if (parentIcon.IsEmpty)
            {
                var parentDirectory = current.IsRoot()
                                          ? current
                                          : current.Parent;
                parentIcon = new DesktopIniParser(parentDirectory.FullName).Icon;
            }
            var finalIcon = GetCurrentIconFromSidecar(current, iconInfo, parentIcon);

            if (!fixAttributesOnly && !finalIcon.IsEmpty && iniFile.Icon.Resource != finalIcon.Resource)
            {
                ReportProgress(0,
                               $"<<LINK:{finalIcon.Resource}||{finalIcon.Icon.FullName}::500>>\t==>\t<<LINK:{current.FullName}::800>> [<<LINK:{icon.Info}>>]");
                //ReportStatus($"Setting Main Icon To [LINK:{icon.Info}::500] for [LINK:{current.FullName}::800] [Parent: [LINK:{parentIcon.Info}]]");
                if (!previewMode)
                {
                    iniFile.IconResource = finalIcon;
                    iniFile.Save();
                }
            }
            else
            {
                var thisFile = iniFile.Ini;
                var verified = thisFile.VerifyHiddenSystem(!previewMode);
                verified &= thisFile.Directory.VerifySystem(!previewMode);
                verified &= FolderInfoFile.GetFile(thisFile.Directory.FullName, SidecarType.Main).VerifyHiddenSystem(!previewMode);
                if (!verified)
                {
                    ReportProgress(0,
                                   $"*** Fixing desktop.ini attributes for <<LINK:{current.FullName}::1200>> [<<LINK:{icon.Info}>>]");
                }
            }
            if (!recursive)
            {
                return;
            }
            foreach (var child in current.EnumerateDirectoriesSafe())
            {
                ApplyFolderIconsImpl(child, finalIcon.IsEmpty ? parentIcon : finalIcon, previewMode, fixAttributesOnly);
            }
        }
Пример #3
0
        IEnumerable <DirectoryInfo> GetRootFoldersFromDirectory(FolderIconInfo iconInfo)
        {
            var allRoots       = iconInfo.GetRoots();
            var folderIconInfo = FolderIconInfo.Get(iconInfo);

            //TODO: Remove ToArray() and strPaths
            var roots = new [] { iconInfo.Directory }
            .Concat(iconInfo
                    .GetRoots()
                    .Select(x => DirectoriesIO.GetInfo(Directories.Roots.Library, x)))
            .ToArray();
            var strPaths = roots
                           //.Where(p=>Paths.Exists(p.FullName))
                           .Select(p => p.FullName)
                           .ToArray();

            return(roots);
        }