Esempio n. 1
0
        public AgeDecorator(AthleteDescriber describer)
        {
            heldDescriber       = describer;
            ObservedAthleteList = heldDescriber.ObservedAthleteList;

            InitializeComponent();
        }
        private void CreateButton_Click(object sender, EventArgs e)
        {
            AthleteDescriber describer = new AthleteDescriber();

            if (AthleteListView.SelectedItems != null)
            {
                foreach (ListViewItem item in AthleteListView.SelectedItems)
                {
                    Athlete observedAthlete = item.Tag as Athlete;
                    describer.ObservedAthleteList.Add(observedAthlete);
                }
            }
            if (ShowNameBox.Checked)
            {
                describer = new NameDecorator(describer);
            }
            if (ShowAgeBox.Checked)
            {
                describer = new AgeDecorator(describer);
            }
            if (ShowLocationBox.Checked)
            {
                describer = new LocationDecorator(describer);
            }
            describer.RegisterWithAthletes();
            describer.title = $"Display #{ControlForm.observerList.Count() + 1} (Athlete Description)";
            ControlForm.observerList.Add(describer);
            describer.RefreshObserver();
            this.Hide();
            describer.Show();
        }