コード例 #1
0
        internal void DisplayAlbums()
        {
            string albumPictureURL          = string.Empty;
            bool   hasShownExceptionMessage = false;

            lock (r_PanelToDisplayIn)
            {
                r_PanelToDisplayIn.Invoke(new Action(() => r_PanelToDisplayIn.Controls.Clear()));
                foreach (Album currentAlbum in r_AlbumsOfUser)
                {
                    if (currentAlbum.Count > 0)
                    {
                        PictureWrapper currentAlbumPictureWrapper;
                        PictureBox     currentAlbumPictureBox;

                        try
                        {
                            albumPictureURL = currentAlbum.CoverPhoto.PictureNormalURL;
                        }
                        catch (Facebook.FacebookApiException)
                        {
                            // current album has no cover photo, we handle this within PictureWrapper in the form of empty url string.
                        }
                        finally
                        {
                            try
                            {
                                currentAlbumPictureWrapper         = new PictureWrapper(albumPictureURL);
                                currentAlbumPictureBox             = currentAlbumPictureWrapper.PictureBox;
                                currentAlbumPictureBox.Enabled     = false;
                                currentAlbumPictureBox.Cursor      = Cursors.Hand;
                                currentAlbumPictureBox.MouseEnter += new EventHandler(album_Enter);
                                currentAlbumPictureBox.MouseLeave += new EventHandler(album_Leave);
                                currentAlbumPictureBox.Click      += (sender, e) =>
                                {
                                    FacebookView.CreateThread(() => album_Click(currentAlbum));
                                };
                                r_PanelToDisplayIn.Invoke(new Action(() => r_PanelToDisplayIn.Controls.Add(currentAlbumPictureBox)));
                            }
                            catch (FacebookApiLimitException ex)
                            {
                                if (!hasShownExceptionMessage)
                                {
                                    hasShownExceptionMessage = true;
                                    MessageBox.Show(ex.Message);
                                }
                            }
                        }
                    }
                }

                foreach (Control currItem in r_PanelToDisplayIn.Controls)
                {
                    currItem.Enabled = true;
                }
            }
        }
コード例 #2
0
        private void showFriendProfilePicture(AppUser i_Friend, ref bool io_HasShownMessageBox)
        {
            string profilePictureURL = string.Empty;
            string firstName         = string.Empty;
            string lastName          = string.Empty;

            try
            {
                firstName         = i_Friend.FirstName;
                lastName          = i_Friend.LastName;
                profilePictureURL = i_Friend.ProfilePicture;
            }
            catch (Exception ex)
            {
                if (!io_HasShownMessageBox)
                {
                    MessageBox.Show(ex.Message);
                    io_HasShownMessageBox = true;
                }
            }
            finally
            {
                try
                {
                    PictureWrapper         friendPictureWrapper = new PictureWrapper(profilePictureURL);
                    DetailedProfilePicture friendPicture        = new DetailedProfilePicture(
                        friendPictureWrapper.PictureBox,
                        firstName,
                        lastName);
                    friendPicture.FriendProfilePicture.Enabled = false;
                    if (FriendOnClickDelegate != null)
                    {
                        friendPicture.FriendProfilePicture.Name   = string.Format("{0} {1}", firstName, lastName);
                        friendPicture.FriendProfilePicture.Cursor = Cursors.Hand;
                        friendPicture.FriendProfilePicture.Click += (user, e) => FriendOnClickDelegate.Invoke(friendPicture.FriendProfilePicture, new AppUserEventArgs(i_Friend));
                    }

                    r_DisplayPanel.Invoke(new Action(() => r_DisplayPanel.Controls.Add(friendPicture.FriendProfilePicture)));
                }
                catch (FacebookApiLimitException ex)
                {
                    if (!io_HasShownMessageBox)
                    {
                        io_HasShownMessageBox = true;
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
コード例 #3
0
        private void album_Click(Album i_ClickedAlbum)
        {
            bool hasShownExceptionMessage = false;

            lock (r_PanelToDisplayIn)
            {
                r_PanelToDisplayIn.Invoke(new Action(() => r_PanelToDisplayIn.Controls.Clear()));
                if (AlbumClickedAction != null)
                {
                    AlbumClickedAction.Invoke();
                }

                try
                {
                    foreach (Photo currentPhoto in i_ClickedAlbum.Photos)
                    {
                        try
                        {
                            PictureWrapper currentPictureWrapper  = new PictureWrapper(currentPhoto.PictureNormalURL);
                            PictureBox     currentPhotoPictureBox = currentPictureWrapper.PictureBox;

                            r_PanelToDisplayIn.Invoke(new Action(() => r_PanelToDisplayIn.Controls.Add(currentPhotoPictureBox)));
                        }
                        catch (FacebookApiLimitException ex)
                        {
                            if (!hasShownExceptionMessage)
                            {
                                hasShownExceptionMessage = true;
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #4
0
        private void fetchPosts()
        {
            FacebookObjectCollection <Post> allPosts;
            bool hasShownExceptionMessage = false;

            postsRoundedButton.Invoke(new Action(() => postsRoundedButton.Enabled = false));
            tableLayoutPanelPosts.Invoke(new Action(() => tableLayoutPanelPosts.Controls.Clear()));
            tableLayoutPanelPosts.Invoke(new Action(() => tableLayoutPanelPosts.RowStyles.Clear()));
            try
            {
                allPosts = r_AppEngine.Posts;
                if (allPosts != null && allPosts.Count > 0)
                {
                    foreach (Post currentPost in allPosts)
                    {
                        bool  isLegalPost = false;
                        Label postDetails;

                        postDetails = new Label
                        {
                            Text = string.Format(
                                "Posted at: {0}{1}Post Type: {2}{3}",
                                currentPost.CreatedTime.ToString(),
                                Environment.NewLine,
                                currentPost.Type,
                                Environment.NewLine)
                        };
                        postDetails.AutoSize = true;

                        if (currentPost.Message != null)
                        {
                            addPostData(currentPost.Message, ref isLegalPost);
                        }

                        if (currentPost.Caption != null)
                        {
                            addPostData(currentPost.Caption, ref isLegalPost);
                        }

                        if (currentPost.Type == Post.eType.photo)
                        {
                            try
                            {
                                PictureWrapper postPictureWrapper = new PictureWrapper(currentPost.PictureURL);
                                PictureBox     postPicture        = postPictureWrapper.PictureBox;

                                tableLayoutPanelPosts.Invoke(new Action(() => tableLayoutPanelPosts.Controls.Add(postPicture)));
                                isLegalPost = true;
                            }
                            catch (FacebookApiLimitException ex)
                            {
                                if (!hasShownExceptionMessage)
                                {
                                    hasShownExceptionMessage = true;
                                    MessageBox.Show(ex.Message);
                                }
                            }
                        }

                        if (isLegalPost == true)
                        {
                            Label seperator = new Label {
                                Text = " ", AutoSize = true
                            };

                            tableLayoutPanelPosts.Invoke(new Action(() => tableLayoutPanelPosts.Controls.Add(postDetails)));
                            tableLayoutPanelPosts.Invoke(new Action(() => tableLayoutPanelPosts.Controls.Add(seperator)));
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No Posts to retrieve :(");
                }
            }
            catch (Exception exPosts)
            {
                MessageBox.Show(string.Format("Error! could'nt fetch posts - {0}.", exPosts.Message));
            }
        }