Ejemplo n.º 1
0
 private void SelectioinTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (NameQueue.Count == 1)
     {
         SelectioinTimer.Stop();
         SelectedStudent.Name = NameQueue.Dequeue();
         _RandomSelection.CanExecute(true);
         _RandomSelection.RaiseCanExecuteChanged();
     }
     else
     {
         SelectedStudent.Name = NameQueue.Dequeue();
     }
 }
Ejemplo n.º 2
0
        private void RandomSelectionExecute()
        {
            _RandomSelection.CanExecute(false);
            _RandomSelection.RaiseCanExecuteChanged();
            int RandomResult   = 0;
            int SelectedIndex  = -1;
            int SelectionTimes = _RandomTimes.Next(1, 11);

            for (int i = 0; i < SelectionTimes; i++)
            {
                SelectedIndex = -1;
                RandomResult  = _Random.Next(Limit);
                do
                {
                    SelectedIndex++;
                    if (_StudentStatesList[SelectedIndex])
                    {
                        RandomResult--;
                    }
                } while (RandomResult >= 0);

                //SelectedStudent.Name = _StudentNamesList[SelectedIndex];
                NameQueue.Enqueue(_StudentNamesList[SelectedIndex]);
            }
            SelectioinTimer.Start();
            Thread.Sleep(200);
            Limit--;
            if (Limit == 0)
            {
                Limit = _StudentStatesList.Count;
                for (int i = 0; i < _StudentStatesList.Count; i++)
                {
                    _StudentStatesList[i] = true;
                }
                _StudentXml.RefreshStudentState();
                Debug.WriteLine("Refresh");
            }
            else
            {
                _StudentXml.SingleStudentStateChanged(SelectedIndex);
                _StudentStatesList[SelectedIndex] = false;
            }
        }