private void button4_Click(object sender, EventArgs e)
        {
            RecurrenceInfo info = RecurrenceHelper.GetFriendlySeriesInfo(txtGetRecurrenceValues.Text);

            pgrpropertyGrid1.SelectedObject = info;
            tabMain.SelectedTab             = tabProperty;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            RecurrenceValues values = null;

            switch (tabControl1.SelectedIndex)
            {
            case 0:     // Daily
                DailyRecurrenceSettings da;
                if (radioOccurrences.Checked)
                {
                    da = new DailyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    da = new DailyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }

                if (radioButton1.Checked)
                {
                    values = da.GetValues(int.Parse(textBox1.Text));
                }
                else
                {
                    values = da.GetValues(1, DailyRegenType.OnEveryWeekday);
                }
                break;

            case 1:     // Weekly
                WeeklyRecurrenceSettings we;
                SelectedDayOfWeekValues  selectedValues = new SelectedDayOfWeekValues();

                if (radioOccurrences.Checked)
                {
                    we = new WeeklyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    we = new WeeklyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }

                selectedValues.Sunday    = chkSunday.Checked;
                selectedValues.Monday    = chkMonday.Checked;
                selectedValues.Tuesday   = chkTuesday.Checked;
                selectedValues.Wednesday = chkWednesday.Checked;
                selectedValues.Thursday  = chkThursday.Checked;
                selectedValues.Friday    = chkFriday.Checked;
                selectedValues.Saturday  = chkSaturday.Checked;

                values = we.GetValues(int.Parse(txtWeeklyRegenXWeeks.Text), selectedValues);
                break;

            case 2:     // Monthly
                MonthlyRecurrenceSettings mo;
                if (radioOccurrences.Checked)
                {
                    mo = new MonthlyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    mo = new MonthlyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }


                if (radioButton3.Checked)
                {
                    values = mo.GetValues(int.Parse(textBox4.Text), Convert.ToInt32(textBox2.Text));
                }
                else
                {
                    // Get the adjusted values
                    mo.AdjustmentValue = int.Parse(txtMonthlyAdjustedValue.Text);
                    values             = mo.GetValues((MonthlySpecificDatePartOne)comboBox2.SelectedIndex, (MonthlySpecificDatePartTwo)comboBox3.SelectedIndex, int.Parse(textBox3.Text));
                }
                break;

            case 3:     // Yearly
                YearlyRecurrenceSettings yr;
                if (radioOccurrences.Checked)
                {
                    yr = new YearlyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    yr = new YearlyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }


                if (radioYearlyEvery.Checked)
                {
                    values = yr.GetValues(int.Parse(txtYearEvery.Text), cboYearEveryMonth.SelectedIndex + 1);
                }
                else
                {
                    // Get the adjusted value
                    yr.AdjustmentValue = int.Parse(txtYearlyAdjustedValue.Text);
                    values             = yr.GetValues((YearlySpecificDatePartOne)comboBox5.SelectedIndex, (YearlySpecificDatePartTwo)comboBox4.SelectedIndex, (YearlySpecificDatePartThree)(comboBox6.SelectedIndex + 1));
                }
                break;
            }

            txtSeriesInfo.Text          = values.GetSeriesInfo();
            txtGetRecurrenceValues.Text = txtSeriesInfo.Text;

            lstResults.Items.Clear();
            DateTime[] bolded  = new DateTime[values.Values.Count];
            int        counter = 0;

            foreach (DateTime dt in values.Values)
            {
                bolded[counter] = dt;
                lstResults.Items.Add(new DateItem(dt));
                counter++;
            }
            monthCalendar1.BoldedDates = bolded;

            if (lstResults.Items.Count > 0)
            {
                lstResults.SelectedIndex = 0;
            }

            txtTotal.Text          = lstResults.Items.Count.ToString();
            txtEndDate.Text        = values.EndDate.ToShortDateString();
            txtStartDate.Text      = values.StartDate.ToShortDateString();
            btnGetNextDate.Enabled = lstResults.Items.Count > 0;
            txtNextDate.Text       = string.Empty;
            lstRecurrenceValues.Items.Clear();
            tabMain.SelectedTab   = tabSecond;
            txtAdjustedTotal.Text = lstRecurrenceValues.Items.Count.ToString();

            // Get reccurrence info object to use for setting controls
            RecurrenceInfo info = RecurrenceHelper.GetFriendlySeriesInfo(values.GetSeriesInfo());

            dateTimePickerStartDate.Value = info.StartDate;
            if (info.EndDate.HasValue)
            {
                dateTimePickerStartDateEndDate.Value = info.EndDate.Value;
                dtAdjustedDateTime.Value             = info.EndDate.Value;
                dateTimePicker1.Value = info.EndDate.Value;
            }
        }