示例#1
0
文件: CCover.cs 项目: da-ka/Vocaluxe
        /// <summary>
        ///     Loads all covers from the theme
        /// </summary>
        private static bool _LoadCovers()
        {
            SThemeCover coverTheme = _GetCoverTheme();

            Debug.Assert(!String.IsNullOrEmpty(coverTheme.Info.Name));

            IEnumerable <string> files = CHelper.ListImageFiles(coverTheme.FolderPath, true, true);

            lock (_Covers)
            {
                foreach (string file in files)
                {
                    _AddCover(Path.GetFileNameWithoutExtension(file), file);
                }
                if (_CoverExists(_NoCoverName))
                {
                    NoCover = _Covers[_NoCoverName];
                }
                else if (_CoverExists(_NoCoverNameAlt))
                {
                    NoCover = _Covers[_NoCoverNameAlt];
                }
                else
                {
                    CLog.Fatal("Covertheme \"{ThemeName}\" does not include a cover file named \"{MissingFileName}\" and cannot be used!", CLog.Params(coverTheme.Info.Name, _NoCoverName));
                    _UnloadCovers();
                    // Remove current theme and recursively try the other themes
                    _CoverThemes.Remove(coverTheme);
                    return(_CoverThemes.Count > 0 && _LoadCovers());
                }
            }
            _LoadCoverGenerators(coverTheme);
            return(true);
        }
示例#2
0
        private static void _LoadAvatars()
        {
            var knownFiles = new List <string>();

            if (_Avatars.Count > 0)
            {
                var ids = new int[_Avatars.Keys.Count];
                _Avatars.Keys.CopyTo(ids, 0);
                foreach (int id in ids)
                {
                    if (_Avatars[id].Reload())
                    {
                        knownFiles.Add(Path.GetFileName(_Avatars[id].FileName));
                    }
                    else
                    {
                        _Avatars.Remove(id);
                    }
                }
            }

            var files = new List <string>();

            foreach (string path in CConfig.ProfileFolders)
            {
                files.AddRange(CHelper.ListImageFiles(path, true, true));
            }

            foreach (string file in files)
            {
                if (knownFiles.Contains(Path.GetFileName(file)))
                {
                    continue;
                }

                CAvatar avatar = CAvatar.GetAvatar(file);
                if (avatar != null)
                {
                    avatar.ID = _AvatarIDs.Dequeue();
                    _Avatars.Add(avatar.ID, avatar);
                }
            }
            _ProfilesChanged = true;
        }