Exemplo n.º 1
0
 private void PhotosListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (FriendsByStatusListBox.SelectedItems.Count == 1)
     {
         UserPrototype selectedFriend = FriendsByStatusListBox.SelectedItem as UserPrototype;
         FriendByStatusPictureBox.LoadAsync(selectedFriend.PictureNormalURL);
     }
 }
Exemplo n.º 2
0
        public static void DisplayFriendByStatusAndGender(FormFacebook i_FacebookForm, User i_LoggedInUser)
        {
            i_FacebookForm.FriendsByStatusListBox.Items.Clear();
            i_FacebookForm.FriendsByStatusListBox.DisplayMember = "Name";

            bool isMale    = i_FacebookForm.MaleButton.Checked == true;
            bool isMarried = i_FacebookForm.MarriedFriendsButton.Checked == true;
            bool isSingle  = i_FacebookForm.SingleFriendButton.Checked == true;

            User.eRelationshipStatus e_UserStatus;
            User.eGender             e_UserGender;
            try
            {
                foreach (User friend in i_LoggedInUser.Friends)
                {
                    e_UserGender = (User.eGender)friend.Gender;
                    e_UserStatus = (User.eRelationshipStatus)friend.RelationshipStatus;

                    bool checkIfAddToTheList =
                        (isMale && isSingle && e_UserGender == User.eGender.male && e_UserStatus == User.eRelationshipStatus.Single) ||
                        (isMale && isMarried && e_UserGender == User.eGender.male && e_UserStatus == User.eRelationshipStatus.Married) ||
                        (!isMale && isSingle && e_UserGender == User.eGender.female && e_UserStatus == User.eRelationshipStatus.Single) ||
                        (!isMale && isMarried && e_UserGender == User.eGender.female && e_UserStatus == User.eRelationshipStatus.Married);

                    if (checkIfAddToTheList)
                    {
                        if (i_FacebookForm.FriendsByStatusListBox.Items.Count > 0)
                        {
                            UserPrototype friendPrototype  = (UserPrototype)i_FacebookForm.FriendsByStatusListBox.Items[0];
                            UserPrototype newUserPrototype = friendPrototype.ShalowClone();
                            newUserPrototype.m_Name           = friend.Name;
                            newUserPrototype.PictureNormalURL = friend.PictureNormalURL;
                            i_FacebookForm.FriendsByStatusListBox.Items.Add(newUserPrototype);
                        }
                        else
                        { ////first user add to the list box
                            UserPrototype firstUserPrototype = new UserPrototype
                            {
                                m_Name           = friend.Name,
                                e_Gender         = (eGender)friend.Gender,
                                e_UserStatus     = (eRelationshipStatus)friend.RelationshipStatus,
                                PictureNormalURL = friend.PictureNormalURL
                            };
                            i_FacebookForm.FriendsByStatusListBox.Items.Add(firstUserPrototype);
                        }

                        i_FacebookForm.FriendsByStatusListBox.Items.Add(friend);
                        friend.ReFetch(DynamicWrapper.eLoadOptions.Full);
                    }
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("feature unavailable because of facebook");
            }

            if (i_LoggedInUser.Friends.Count == 0)
            {
                MessageBox.Show("No Friends to retrieve ");
            }
        }