Пример #1
0
 /// <summary>
 /// Interaction logic for voting button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void upVote(object sender, RoutedEventArgs e)
 {
     if (main.signedIn)
     {
         if (upvoted == false)
         {
             upvoted = true;
             String      stringPath  = "Images/Icons/arrow.png";
             Uri         imageUri    = new Uri(stringPath, UriKind.Relative);
             BitmapImage imageBitmap = new BitmapImage(imageUri);
             upvoteImage.Source = imageBitmap;
             score++;
             sideScore.Text = score.ToString();
         }
         else
         {
             upvoted = false;
             String      stringPath  = "Images/Icons/arrow_blank.png";
             Uri         imageUri    = new Uri(stringPath, UriKind.Relative);
             BitmapImage imageBitmap = new BitmapImage(imageUri);
             upvoteImage.Source = imageBitmap;
             score--;
             sideScore.Text = score.ToString();
         }
     }
     else if (!main.signedIn)
     {
         LoginPrompt prompt = new LoginPrompt(main);
         prompt.SetMessage("You must sign in to upvote photos.");
         prompt.ShowDialog();
         main.HighlightTab();
     }
 }
Пример #2
0
        /// <summary>
        /// Interaction logic for save button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void savePhoto_Click(object sender, RoutedEventArgs e)
        {
            if (main.signedIn)
            {
                if (!saved)
                {
                    // Create a new instance with the same attributes
                    Photo copyOfPhoto = new Photo(photoId, imageName.Source);
                    copyOfPhoto.title    = this.title;
                    copyOfPhoto.caption  = this.caption;
                    copyOfPhoto.username = this.username;
                    copyOfPhoto.ageDays  = this.ageDays;
                    copyOfPhoto.ageHours = this.ageHours;
                    copyOfPhoto.time     = this.time;
                    copyOfPhoto.score    = this.score;
                    copyOfPhoto.main     = this.main;
                    copyOfPhoto.displaySideInfo();
                    copyOfPhoto.comments     = this.comments;
                    copyOfPhoto.commentCount = this.commentCount;
                    copyOfPhoto.upvoted      = this.upvoted;
                    copyOfPhoto.IsPrivate    = this.IsPrivate;

                    // 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
                    this.Saved = true;
                }
                else if (saved)
                {
                    this.Saved = false;
                    main.currSavedPage.RemovePost(this);
                    main.currPhotosPage.SetPhotoUnsaved(this);
                }
            }
            else if (!main.signedIn)
            {
                LoginPrompt prompt = new LoginPrompt(main);
                prompt.SetMessage("You must sign in to save photos.");
                prompt.ShowDialog();
                main.HighlightTab();
            }
        }
 private void FollowClick(object sender, RoutedEventArgs e)
 {
     if (main.signedIn)
     {
         if ((followButton.Content as string) == "Follow")
         {
             followButton.Content  = "Unfollow";
             main.followingSomeone = true;
         }
         else if ((followButton.Content as string) == "Unfollow")
         {
             followButton.Content  = "Follow";
             main.followingSomeone = false;
         }
     }
     else
     {
         LoginPrompt prompt = new LoginPrompt(main);
         prompt.SetMessage("You must sign in to follow other users.");
         prompt.ShowDialog();
         main.HighlightTab();
     }
 }
Пример #4
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            if (main.signedIn)
            {
                if (!saved)
                {
                    // Create a new instance with the same attributes
                    Discussion copyOfDiscussion = new Discussion(discussionId, user, title, description, numReplies);
                    copyOfDiscussion.score    = this.score;
                    copyOfDiscussion.main     = this.main;
                    copyOfDiscussion.comments = this.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
                    this.Saved = true;
                }
                else if (saved)
                {
                    this.Saved = false;

                    main.currSavedPage.RemovePost(this);
                    main.currDiscussionPage.SetDiscussionUnsaved(this);
                }
            }
            else if (!main.signedIn)
            {
                LoginPrompt prompt = new LoginPrompt(main);
                prompt.SetMessage("You must sign in to save discussions.");
                prompt.ShowDialog();
                main.HighlightTab();
            }
        }
 private void DevClick(object sender, RoutedEventArgs e)
 {
     if (main.signedIn)
     {
         if (sender.Equals(messageButton))
         {
             MessageDevelopmentPrompt prompt = new MessageDevelopmentPrompt(this);
             main.ChangeFill(Visibility.Visible);
             prompt.ShowDialog();
         }
         else if (sender.Equals(blockButton))
         {
             MessageDevelopmentPrompt prompt = new MessageDevelopmentPrompt(this);
             prompt.SetMessage("Blocking is currently under development.");
             main.ChangeFill(Visibility.Visible);
             prompt.ShowDialog();
         }
     }
     else
     {
         if (sender.Equals(messageButton))
         {
             LoginPrompt prompt = new LoginPrompt(main);
             prompt.SetMessage("You must sign in to message other users.\n(This feature is under development)");
             prompt.ShowDialog();
             main.HighlightTab();
         }
         else if (sender.Equals(blockButton))
         {
             LoginPrompt prompt = new LoginPrompt(main);
             prompt.SetMessage("You must sign in to block users.\n(This feature is under development)");
             prompt.ShowDialog();
             main.HighlightTab();
         }
     }
 }
Пример #6
0
 protected void Button_Click(Object sender, EventArgs e)
 {
     if ((sender.Equals(followingTab)) || (sender.Equals(logoButton)))
     {
         if (signedIn)
         {
             currFollowingPage      = new FollowingPage(this, followingSomeone);
             contentControl.Content = currFollowingPage;
             HighlightTab();
         }
         else
         {
             contentControl.Content = currPhotosPage;
             HighlightTab();
         }
     }
     else if (sender.Equals(photosTab))
     {
         contentControl.Content = currPhotosPage;
         currPhotosPage.SortByPopular();
         HighlightTab();
     }
     else if (sender.Equals(discussionsTab))
     {
         contentControl.Content = currDiscussionPage;
         currDiscussionPage.SortByMostCommented();
         HighlightTab();
     }
     else if (sender.Equals(savedTab))
     {
         contentControl.Content = currSavedPage;
         HighlightTab();
     }
     else if (sender.Equals(postButton))
     {
         postButtonDropdown.IsOpen = !postButtonDropdown.IsOpen;
     }
     else if (sender.Equals(notificationsButton))
     {
         notificationsButtonDropdown.IsOpen = !notificationsButtonDropdown.IsOpen;
     }
     else if (sender.Equals(messageButton))
     {
         messagesButtonDropdown.IsOpen = !messagesButtonDropdown.IsOpen;
     }
     else if (sender.Equals(accountButton))
     {
         accountButtonDropdown.IsOpen = !accountButtonDropdown.IsOpen;
     }
     else if (sender.Equals(profileButton))
     {
         accountButtonDropdown.IsOpen = false;
         currProfilePage        = new ProfilePage(this, currUser);
         contentControl.Content = currProfilePage;
         HighlightTab();
     }
     else if (sender.Equals(userSettingButton))
     {
         accountButtonDropdown.IsOpen = false;
         contentControl.Content       = new UserSettings(this, currUser);
         HighlightTab();
     }
     else if (sender.Equals(logoutButton))
     {
         //LogoutPromptPopup popup = new LogoutPromptPopup(this);
         //popup.ShowDialog();
         //contentControl.Content = new LoginPage();
         //HighlightTab();
         if (!signedIn)
         {
             accountButtonDropdown.IsOpen = false;
             contentControl.Content       = new LoginPage(this);
             HighlightTab();
         }
         else if (signedIn)
         {
             accountButtonDropdown.IsOpen = false;
             LogoutPromptPopup popup = new LogoutPromptPopup(this);
             popup.ShowDialog();
         }
     }
     else if (sender.Equals(seeAllMessagesButton))
     {
         contentControl.Content        = currMessagesPage;
         messagesButtonDropdown.IsOpen = false;
         HighlightTab();
     }
     else if (sender.Equals(postPhotoButton))
     {
         if (signedIn)
         {
             postButtonDropdown.IsOpen = false;
             PostPhotoPopup photoPopup = new PostPhotoPopup(this);
             photoPopup.SetValue(Grid.RowProperty, 2);
             photoPopup.SetValue(Grid.ColumnSpanProperty, 3);
             mainGrid.Children.Add(photoPopup);
         }
         else if (!signedIn)
         {
             LoginPrompt prompt = new LoginPrompt(this);
             prompt.SetMessage("You must sign in to create posts.");
             prompt.ShowDialog();
             HighlightTab();
         }
     }
     else if (sender.Equals(postDiscussionButton))
     {
         if (signedIn)
         {
             postButtonDropdown.IsOpen = false;
             PostDiscussionPopup discussionPopup = new PostDiscussionPopup(this);
             discussionPopup.SetValue(Grid.RowProperty, 2);
             discussionPopup.SetValue(Grid.ColumnSpanProperty, 3);
             mainGrid.Children.Add(discussionPopup);
         }
         else if (!signedIn)
         {
             LoginPrompt prompt = new LoginPrompt(this);
             prompt.SetMessage("You must sign in to create posts.");
             prompt.ShowDialog();
             HighlightTab();
         }
     }
 }