Beispiel #1
0
        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);
        }
Beispiel #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;
        }
Beispiel #3
0
        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);
            }
        }