Beispiel #1
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            Console.WriteLine(emailBox.Text);
            SubjectHandler.addObserver(emailBox.Text, new EmailForm(emailBox.Text, (int)updateNumber.Value), "EMAIL");

            this.Hide();
        }
 private void setAvailableObservers()
 {
     observerView.Items.Clear();
     foreach (string name in SubjectHandler.GetObservers().Keys)
     {
         observerView.Items.Add(new ListViewItem(new[] { name }));
     }
     SubjectHandler.SetNewObserver(false);
 }
        private void subjectListener()
        {
            while (running)
            {
                Thread.Sleep(500);
                lock (AthleteCollection.getAthleteCollection())
                {
                    foreach (KeyValuePair <int, Athlete> athlete in AthleteCollection.getAthleteCollection())
                    {
                        if (athlete.Value.justUpdated == true)
                        {
                            SubjectHandler.addSubject(athlete.Value);


                            athlete.Value.justUpdated = false;
                            if (this.availableAthletes.InvokeRequired)
                            {
                                SetAvailableList b = new SetAvailableList(setAvailableList);

                                this.Invoke(b, new object[] { AthleteCollection.getAthleteCollection() });
                            }
                            else
                            {
                                availableAthletes.Items.Add(athlete.Value.BibNumber.ToString(), athlete.Value.currTime.ToString(), athlete.Value.Location.ToString());
                            }
                        }

                        if (SubjectHandler.ObserverAdded())
                        {
                            if (this.observerView.InvokeRequired)
                            {
                                SetAvailableObservers o = new SetAvailableObservers(setAvailableObservers);
                                this.Invoke(o, new object[] { });
                            }
                        }

                        if (athlete.Value.updated == true)
                        {
                            SubjectHandler.UpdateDisplays();
                            AthleteCollection.updateDone(athlete.Value.BibNumber);
                        }
                    }
                }
            }
        }
        private void removeSubject_Click(object sender, EventArgs e)
        {
            if (observerName.Text != "Athletes being Observed")
            {
                if (observedAthletes.SelectedItems.Count > 0)
                {
                    int index = Int32.Parse(observedAthletes.SelectedItems[0].Text);


                    AthleteCollection athletes = AthleteCollection.getAthleteCollection();
                    Dictionary <string, SubjectManager> temp = SubjectHandler.GetObservers();
                    temp[observerName.Text].subjects.Remove(index);
                    temp[observerName.Text].AvailableSubjects.Add(index, athletes[index]);

                    updateLists(observerName.Text, temp);
                }
            }
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (listRadio.Checked)
            {
                SubjectHandler.addObserver(textBox1.Text, new ListDisplay(), "LIST");
            }
            //Console.WriteLine(name);

            if (emailRadio.Checked)
            {
                EmailForm.Show();
            }

            if (graphicalRadio.Checked)
            {
                SubjectHandler.addObserver(textBox1.Text, new GraphicalDisplay(), "LIST");
            }

            this.Hide();
            this.textBox1.ResetText();
        }
        private void observerView_SelectedIndexChanged(object sender, EventArgs e)
        {
            string name = "";
            Dictionary <string, SubjectManager> observers = SubjectHandler.GetObservers();

            if (observerView.SelectedItems.Count > 0)
            {
                observerName.Text = observerView.SelectedItems[0].Text;
                name = observerName.Text;
                if (observerName.Text != "Athletes being Observed")
                {
                    try
                    {
                        updateLists(name, observers);
                    }
                    catch (Exception f)
                    {
                        Console.WriteLine(f);
                    }
                }
            }
        }