예제 #1
0
        /// <summary>
        /// This is used to initialize the control with settings from an existing recurrence object
        /// </summary>
        /// <param name="recurrence">The recurrence from which to get the settings.  If null, it uses a default
        /// daily recurrence pattern.</param>
        public void SetRecurrence(Recurrence recurrence)
        {
            Recurrence r = new Recurrence();

            if (recurrence == null)
            {
                r.StartDateTime = DateTime.Today;
                r.RecurDaily(1);
            }
            else
            {
                r.Parse(recurrence.ToStringWithStartDateTime());
            }

            // If the given pattern is not available, set it to the next best pattern
            if (maxPattern < r.Frequency)
            {
                switch (maxPattern)
                {
                case RecurFrequency.Yearly:
                    r.RecurYearly(DateTime.Now.Month, DateTime.Now.Day, r.Interval);
                    break;

                case RecurFrequency.Monthly:
                    r.RecurMonthly(DateTime.Now.Day, r.Interval);
                    break;

                case RecurFrequency.Weekly:
                    r.RecurWeekly(r.Interval, DateUtils.ToDaysOfWeek(DateTime.Now.DayOfWeek));
                    break;

                case RecurFrequency.Daily:
                    r.RecurDaily(r.Interval);
                    break;

                case RecurFrequency.Hourly:
                    r.RecurDaily(r.Interval);
                    r.Frequency = RecurFrequency.Hourly;
                    break;

                default:
                    r.RecurDaily(r.Interval);
                    r.Frequency = RecurFrequency.Minutely;
                    break;
                }
            }

            switch (r.Frequency)
            {
            case RecurFrequency.Yearly:
                rbYearly.Checked = true;
                break;

            case RecurFrequency.Monthly:
                rbMonthly.Checked = true;
                break;

            case RecurFrequency.Weekly:
                rbWeekly.Checked = true;
                break;

            case RecurFrequency.Hourly:
                rbHourly.Checked = true;
                break;

            case RecurFrequency.Minutely:
                rbMinutely.Checked = true;
                break;

            case RecurFrequency.Secondly:
                rbSecondly.Checked = true;
                break;

            default:        // Daily or undefined
                rbDaily.Checked = true;
                break;
            }

            cboWeekStartDay.SelectedValue = r.WeekStart;
            dtpEndDate.Value     = DateTime.Today;
            udcOccurrences.Value = 1;

            // If not visible, this option is always on in the recurrence
            if (holidayVisible)
            {
                chkHolidays.Checked = r.CanOccurOnHoliday;
            }
            else
            {
                chkHolidays.Checked = true;
            }

            if (r.MaximumOccurrences != 0)
            {
                rbEndAfter.Checked   = true;
                udcOccurrences.Value = (r.MaximumOccurrences < 1000) ? r.MaximumOccurrences : 999;
            }
            else
            if (r.RecurUntil == DateTime.MaxValue)
            {
                rbNeverEnds.Checked = true;
            }
            else
            {
                rbEndByDate.Checked = true;
                dtpEndDate.Value    = r.RecurUntil;
            }

            // Set parameters in the sub-controls.  Set them all so that when the Advanced pane is hidden or
            // shown, it keeps them consistent when first opened.
            ucYearly.SetValues(r);
            ucMonthly.SetValues(r);
            ucWeekly.SetValues(r);
            ucDaily.SetValues(r);
            ucHourly.SetValues(r);
            ucMinutely.SetValues(r);
            ucSecondly.SetValues(r);
            ucAdvanced.SetValues(r);

            if (advancedVisible)
            {
                noCopy = true;
                chkAdvanced.Checked = r.IsAdvancedPattern;
                noCopy = false;
            }
        }
예제 #2
0
        //=====================================================================

        /// <summary>
        /// This is used to retrieve the recurrence information into the passed recurrence object
        /// </summary>
        /// <param name="recurrence">The recurrence in which to store the settings</param>
        /// <exception cref="ArgumentNullException">This is thrown if the passed recurrence object is null</exception>
        public void GetRecurrence(Recurrence recurrence)
        {
            Recurrence r = new Recurrence();

            if (recurrence == null)
            {
                throw new ArgumentNullException("recurrence", LR.GetString("ExRPRecurrenceIsNull"));
            }

            // Get the basic stuff
            r.Reset();
            r.WeekStart         = (DayOfWeek)cboWeekStartDay.SelectedValue;
            r.CanOccurOnHoliday = chkHolidays.Checked;

            r.Frequency = rbYearly.Checked ? RecurFrequency.Yearly :
                          rbMonthly.Checked ? RecurFrequency.Monthly :
                          rbWeekly.Checked ? RecurFrequency.Weekly :
                          rbDaily.Checked ? RecurFrequency.Daily :
                          rbHourly.Checked ? RecurFrequency.Hourly :
                          rbMinutely.Checked ? RecurFrequency.Minutely : RecurFrequency.Secondly;

            if (rbEndAfter.Checked)
            {
                r.MaximumOccurrences = (int)udcOccurrences.Value;
            }
            else
            if (rbEndByDate.Checked)
            {
                if (this.ShowEndTime)
                {
                    r.RecurUntil = dtpEndDate.Value;
                }
                else
                {
                    r.RecurUntil = dtpEndDate.Value.Date;
                }
            }

            // Get the frequency-specific stuff
            if (chkAdvanced.Checked)
            {
                ucAdvanced.GetValues(r);
            }
            else
            if (rbYearly.Checked)
            {
                ucYearly.GetValues(r);
            }
            else
            if (rbMonthly.Checked)
            {
                ucMonthly.GetValues(r);
            }
            else
            if (rbWeekly.Checked)
            {
                ucWeekly.GetValues(r);
            }
            else
            if (rbDaily.Checked)
            {
                ucDaily.GetValues(r);
            }
            else
            if (rbHourly.Checked)
            {
                ucHourly.GetValues(r);
            }
            else
            if (rbMinutely.Checked)
            {
                ucMinutely.GetValues(r);
            }
            else
            {
                ucSecondly.GetValues(r);
            }

            recurrence.Parse(r.ToString());
        }
예제 #3
0
        /// <summary>
        /// This is used to initialize the control with settings from an existing recurrence object
        /// </summary>
        /// <param name="recurrence">The recurrence from which to get the settings.  If null, it uses a default daily
        /// recurrence pattern.</param>
        public void SetRecurrence(Recurrence recurrence)
        {
            rRecur = new Recurrence();

            if(recurrence == null)
            {
                rRecur.StartDateTime = DateTime.Today;
                rRecur.RecurDaily(1);
            }
            else
            {
                rRecur.Parse(recurrence.ToStringWithStartDateTime());

                // Reset to daily if undefined
                if(rRecur.Frequency == RecurFrequency.Undefined)
                    rRecur.RecurDaily(rRecur.Interval);
            }

            // If the given pattern is not available, set it to the next best pattern
            if(this.MaximumPattern < rRecur.Frequency)
                switch(this.MaximumPattern)
                {
                    case RecurFrequency.Yearly:
                        rRecur.RecurYearly(DateTime.Now.Month, DateTime.Now.Day, rRecur.Interval);
                        break;

                    case RecurFrequency.Monthly:
                        rRecur.RecurMonthly(DateTime.Now.Day, rRecur.Interval);
                        break;

                    case RecurFrequency.Weekly:
                        rRecur.RecurWeekly(rRecur.Interval, DateUtils.ToDaysOfWeek(DateTime.Now.DayOfWeek));
                        break;

                    case RecurFrequency.Daily:
                        rRecur.RecurDaily(rRecur.Interval);
                        break;

                    case RecurFrequency.Hourly:
                        rRecur.RecurDaily(rRecur.Interval);
                        rRecur.Frequency = RecurFrequency.Hourly;
                        break;

                    default:
                        rRecur.RecurDaily(rRecur.Interval);
                        rRecur.Frequency = RecurFrequency.Minutely;
                        break;
                }
        }
예제 #4
0
        /// <summary>
        /// This is used to retrieve the recurrence information into the passed recurrence object
        /// </summary>
        /// <param name="recurrence">The recurrence in which to store the settings.</param>
        /// <exception cref="ArgumentNullException">This is thrown if the passed recurrence object is null</exception>
        public void GetRecurrence(Recurrence recurrence)
        {
            if(recurrence == null)
                throw new ArgumentNullException("recurrence", LR.GetString("ExRPRecurrenceIsNull"));

            recurrence.Parse(rRecur.ToString());
        }
예제 #5
0
        /// <summary>
        /// This is used to initialize the control with settings from an existing recurrence object
        /// </summary>
        /// <param name="recurrence">The recurrence from which to get the settings.  If null, it uses a default
        /// daily recurrence pattern.</param>
        public void SetRecurrence(Recurrence recurrence)
        {
            Recurrence r = new Recurrence();

            if(recurrence == null)
            {
                r.StartDateTime = DateTime.Today;
                r.RecurDaily(1);
            }
            else
                r.Parse(recurrence.ToStringWithStartDateTime());

            // If the given pattern is not available, set it to the next best pattern
            if(maxPattern < r.Frequency)
                switch(maxPattern)
                {
                    case RecurFrequency.Yearly:
                        r.RecurYearly(DateTime.Now.Month, DateTime.Now.Day, r.Interval);
                        break;

                    case RecurFrequency.Monthly:
                        r.RecurMonthly(DateTime.Now.Day, r.Interval);
                        break;

                    case RecurFrequency.Weekly:
                        r.RecurWeekly(r.Interval, DateUtils.ToDaysOfWeek(DateTime.Now.DayOfWeek));
                        break;

                    case RecurFrequency.Daily:
                        r.RecurDaily(r.Interval);
                        break;

                    case RecurFrequency.Hourly:
                        r.RecurDaily(r.Interval);
                        r.Frequency = RecurFrequency.Hourly;
                        break;

                    default:
                        r.RecurDaily(r.Interval);
                        r.Frequency = RecurFrequency.Minutely;
                        break;
                }

            switch(r.Frequency)
            {
                case RecurFrequency.Yearly:
                    rbYearly.Checked = true;
                    break;

                case RecurFrequency.Monthly:
                    rbMonthly.Checked = true;
                    break;

                case RecurFrequency.Weekly:
                    rbWeekly.Checked = true;
                    break;

                case RecurFrequency.Hourly:
                    rbHourly.Checked = true;
                    break;

                case RecurFrequency.Minutely:
                    rbMinutely.Checked = true;
                    break;

                case RecurFrequency.Secondly:
                    rbSecondly.Checked = true;
                    break;

                default:    // Daily or undefined
                    rbDaily.Checked = true;
                    break;
            }

            cboWeekStartDay.SelectedValue = r.WeekStart;
            dtpEndDate.Value = DateTime.Today;
            udcOccurrences.Value = 1;

            // If not visible, this option is always on in the recurrence
            if(holidayVisible)
                chkHolidays.Checked = r.CanOccurOnHoliday;
            else
                chkHolidays.Checked = true;

            if(r.MaximumOccurrences != 0)
            {
                rbEndAfter.Checked = true;
                udcOccurrences.Value = (r.MaximumOccurrences < 1000) ? r.MaximumOccurrences : 999;
            }
            else
                if(r.RecurUntil == DateTime.MaxValue)
                    rbNeverEnds.Checked = true;
                else
                {
                    rbEndByDate.Checked = true;
                    dtpEndDate.Value = r.RecurUntil;
                }

            // Set parameters in the sub-controls.  Set them all so that when the Advanced pane is hidden or
            // shown, it keeps them consistent when first opened.
            ucYearly.SetValues(r);
            ucMonthly.SetValues(r);
            ucWeekly.SetValues(r);
            ucDaily.SetValues(r);
            ucHourly.SetValues(r);
            ucMinutely.SetValues(r);
            ucSecondly.SetValues(r);
            ucAdvanced.SetValues(r);

            if(advancedVisible)
            {
                noCopy = true;
                chkAdvanced.Checked = r.IsAdvancedPattern;
                noCopy = false;
            }
        }
예제 #6
0
        //=====================================================================

        /// <summary>
        /// This is used to retrieve the recurrence information into the passed recurrence object
        /// </summary>
        /// <param name="recurrence">The recurrence in which to store the settings</param>
        /// <exception cref="ArgumentNullException">This is thrown if the passed recurrence object is null</exception>
        public void GetRecurrence(Recurrence recurrence)
        {
            Recurrence r = new Recurrence();

            if(recurrence == null)
                throw new ArgumentNullException("recurrence", LR.GetString("ExRPRecurrenceIsNull"));

            // Get the basic stuff
            r.Reset();
            r.WeekStart = (DayOfWeek)cboWeekStartDay.SelectedValue;
            r.CanOccurOnHoliday = chkHolidays.Checked;

            r.Frequency = rbYearly.Checked ? RecurFrequency.Yearly :
                rbMonthly.Checked ? RecurFrequency.Monthly :
                    rbWeekly.Checked ? RecurFrequency.Weekly :
                        rbDaily.Checked ? RecurFrequency.Daily :
                            rbHourly.Checked ? RecurFrequency.Hourly :
                                rbMinutely.Checked ? RecurFrequency.Minutely : RecurFrequency.Secondly;

            if(rbEndAfter.Checked)
                r.MaximumOccurrences = (int)udcOccurrences.Value;
            else
                if(rbEndByDate.Checked)
                    if(this.ShowEndTime)
                        r.RecurUntil = dtpEndDate.Value;
                    else
                        r.RecurUntil = dtpEndDate.Value.Date;

            // Get the frequency-specific stuff
            if(chkAdvanced.Checked)
                ucAdvanced.GetValues(r);
            else
                if(rbYearly.Checked)
                    ucYearly.GetValues(r);
                else
                    if(rbMonthly.Checked)
                        ucMonthly.GetValues(r);
                    else
                        if(rbWeekly.Checked)
                            ucWeekly.GetValues(r);
                        else
                            if(rbDaily.Checked)
                                ucDaily.GetValues(r);
                            else
                                if(rbHourly.Checked)
                                    ucHourly.GetValues(r);
                                else
                                    if(rbMinutely.Checked)
                                        ucMinutely.GetValues(r);
                                    else
                                        ucSecondly.GetValues(r);

            recurrence.Parse(r.ToString());
        }