예제 #1
0
        private void DeleteComment(object sender, RoutedEventArgs e)
        {
            DeletePrompt prompt = new DeletePrompt(this);

            prompt.SetMessage("This action cannot be undone, are you sure you want to proceed?");
            prompt.ShowDialog();
            if (prompt.confirmed == true)
            {
                this.username                = "******";
                this.comment                 = "[deleted]";
                this.commentBox.Text         = "[deleted]";
                this.usernameText.Text       = "[deleted]";
                this.commentBox.Foreground   = Brushes.Red;
                this.usernameText.Foreground = Brushes.Red;
                this.replyButton.IsEnabled   = false;
                this.CurrentUser             = false;
                this.deleted                 = true;
            }
        }
예제 #2
0
        protected void ButtonClick(object sender, EventArgs e)
        {
            if (main.signedIn)
            {
                if (sender.Equals(PostCommentButton))
                {
                    if (replyFlag == 0)
                    {
                        Comment newComment = new Comment(main.currUser.UserName, CommentBox.Text, this);
                        newComment.CurrentUser = true;
                        commentsFeed.Children.Add(newComment);
                        ScrollViewComments.ScrollToEnd();
                        discussion.GetComments().Add(newComment);
                        CommentBox.Text        = "";
                        CommentBoxDefault.Text = "Type a message...";
                        discussion.numReplies++;
                        string repliesString = discussion.numReplies.ToString();
                        repliesString             += (discussion.numReplies != 1) ? " replies" : " reply";
                        NumRepliesButton.Content   = repliesString;
                        discussion.replyCount.Text = repliesString;
                        CommentBox.Focus();
                        //parent.GetDiscussionDict()[discussion.GetDiscussionId()] = discussion;
                    }
                    else if (replyFlag == 1)
                    {
                        //string[] reply = CommentBox.Text.Split('\n');
                        Comment newComment = new Comment(main.currUser.UserName, CommentBox.Text, this);
                        newComment.CurrentUser = true;
                        commentToReplyTo.repliesFeed.Children.Add(newComment);
                        CommentBox.Text        = "";
                        CommentBoxDefault.Text = "Type a message...";
                        replyFlag        = 0;
                        commentToReplyTo = null;
                        discussion.numReplies++;
                        string repliesString = discussion.numReplies.ToString();
                        repliesString             += (discussion.numReplies != 1) ? " replies" : " reply";
                        NumRepliesButton.Content   = repliesString;
                        discussion.replyCount.Text = repliesString;
                        CommentBox.Focus();
                    }
                }
                else if (sender.Equals(DeleteButton))
                {
                    DeletePrompt prompt = new DeletePrompt(main, this);
                    prompt.SetMessage("This action cannot be undone, are you sure you want to proceed?");
                    prompt.ShowDialog();
                    main.HighlightTab();
                    if (prompt.confirmed == true)
                    {
                        // remove from discussions page
                        main.currDiscussionPage.discussionDict.Remove(discussion.discussionId);
                        main.currDiscussionPage.DisplayDiscussionPosts();
                        // remove from user's profile page
                        main.currUser.userDiscussions.Remove(discussion.discussionId);
                        main.currProfilePage.DisplayPosts();
                        // close popup window
                        this.Visibility = Visibility.Hidden;
                        main.ChangeFill(Visibility.Hidden);
                    }
                }
                else if (sender.Equals(EditButton))
                {
                    if (editable == false)
                    {
                        EditButton.Content    = "Save Changes";
                        EditButton.Background = Brushes.Yellow;

                        editable = true;

                        descriptionTextBox.Text          = DiscussionDescription.Text;
                        DiscussionDescription.Visibility = Visibility.Hidden;
                        descriptionTextBox.Visibility    = Visibility.Visible;
                        Keyboard.Focus(descriptionTextBox);
                        descriptionTextBox.CaretIndex = descriptionTextBox.Text.Length;
                    }
                    else
                    {
                        EditButton.Content               = "EDIT";
                        EditButton.Background            = Brushes.LightGray;
                        DiscussionDescription.Visibility = Visibility.Visible;
                        editable = false;
                        updateDescription();
                    }
                }
                else if (sender.Equals(saveButton))
                {
                    if (!discussion.saved)
                    {
                        // Create a new instance with the same attributes
                        Discussion copyOfDiscussion = new Discussion(discussion.discussionId, discussion.user, discussion.title, discussion.description, discussion.numReplies);
                        copyOfDiscussion.score    = discussion.score;
                        copyOfDiscussion.main     = discussion.main;
                        copyOfDiscussion.comments = discussion.comments;

                        // Set the saved flag of the new Discussion to true
                        copyOfDiscussion.Saved = true;
                        //  Pass it to SavedPage.AddPost()
                        main.currSavedPage.AddPost(copyOfDiscussion);

                        // Set the Saved button content of this discussion to Unsave
                        // Set the saved flag of this dicussion to true
                        discussion.saved = true;
                        discussion.saveDiscussion.Content = "Unsave";
                        saveButton.Content = "Unsave";
                    }
                    else if (discussion.saved)
                    {
                        discussion.saved = false;

                        main.currSavedPage.RemovePost(discussion);
                        main.currDiscussionPage.SetDiscussionUnsaved(discussion);
                        discussion.saveDiscussion.Content = "Save";
                        saveButton.Content = "Save";
                    }
                }
                else if (sender.Equals(MessageUserButton))
                {
                    MessageDevelopmentPrompt prompt = new MessageDevelopmentPrompt(this);
                    prompt.ShowDialog();
                }
            }
            else if (!main.signedIn)
            {
                if (sender.Equals(saveButton))
                {
                    NoBlurPrompt prompt = new NoBlurPrompt(main, this);
                    prompt.SetMessage("You must sign in to save posts.");
                    prompt.ShowDialog();
                    main.HighlightTab();
                }
                else
                {
                    NoBlurPrompt prompt = new NoBlurPrompt(main, this);
                    prompt.SetMessage("You must sign in to discuss with users.");
                    prompt.ShowDialog();
                    main.HighlightTab();
                }
            }
        }
예제 #3
0
        private void ButtonClick(object sender, EventArgs e)
        {
            if (main.signedIn)
            {
                if (sender.Equals(postCommentButton))
                {
                    if (replyFlag == 0)
                    {
                        Comment newComment = new Comment(main.currUser.UserName, commentBox.Text, this);
                        newComment.CurrentUser = true;
                        commentFeed.Children.Add(newComment);
                        photoAndComments.ScrollToEnd();
                        photo.comments.Add(newComment);
                        commentBox.Text        = "";
                        commentBoxDefault.Text = "Type a comment...";
                        // Unnecessary line. Same as DiscussionPopup.
                        //parent.photoDict[photo.photoId] = photo;
                        photo.commentCount++;
                        string repliesString = photo.commentCount.ToString();
                        repliesString           += (photo.commentCount != 1) ? " replies" : " reply";
                        NumRepliesButton.Content = repliesString;
                        commentBox.Focus();
                    }
                    else if (replyFlag == 1)
                    {
                        //string[] reply = commentBox.Text.Split('\n');
                        Comment newComment = new Comment(main.currUser.UserName, commentBox.Text, this);
                        newComment.CurrentUser = true;
                        commentToReplyTo.repliesFeed.Children.Add(newComment);
                        commentBox.Text        = "";
                        commentBoxDefault.Text = "Type a comment...";
                        replyFlag        = 0;
                        commentToReplyTo = null;
                        photo.commentCount++;
                        string repliesString = photo.commentCount.ToString();
                        repliesString           += (photo.commentCount != 1) ? " replies" : " reply";
                        NumRepliesButton.Content = repliesString;
                        commentBox.Focus();
                    }
                }
                else if (sender.Equals(DeleteButton))
                {
                    DeletePrompt prompt = new DeletePrompt(main, this);
                    prompt.SetMessage("This action cannot be undone, are you sure you want to proceed?");
                    prompt.ShowDialog();
                    main.HighlightTab();
                    if (prompt.confirmed == true)
                    {
                        // remove from photos page
                        main.currPhotosPage.photoDict.Remove(photo.photoId);
                        main.currPhotosPage.DisplayPhotos();
                        // remove from user's profile page
                        main.currUser.userPhotos.Remove(photo.photoId);
                        main.currProfilePage.DisplayPosts();
                        // close popup window
                        this.Visibility = Visibility.Hidden;
                        main.ChangeFill(Visibility.Hidden);
                    }
                }
                else if (sender.Equals(EditButton))
                {
                    if (editable == false)
                    {
                        EditButton.Content    = "Save Changes";
                        EditButton.Background = Brushes.Yellow;

                        editable = true;

                        captionTextBox.Text       = description.Text;
                        description.Visibility    = Visibility.Hidden;
                        captionTextBox.Visibility = Visibility.Visible;
                        Keyboard.Focus(captionTextBox);
                        captionTextBox.CaretIndex = captionTextBox.Text.Length;
                    }
                    else
                    {
                        EditButton.Content     = "EDIT";
                        EditButton.Background  = Brushes.LightGray;
                        description.Visibility = Visibility.Visible;
                        editable = false;
                        updateCaption();
                    }
                }
                else if (sender.Equals(saveButton))
                {
                    if (!photo.Saved)
                    {
                        // Create a new instance with the same attributes
                        Photo copyOfPhoto = new Photo(photo.photoId, photo.imageName.Source);
                        copyOfPhoto.title    = photo.title;
                        copyOfPhoto.caption  = photo.caption;
                        copyOfPhoto.username = photo.username;
                        copyOfPhoto.ageDays  = photo.ageDays;
                        copyOfPhoto.ageHours = photo.ageHours;
                        copyOfPhoto.time     = photo.time;
                        copyOfPhoto.score    = photo.score;
                        copyOfPhoto.main     = photo.main;
                        copyOfPhoto.displaySideInfo();
                        copyOfPhoto.comments     = photo.comments;
                        copyOfPhoto.commentCount = photo.commentCount;
                        copyOfPhoto.upvoted      = photo.upvoted;

                        // Set the saved flag of the new Discussion to true
                        copyOfPhoto.Saved = true;
                        //  Pass it to SavedPage.AddPost()
                        main.currSavedPage.AddPost(copyOfPhoto);

                        // Set the Saved button content of this discussion to Unsave
                        // Set the saved flag of this dicussion to true
                        photo.Saved        = true;
                        saveButton.Content = "Unsave";
                    }
                    else if (photo.Saved)
                    {
                        photo.Saved = false;
                        main.currSavedPage.RemovePost(photo);
                        main.currPhotosPage.SetPhotoUnsaved(photo);
                        saveButton.Content = "Save";
                    }
                }
                else if (sender.Equals(MessageUserButton))
                {
                    MessageDevelopmentPrompt prompt = new MessageDevelopmentPrompt(this);
                    prompt.ShowDialog();
                }
            }
            else if (!main.signedIn)
            {
                if (sender.Equals(saveButton))
                {
                    NoBlurPrompt prompt = new NoBlurPrompt(main, this);
                    prompt.SetMessage("You must sign in to save posts.");
                    prompt.ShowDialog();
                    main.HighlightTab();
                }
                else
                {
                    NoBlurPrompt prompt = new NoBlurPrompt(main, this);
                    prompt.SetMessage("You must sign in to discuss with users.");
                    prompt.ShowDialog();
                    main.HighlightTab();
                }
            }
        }