예제 #1
0
 private void SubscribeButton_Click(object sender, EventArgs e)
 {
     toEmail = EmailEntryBox.Text;
     if (ValidateEmail(toEmail))
     {
         foreach (ListViewItem item in AthleteListview.SelectedItems)
         {
             emailedAthlete = item.Tag as Athlete;
         }
         emailedAthlete.registerObserver(this);
         this.Hide();
     }
     else
     {
         label1.Text = "Invalid Email.";
     }
 }
예제 #2
0
 private void SubScribeButton_Click(object sender, EventArgs e)
 {
     if (active)
     {
         Type type = _selectedObserver.GetType();
         if (_selectedObserver != null && !type.Equals(typeof(EmailObserver)) && !type.Equals(typeof(AthleteDescriber)) && !type.Equals(typeof(AgeDecorator)) && !type.Equals(typeof(NameDecorator)) && !type.Equals(typeof(LocationDecorator)))
         {
             foreach (ListViewItem item in AthleteListView.SelectedItems)
             {
                 Athlete athlete = item.Tag as Athlete;
                 athlete?.registerObserver(_selectedObserver);
             }
             RefreshObserverListView();
             RefreshListViews();
         }
         else if (type.Equals(typeof(EmailObserver)) || type.Equals(typeof(AthleteDescriber)) || type.Equals(typeof(AgeDecorator)) || type.Equals(typeof(NameDecorator)) || type.Equals(typeof(LocationDecorator)))
         {
             ObservedAthletesLabel.Text = $"This type of observer can only observe one athlete.";
         }
     }
 }