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."; } }
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."; } } }