void GenerateSidecarFilesImpl(DirectoryInfo current, IconReference parentIcon, bool previewMode, bool recursive = true) { var icon = DesktopIniParser.GetIcon(current.FullName); var infoFile = new FolderInfoFile(current); var info = infoFile.Object; var iconInfo = infoFile.Object.Icon; //IconReference finalIcon; //var isNew = GetCurrentIconFromIni(current, icon, parentIcon, iconInfo, out finalIcon); var finalIcon = icon; var isNew = (icon.Resource != parentIcon.Resource && !icon.IsEmpty); if (isNew) { ReportProgress(0, $"Setting Main Icon To <<LINK:{finalIcon.Info}::500>> for <<LINK:{current.FullName}::800>> [<<LINK:{parentIcon.Info}>>]"); //ReportStatus($"Setting Main Icon To [LINK:{icon.Info}::500] for [LINK:{current.FullName}::800] [Parent: [LINK:{parentIcon.Info}]]"); if (!previewMode) { info.Icon.Main = finalIcon.Resource; infoFile.Save(); } } if (!recursive) { return; } foreach (var child in current.EnumerateDirectoriesSafe()) { GenerateSidecarFilesImpl(child, finalIcon.IsEmpty ? parentIcon : finalIcon, previewMode); } }
private void SaveIconToSidecarImpl() { var directory = SelectedDirectory; var icon = IconReference.FromResource(directory.FullPath, SelectedIcon.FullPath); var directoryInfo = new DirectoryInfo(directory.FullPath); var infoFile = new FolderInfoFile(directoryInfo); var info = infoFile.Object; info.Icon.Main = icon.Resource; infoFile.Save(); directory.Image.Refresh(); directory.OnPropertyChanged(nameof(directory.SidecarExists)); directory.OnPropertyChanged(nameof(directory.Sidecar)); }
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); } }
private void SaveIconToSidecarImpl() { var directory = SelectedDirectory; var icon = IconReference.FromResource(directory.FullPath, SelectedIcon.FullPath); var directoryInfo = new DirectoryInfo(directory.FullPath); //TODO: Simplify Access to FolderInfoFile Constructor var infoFile = new FolderInfoFile(directoryInfo, SidecarType.Main, null); var info = infoFile.Object; info.Icon.Main = icon.Resource; infoFile.Save(); directory.Image.Result.Refresh(); directory.OnPropertyChanged(nameof(directory.SidecarExists)); directory.OnPropertyChanged(nameof(directory.Sidecar)); }