public void Button_Click(object sender, EventArgs e)
 {
     if (sender.Equals(CancelPostDiscussionButton))
     {
         PostCancelPrompt prompt = new PostCancelPrompt(this);
         prompt.ShowDialog();
         //parent.ChangeFill(Visibility.Hidden);
         //this.Visibility = Visibility.Hidden;
     }
     else if (sender.Equals(ConfirmPostDiscussionButton))
     {
         bool isComplete = true;
         // check if all fields are filled in
         if (AddDiscussionTitleBox.Text.Equals(""))
         {
             AddDiscussionTitleDefault.Foreground = new SolidColorBrush(Colors.Red);
             isComplete = false;
         }
         if (AddDiscussionDescriptionBox.Text.Equals(""))
         {
             AddDiscussionDescriptionDefault.Foreground = new SolidColorBrush(Colors.Red);
             isComplete = false;
         }
         if (isComplete)
         {
             parent.AddDiscussion(new Discussion(parent.currDiscussionPage.GetDiscussionIdCtr(), parent.currUser.UserName, AddDiscussionTitleBox.Text, AddDiscussionDescriptionBox.Text, 0, true));
             parent.ChangeFill(Visibility.Hidden);
             this.Visibility = Visibility.Hidden;
         }
     }
 }
Exemplo n.º 2
0
        public void Button_Click(object sender, EventArgs e)
        {
            if (sender.Equals(BrowseButton))
            {
                OpenFileDialog dialog = new OpenFileDialog();
                var            result = dialog.ShowDialog();
                if (result == false)
                {
                    return;
                }
                ImageBox.Visibility   = Visibility.Hidden;
                AddedImage.Source     = new BitmapImage(new Uri(dialog.FileName));
                AddedImage.Visibility = Visibility.Visible;
            }
            else if (sender.Equals(CancelPostPhotoButton))
            {
                PostCancelPrompt prompt = new PostCancelPrompt(this);
                prompt.ShowDialog();

                /*
                 * parent.ChangeFill(Visibility.Hidden);
                 * AddedImage.Source = null;
                 * AddedImage.Visibility = Visibility.Hidden;
                 * ImageBox.Visibility = Visibility.Visible;
                 * BrowseButton.Foreground = new SolidColorBrush(Colors.Black);
                 * AddPhotoTitleDefault.Foreground = new SolidColorBrush(Colors.Black);
                 * AddPhotoCaptionDefault.Foreground = new SolidColorBrush(Colors.Black);
                 * this.Visibility = Visibility.Hidden;*/
            }
            else if (sender.Equals(ConfirmPostPhotoButton))
            {
                bool isComplete = true;
                // check if all fields are filled in
                if (AddedImage.Source == null)
                {
                    BrowseButton.Foreground = new SolidColorBrush(Colors.Red);
                    isComplete = false;
                }
                if (AddPhotoTitleBox.Text.Equals(""))
                {
                    AddPhotoTitleDefault.Foreground = new SolidColorBrush(Colors.Red);
                    isComplete = false;
                }
                // form is complete
                if (isComplete)
                {
                    Photo photoBeingAdded = new Photo(parent.currPhotosPage.photoIdCounter, AddedImage.Source);

                    if (checkPrivate.IsChecked.GetValueOrDefault() == true)
                    {
                        photoBeingAdded.IsPrivate = false;
                    }

                    parent.AddPhoto(photoBeingAdded, AddPhotoTitleBox.Text, AddPhotoCaptionBox.Text);
                    parent.ChangeFill(Visibility.Hidden);
                    this.Visibility = Visibility.Hidden;
                }
            }
        }