示例#1
0
        public override DatePicker Create(DeterministicRandom random)
        {
            DatePicker datePicker = new DatePicker();

            if (DisplayDate != null)
            {
                datePicker.DisplayDate = (DateTime)DisplayDate.GetData(random);
            }

            if (DisplayDateEnd != null)
            {
                datePicker.DisplayDateEnd = (DateTime)DisplayDateEnd.GetData(random);
            }

            if (DisplayDateStart != null)
            {
                datePicker.DisplayDateStart = (DateTime)DisplayDateStart.GetData(random);
            }

            datePicker.FirstDayOfWeek     = FirstDayOfWeek;
            datePicker.IsTodayHighlighted = IsTodayHighlighted;

            if (SelectedDate != null)
            {
                datePicker.SelectedDate = (DateTime)SelectedDate.GetData(random);
            }

            datePicker.SelectedDateFormat = SelectedDateFormat;
            return(datePicker);
        }
示例#2
0
        /// <summary>
        /// Createa a Calendar.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override Calendar Create(DeterministicRandom random)
        {
            Calendar calendar = new Calendar();

            if (DisplayDate != null)
            {
                calendar.DisplayDate = (DateTime)DisplayDate.GetData(random);
            }

            if (DisplayDateEnd != null)
            {
                calendar.DisplayDateEnd = (DateTime)DisplayDateEnd.GetData(random);
            }

            if (DisplayDateStart != null)
            {
                calendar.DisplayDateStart = (DateTime)DisplayDateStart.GetData(random);
            }

            calendar.FirstDayOfWeek     = FirstDayOfWeek;
            calendar.IsTodayHighlighted = IsTodayHighlighted;
            calendar.SelectionMode      = SelectionMode;
            calendar.DisplayMode        = DisplayMode;
            HomelessTestHelpers.Merge(calendar.BlackoutDates, BlackoutDates);

            //SelectedDate property cannot be set when the selection mode is None.
            // and
            //BlackoutDates cannot contain the SelectedDate.
            if (SelectedDate != null && calendar.SelectionMode != CalendarSelectionMode.None)
            {
                DateTime date = (DateTime)SelectedDate.GetData(random);
                if (!calendar.BlackoutDates.Contains(date))
                {
                    calendar.SelectedDate = date;
                }
            }

            return(calendar);
        }