/// <summary> /// <see cref="Control.Click"/> event handler /// for the <see cref="Button"/> <see cref="btnAddCorrectResponse"/> /// Adds a new <see cref="StopCondition"/> (response condition) to the slide /// according to the settings made in the UI. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An empty <see cref="EventArgs"/></param> private void btnAddCorrectResponse_Click(object sender, EventArgs e) { if (this.rdbTestingMouse.Checked) { MouseStopCondition msc = new MouseStopCondition(); string selectedItemMouse = (string)this.cbbTestingMouseButtons.SelectedItem; msc.CanBeAnyInputOfThisType = selectedItemMouse == "Any" ? true : false; msc.Target = this.cbbTestingTargets.Text; if (!msc.CanBeAnyInputOfThisType) { msc.StopMouseButton = (MouseButtons)Enum.Parse(typeof(MouseButtons), selectedItemMouse); } if (!this.lsbCorrectResponses.Items.Contains(msc)) { this.lsbCorrectResponses.Items.Add(msc); } // Add this stop condition to the stopcondition list. if (!this.lsbStopConditions.Items.Contains((MouseStopCondition)msc.Clone())) { this.lsbStopConditions.Items.Add(msc); } } else if (this.rdbTestingKey.Checked) { KeyStopCondition ksc = new KeyStopCondition(); string selectedItemKeys = (string)this.cbbTestingKeys.SelectedItem; ksc.CanBeAnyInputOfThisType = selectedItemKeys == "Any" ? true : false; if (!ksc.CanBeAnyInputOfThisType) { ksc.StopKey = (Keys)Enum.Parse(typeof(Keys), selectedItemKeys); } // Add this condition to the stopcondition list. if (!this.lsbStopConditions.Items.Contains(ksc)) { this.lsbStopConditions.Items.Add((KeyStopCondition)ksc.Clone()); } // Add this condition to the testing list. if (!this.lsbCorrectResponses.Items.Contains(ksc)) { this.lsbCorrectResponses.Items.Add(ksc); } } }
/// <summary> /// <see cref="Control.Click"/> event handler /// for the <see cref="Button"/> <see cref="btnAddLink"/> /// Adds a new <see cref="StopCondition"/> (as link condition) to the slide /// according to the settings made in the UI. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An empty <see cref="EventArgs"/></param> private void btnAddLink_Click(object sender, EventArgs e) { if (this.rdbLinksMouse.Checked) { MouseStopCondition msc = new MouseStopCondition(); string selectedItemMouse = (string)this.cbbLinksMouseButtons.SelectedItem; msc.CanBeAnyInputOfThisType = selectedItemMouse == "Any" ? true : false; msc.Target = this.cbbLinksTargets.Text; if (!msc.CanBeAnyInputOfThisType) { msc.StopMouseButton = (MouseButtons)Enum.Parse(typeof(MouseButtons), selectedItemMouse); } Trial selectedTrial = (Trial)this.cbbLinksTrial.SelectedItem; if (selectedTrial != null) { msc.TrialID = selectedTrial.ID; // Add this link to the link list. if (!this.lsbLinks.Items.Contains(msc)) { this.lsbLinks.Items.Add((MouseStopCondition)msc.Clone()); } if (msc.Target != string.Empty) { msc.Target = "Any"; } msc.TrialID = null; // Add this link to the stopcondition list. if (!this.lsbStopConditions.Items.Contains(msc)) { this.lsbStopConditions.Items.Add(msc); } } } else if (this.rdbLinksKey.Checked) { KeyStopCondition ksc = new KeyStopCondition(); string selectedItemKeys = (string)this.cbbLinksKeys.SelectedItem; ksc.CanBeAnyInputOfThisType = selectedItemKeys == "Any" ? true : false; if (!ksc.CanBeAnyInputOfThisType) { ksc.StopKey = (Keys)Enum.Parse(typeof(Keys), selectedItemKeys); } Trial selectedTrial = (Trial)this.cbbLinksTrial.SelectedItem; if (selectedTrial != null) { ksc.TrialID = selectedTrial.ID; // Add this link to the link list. if (!this.lsbLinks.Items.Contains(ksc)) { this.lsbLinks.Items.Add((KeyStopCondition)ksc.Clone()); } // Add this link to the stopcondition list. if (!this.lsbStopConditions.Items.Contains(ksc)) { this.lsbStopConditions.Items.Add(ksc); } } } }