Ejemplo n.º 1
0
 private void displaySelectedFriend()
 {
     if (ListBoxFriends.SelectedItems.Count == 1)
     {
         if (ListBoxFriends.SelectedItem is AlteredUser)
         {
             AlteredUser selectedFriend = ListBoxFriends.SelectedItem as AlteredUser;
             TextBoxNickname.Text = selectedFriend.Name;
             if (selectedFriend.PictureNormalURL != null)
             {
                 PictureBoxFriend.LoadAsync(selectedFriend.PictureNormalURL);
             }
             else
             {
                 PictureBoxUser.Image = PictureBoxUser.ErrorImage;
             }
         }
         else
         {
             User selectedFriend = ListBoxFriends.SelectedItem as User;
             TextBoxNickname.Text = selectedFriend.Name;
             if (selectedFriend.PictureNormalURL != null)
             {
                 PictureBoxFriend.LoadAsync(selectedFriend.PictureNormalURL);
             }
             else
             {
                 PictureBoxUser.Image = PictureBoxUser.ErrorImage;
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void TextBoxNickname_Leave(object sender, EventArgs e)
        {
            User selectedFriend = ListBoxFriends.SelectedItem as User;
            int  index          = ListBoxFriends.SelectedIndex;

            if (selectedFriend != null)
            {
                AlteredUser alteredFriend = new AlteredUser();
                alteredFriend.Name             = TextBoxNickname.Text;
                alteredFriend.PictureNormalURL = selectedFriend.PictureNormalURL;
                ListBoxFriends.Items.RemoveAt(index);
                ListBoxFriends.Items.Insert(index, alteredFriend);
            }
        }