/// <summary> /// This method iterates recursively through the tree to return only the trials /// contained in the tree. /// </summary> /// <param name="trials">Ref. The output <see cref="TrialCollection"/> of trials.</param> /// <param name="node">The <see cref="TreeNode"/> to parse.</param> private void ParseNodeForTrials(ref TrialCollection trials, TreeNode node) { Trial trial = null; // Add trial if this node is marked to be a trial if (node.Tag != null && node.Tag.ToString() == "Trial") { trial = new Trial(node.Text, GetIdOfNode(node)); trials.Add(trial); } foreach (TreeNode subNode in node.Nodes) { SlideshowTreeNode subSlideNode = subNode as SlideshowTreeNode; Slide slide = subSlideNode.Slide; if (slide != null) { // By default use a new trial for each slide trial = new Trial(subNode.Text, GetIdOfNode(subNode)); // If parent is already marked as trial use this // instead. if (subNode.Parent != null && subNode.Parent.Tag != null && subNode.Parent.Tag.ToString() == "Trial") { trial = trials[trials.Count - 1]; } // Add slide to correct trial trial.Add(slide); } // Iterate through the tree. this.ParseNodeForTrials(ref trials, subNode); // If a trial was found, add it to the list. if (trial != null && !trials.Contains(trial)) { trials.Add(trial); } } }
/// <summary> /// Inserts the pre slide trials. /// </summary> /// <param name="trials">The trials.</param> private void InsertPreSlideTrials(ref TrialCollection trials) { var trialsWithPreSlideTrials = new TrialCollection(); foreach (var trial in trials) { foreach (var slideobject in trial) { // if we have a preslide fixation trial add this trial before var preSlideTrialID = slideobject.IdOfPreSlideFixationTrial; if (preSlideTrialID != -1) { var preSlideNode = this.GetNodeByID(preSlideTrialID); var preTrial = new Trial(preSlideNode.Text, preSlideTrialID); preTrial.AddRange(this.GetPreSlideTrialSlides(preSlideNode)); trialsWithPreSlideTrials.Add(preTrial); } } trialsWithPreSlideTrials.Add(trial); } trials = trialsWithPreSlideTrials; }
/// <summary> /// This method iterates the given shuffled object collection recursively /// to return the one dimensional <see cref="TrialCollection"/> that is used /// during presentation. /// </summary> /// <param name="collection">A <see cref="List{Object}"/> with the shuffled trials separated in /// shuffle groups.</param> /// <param name="trials">Ref. The output <see cref="TrialCollection"/>.</param> private void GetTrialsFromObjectCollection(List <object> collection, ref TrialCollection trials) { foreach (object item in collection) { if (item is Trial) { Trial trial = item as Trial; trials.Add(trial); } else if (item is List <object> ) { this.GetTrialsFromObjectCollection((List <object>)item, ref trials); } } }