private void listViewFriends_SelectedIndexChanged(object sender, EventArgs e) { if ((sender as ListView).SelectedItems.Count > 0) { listBoxFriendStatuses.Items.Clear(); listBoxFriendEvents.Items.Clear(); listBoxFriendCheckIns.Items.Clear(); listBoxStatusComments.Items.Clear(); labelEventName.Text = String.Empty; labelEventLocation.Text = String.Empty; labelEventTime.Text = String.Empty; pictureBoxEventPicture.Hide(); pictureBoxCheckinsMap.Hide(); UserListViewItem userListViewItem = (sender as ListView).SelectedItems[0] as UserListViewItem; User friend = userListViewItem.User; pictureBoxFriendLarge.LoadAsync(friend.PictureLargeURL); labelFriendName.Text = friend.Name; labelFriendLocation.Text = friend.Location == null ? string.Empty : "Location: " + friend.Location.Name; labelFriendBirthday.Text = friend.Birthday == null ? string.Empty : "Birthday: " + friend.Birthday; labelFriendRelationshipStatus.Text = friend.RelationshipStatus == null ? string.Empty : "Relationship Status: " + friend.RelationshipStatus; labelFriendIntrestedIn.Text = friend.InterestedIn == null ? string.Empty : "Interested In: " + friend.InterestedIn.ToString(); labelFriendBio.Text = friend.Bio == null ? string.Empty : "Bio: " + friend.Bio; new Thread(() => { var friendStatuses = friend.Statuses; var friendEvents = friend.Events; var friendCheckins = friend.Checkins; foreach (Status status in friendStatuses) { Invoke(new Action(() => listBoxFriendStatuses.Items.Add(status))); } foreach (Event friendEvent in friendEvents) { Invoke(new Action(() => listBoxFriendEvents.Items.Add(friendEvent))); } foreach (Checkin checkin in friendCheckins) { Invoke(new Action(() => listBoxFriendCheckIns.Items.Add(new CheckInListBoxAdapter(checkin)))); } }).Start(); } }
private void addFriendToListViewAsync(object i_ListView) { if (this.InvokeRequired) { AddItemCallback a = new AddItemCallback(addFriendToListViewAsync); Invoke(a, new object[] { i_ListView }); } else { foreach (User friend in User.Friends) { PictureBox pb = new PictureBox(); pb.Load(friend.PictureSmallURL); Image img = pb.Image; UserListViewItem userListViewItem = new UserListViewItem(friend); userListViewItem.ImageKey = friend.Name; userListViewItem.Name = friend.Name; userListViewItem.Text = friend.Name; this.LargeImageList.Images.Add(friend.Name, img); this.Items.Add(userListViewItem); } } }
private void initFriendsPanel() { var userFriends = m_User.Friends; Invoke( new Action(() => { listViewFriends.View = View.LargeIcon; listViewFriends.LargeImageList.ImageSize = new Size(64, 64); listViewFriends.LargeImageList.ColorDepth = ColorDepth.Depth24Bit; OprogressBarLoginAndFetchData.Maximum = m_User.Friends.Count + OprogressBarLoginAndFetchData.Value; }), null); foreach (User friend in m_User.Friends) { PictureBox pictureBox = new PictureBox(); pictureBox.Load(friend.PictureSmallURL); Image friendImage = pictureBox.Image; UserListViewItem userListViewItem = new UserListViewItem(friend); userListViewItem.ImageKey = friend.Name; userListViewItem.Name = friend.Name; userListViewItem.Text = friend.Name; Invoke(new Action(() => { listViewFriends.LargeImageList.Images.Add(friend.Name, friendImage); listViewFriends.Items.Add(userListViewItem); OprogressBarLoginAndFetchData.IncrementByOne(); })); } Invoke(new Action(() => { OprogressBarLoginAndFetchData.Reset(); m_LoginAndDataFetchCompleted = true; })); }