Example #1
0
        private static void OnDateRangeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            //DateRangePickerに新しいDateRangeがセットされときによびだされる。
            DateRangePicker2 dateRangePicker = (DateRangePicker2)sender;


            DateRange oldDateRange = (DateRange)e.OldValue;
            DateRange newDateRange = (DateRange)e.NewValue;

            if (DateRange.EqualsDateRange(oldDateRange, newDateRange))
            {
                return;
            }

            DateUnit fromDate = newDateRange.FromDate;

            dateRangePicker.FromYear  = fromDate.Year.ToString();
            dateRangePicker.FromMonth = fromDate.Month.ToString();
            dateRangePicker.FromDay   = fromDate.Day.ToString();
            DateUnit toDate = newDateRange.ToDate;

            dateRangePicker.ToYear  = toDate.Year.ToString();
            dateRangePicker.ToMonth = toDate.Month.ToString();
            dateRangePicker.ToDay   = toDate.Day.ToString();

            //DateRangePickerの変更を監視しているオブジェクトに変更を通知。
            dateRangePicker.OnDateRangeChanged(oldDateRange, newDateRange);
        }
Example #2
0
        private static object CoerceToDay(DependencyObject d, object value)
        {
            DateRangePicker2 dateRangePicker = (DateRangePicker2)d;
            DateRange        dateRange       = dateRangePicker.DateRange;

            return(ToValidDay(dateRange.ToYear, dateRange.ToMonth, value).ToString());
        }
Example #3
0
        private static void OnTextFieldChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e, Action <DateRange, string> action)
        {
            DateRangePicker2 dateRangePicker = (DateRangePicker2)sender;
            DateRange        oldDateRange    = dateRangePicker.DateRange;
            DateRange        newDateRange    = (DateRange)oldDateRange.Clone();

            action(newDateRange, (string)e.NewValue);
            dateRangePicker.DateRange = newDateRange;
        }
Example #4
0
        private static void OnToDayChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DateRangePicker2           dateRangePicker = (DateRangePicker2)sender;
            DateRange                  dateRange       = dateRangePicker.DateRange;
            Action <DateRange, string> action          = (newDateRange, newValue) =>
            {
                newDateRange.ToDay = ToValidDay(dateRange.ToYear, dateRange.ToMonth, (string)newValue);
            };

            OnTextFieldChanged(sender, e, action);
        }