Exemplo n.º 1
0
 private void StartNextIteration()
 {
     Iteration.Complete -= Iteration_Complete;
     Iteration.Tick -= Iteration_Tick;
     Iteration = null;
     BeginIteration();
 }
Exemplo n.º 2
0
        private void BeginIteration()
        {
            if (!TaskListBox.HasItems)
            {
                GoalTextBlock.Text = "Add some tasks to your list with the \"New Task\" button, then try again.";
                GoalDescriptionBlock.Text = "Be sure to give your tasks clear, concise names. Leave the detail for the description.";
                return;
            }

            // Make a list of all incomplete tasks.
            List<StutterTask> temp = new List<StutterTask>();

            foreach(StutterTask st in Tasks)
            {
                if (!st.IsComplete) { temp.Add(st); }
            }

            // If there are no incomplete tasks, fuss.
            if (temp.Count < 1)
            {
                GoalTextBlock.Text = "Add some tasks to your list with the \"New Task\" button, then try again.";
                GoalDescriptionBlock.Text = "Remember, completed tasks won't be selected during a phrase.";
                return;
            }

            // Set up variables for the new Iteration
            StutterTask task = temp[_random.Next(temp.Count)];
            TimeSpan phraseLength = new TimeSpan(0, Settings.Default.PhraseLength, 0);
            TimeSpan blockLength = new TimeSpan(0, Settings.Default.BlockLength, 0);

            #if DEBUG

            // Shorter iterations for debugging purposes.
            phraseLength = new TimeSpan(0,0,10);
            blockLength = new TimeSpan(0,0,5);

            #endif

            // Create the Iteration.
            Iteration = new StutterIteration(task, phraseLength, blockLength);
            Iteration.Complete += Iteration_Complete;
            Iteration.Tick += Iteration_Tick;
            Iteration.BeginPhrase();
            RefreshGoal();
            PhraseProgressLabel.Content = Iteration.PhraseLength.ToString(@"mm\:ss") + " Remaining";
            BeginButton.Content = "Stop Stutter";

            NotificationHelper.CreateNotificiation(this, Iteration.Task.Name, "Phrase Started");
        }