/// <summary>
        /// Different controls will be used to enter the period size depending on the selection
        /// in the periodTypeCombo. This method catches the SelectedIndexChanged event for the
        /// periodTypeCombo and enables the appropriate controls for entering the period size.
        /// </summary>
        private void periodTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            GenPeriodType SelectedPeriodType = GetSelectedPeriodType();

            switch (SelectedPeriodType)
            {
            case GenPeriodType.Bars:
            case GenPeriodType.BeatSynced:
                //Beat Synced generators are not currently supported
                Debug.Assert(SelectedPeriodType != GenPeriodType.BeatSynced);

                this.periodCombo.Visible   = true;
                this.periodTextBox.Visible = false;
                this.periodLbl.Text        = "Period";
                break;

            case GenPeriodType.Time:
                this.periodCombo.Visible   = false;
                this.periodTextBox.Visible = true;
                this.periodLbl.Text        = "Period(ms)";
                break;

            default:
                //Unknown period type
                Debug.Assert(false);
                break;
            }
        }
        /// <summary>
        /// Ensures that the user input is valid and if it is, initializes GenInfoResult and
        /// closes the dialog with DialogResult.OK.
        /// </summary>
        private void OkBtn_Click(object sender, EventArgs e)
        {
            GenPeriodType SelectedPeriodType = GetSelectedPeriodType();

            if (ValidatePeriodTextBox() == false)
            {
                if (SelectedPeriodType == GenPeriodType.Time)
                {
                    return;
                }
                else
                {
                    this.GenInfoResult.TimePeriodInMs = GenEntryConfigInfo.DEFAULT_TIME_PERIOD;
                }
            }
            else
            {
                int periodSize;
                //this should always be able to be parsed as an int because ValidatePeriodTextBox() returned true.
                int.TryParse(this.periodTextBox.Text.Trim(), out periodSize);
                this.GenInfoResult.TimePeriodInMs = periodSize;
            }

            this.GenInfoResult.Name       = this.genNameTextBox.Text;
            this.GenInfoResult.PeriodType = SelectedPeriodType;
            this.GenInfoResult.BarsPeriod = GetSelectedBarsPeriod();
            this.GenInfoResult.Loop       = this.loopCheckBox.Checked;
            this.GenInfoResult.Enabled    = this.enabledCheckBox.Checked;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
示例#3
0
 public void InitWithDefaultValues()
 {
     this.Name           = DEFAULT_NAME;
     this.PeriodType     = DEFAULT_PERIOD_TYPE;
     this.TimePeriodInMs = DEFAULT_TIME_PERIOD;
     this.BarsPeriod     = DEFAULT_BARS_PERIOD;
     this.Loop           = DEFAULT_LOOP;
     this.Enabled        = DEFAULT_ENABLED;
 }
 public void InitWithDefaultValues()
 {
     this.Name = DEFAULT_NAME;
     this.PeriodType = DEFAULT_PERIOD_TYPE;
     this.TimePeriodInMs = DEFAULT_TIME_PERIOD;
     this.BarsPeriod = DEFAULT_BARS_PERIOD;
     this.Loop = DEFAULT_LOOP;
     this.Enabled = DEFAULT_ENABLED;
 }