public static int NewAvatar(string fileName) { CAvatar avatar = CAvatar.GetAvatar(fileName); if (avatar == null) { return(-1); } avatar.ID = _AvatarIDs.Dequeue(); _Avatars.Add(avatar.ID, avatar); _AvatarsChanged = true; return(avatar.ID); }
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; }
private static CAvatar _AddAvatar(CBase64Image avatarData) { try { string filename = _SaveImage(avatarData, "snapshot", CConfig.ProfileFolders[0]); CAvatar avatar = CAvatar.GetAvatar(filename); if (avatar != null) { CProfiles.AddAvatar(avatar); return(avatar); } return(null); } catch { return(null); } }