public static void UpdateDisplays()
        {
            lock (locker)
            {
                Dictionary <int, Athlete> athletes = AthleteCollection.getAthleteCollection();
                foreach (Athlete athlete in athletes.Values)
                {
                    foreach (SubjectManager observer in subjectHandler._observers.Values)
                    {
                        if (observer.AvailableSubjects.ContainsKey(athlete.BibNumber))
                        {
                            observer.AvailableSubjects[athlete.BibNumber] = athlete;
                        }
                        if (observer.subjects.ContainsKey(athlete.BibNumber))
                        {
                            observer.subjects[athlete.BibNumber] = athlete;
                        }
                    }
                }

                foreach (SubjectManager observer in subjectHandler._observers.Values)
                {
                    try
                    {
                        observer.UpdateDisplay();
                    }
                    catch (Exception f)
                    {
                        Console.WriteLine(f);
                    }
                }
            }
        }
Example #2
0
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>DeleteAthlete</name>
        /// <date>14/03/15</date>
        /// <summary>
        /// Marks the athlete for removal and resets the index. If the athlete is new, then it removes it completely
        /// from the list.
        /// </summary>
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        public void DeleteAthlete()
        {
            if (AthleteCollection[SelectedAthleteIndex].Status == StatusType.Added)
            {
                AthleteCollection.RemoveAt(SelectedAthleteIndex);
            }
            else
            {
                AthleteCollection[SelectedAthleteIndex].Status = StatusType.Deleted;
            }

            ResetSelectedIndex();
        }
Example #3
0
        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);
                        }
                    }
                }
            }
        }
Example #4
0
        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);
                }
            }
        }