Beispiel #1
0
        public FriendList(string _userId, string _access_token, Authentification _auth)
        {
            users = new List<User>();
            gettedUsers = new List<User>();
            selectedUser = null;
            userId = _userId;
            access_token = _access_token;
            auth = _auth;

            DownloadUsers();

            //timer
            timer = new Timer();
            timer.Interval = 10000;
            timer.Tick += timer_Tick;
        }
Beispiel #2
0
        public void DownloadUsers()
        {

            Uri uri = new Uri("https://api.vk.com/method/friends.get.xml?user_id=" + userId + "&order=hints&fields=sex, bdate, city, country,  photo_50, photo_max_orig, online, last_seen, status, counters, can_write_private_message, can_see_audio" + "&access_token=" + access_token + "&v=5.21");

            var x = new XmlDocument();
            x.Load(uri.ToString());
            var receivedUsers = x.GetElementsByTagName("response")[0];

            users.Clear();
            gettedUsers.Clear();

            int length = receivedUsers.ChildNodes[1].ChildNodes.Count;

            for (int i = 0; i < length; i++)
            {
                var user = new User(receivedUsers.ChildNodes[1].ChildNodes[i]);
                gettedUsers.Add(user);
            }

            users = gettedUsers.OrderByDescending(us => int.Parse(us.online)).ToList();
            users = users.OrderByDescending(us => us.status_audio_id != "").ToList();
        }
Beispiel #3
0
        public void UpdateUsers()
        {
            bool b = false;
            again:try
            {
                Uri uri = new Uri("https://api.vk.com/method/friends.get.xml?user_id=" + userId + "&order=hints&fields=photo_50, online, last_seen, status, counters, can_write_private_message, can_see_audio" + "&access_token=" + access_token + "&v=5.21");

                var x = new XmlDocument();
                x.Load(uri.ToString());
                var receivedUsers = x.GetElementsByTagName("response")[0];

                int length = receivedUsers.ChildNodes[1].ChildNodes.Count;
                for (int i = 0; i < length; i++)
                {
                    var user = new User(receivedUsers.ChildNodes[1].ChildNodes[i]);
                    var tmpUser = users.FirstOrDefault(z => z.id == user.id);
                    if (tmpUser != null)
                        tmpUser.UpdateDataFrom(user);
                    else
                        users.Add(tmpUser);
                }

                users = users.OrderBy(d => gettedUsers.IndexOf(d)).ToList();
                try
                {
                    users = users.OrderByDescending(us => us.online == "1").ToList();
                }
                catch { }
                users = users.OrderByDescending(us => us.status_audio_id != "").ToList();
            }
            catch
            {
                if (!b)
                {
                    auth();
                    b = true;
                    goto again;
                }
                else
                    System.Windows.Forms.Application.Restart();
            }
        }
Beispiel #4
0
 internal void SelectUser(int index)
 {
     if (index >= 0)
     {
         if (CanGetTracks(index))
         {
             selectedUser = users[index];
             if (!selectedUser.IsDownloaded)
                 selectedUser.DownloadTrackList(access_token);
         }
     }
 }
Beispiel #5
0
 internal void UpdateDataFrom(User user)
 {
     this.can_see_audio = user.can_see_audio;
     this.can_write_private_message = user.can_write_private_message;
     this.last_seen_platform = user.last_seen_platform;
     this.last_seen_time = user.last_seen_time;
     this.online = user.online;
     if (!this.photo_50.Equals(user.photo_50))
     {
         this.photo_50 = user.photo_50;
         DownloadImage();
     }
     this.status = user.status;
     this.status_audio_artist = user.status_audio_artist;
     this.status_audio_id = user.status_audio_id;
     this.status_audio_owner_id = user.status_audio_owner_id;
     this.status_audio_title = user.status_audio_title;
     this.status_audio_url = user.status_audio_url;
 }
Beispiel #6
0
 internal void SetDataFrom(User user)
 {
     this.bdate = user.bdate;
     this.can_see_audio = user.can_see_audio;
     this.can_write_private_message = user.can_write_private_message;
     this.city = user.city;
     this.country = user.country;
     this.first_name = user.first_name;
     this.last_name = user.last_name;
     this.last_seen_platform = user.last_seen_platform;
     this.last_seen_time = user.last_seen_time;
     this.online = user.online;
     this.photo_100 = user.photo_100;
     this.photo_200 = user.photo_200;
     this.photo_200_orig = user.photo_200_orig;
     this.photo_400_orig = user.photo_400_orig;
     this.photo_50 = user.photo_50;
     this.photo_max = user.photo_max;
     this.photo_max_orig = user.photo_max_orig;
     this.sex = user.sex;
     this.status = user.status;
     this.status_audio_artist = user.status_audio_artist;
     this.status_audio_id = user.status_audio_id;
     this.status_audio_owner_id = user.status_audio_owner_id;
     this.status_audio_title = user.status_audio_title;
     this.status_audio_url = user.status_audio_url;
 }