Пример #1
0
        public static void OnDateFormatChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            PosDatePicker dtp = (PosDatePicker)obj;

            if (dtp.DateFormat.Contains("H") || dtp.DateFormat.Contains("h"))
            {
                dtp.TimeDisplay.Visibility = Visibility.Visible;
            }
            dtp.DateDisplay.Text = dtp.SelectedDate.Value.ToString(dtp.DateFormat);
        }
Пример #2
0
        private static object CoerceMaxDate(DependencyObject d, object value)
        {
            PosDatePicker dtpicker = (PosDatePicker)d;
            DateTime      current  = Convert.ToDateTime(value);

            if (current <= dtpicker.MinimumDate)
            {
                throw new ArgumentException("MaximimumDate can not be equal to, or less than MinimumDate");
            }
            if (current < dtpicker.SelectedDate)
            {
                dtpicker.SelectedDate = current;
            }

            return(current);
        }
Пример #3
0
        public static void OnSelectedDateChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            PosDatePicker dtp = (PosDatePicker)obj;

            if (args.NewValue == null)
            {
                dtp.SelectedDate     = Convert.ToDateTime(args.NewValue);
                dtp.DateDisplay.Text = "Tarih Hatalı";
            }
            else
            {
                dtp.DateDisplay.Text        = Convert.ToDateTime(args.NewValue).ToString(dtp.DateFormat);
                dtp.TimeDisplay.Value       = Convert.ToDateTime(args.NewValue);
                dtp.CalDisplay.SelectedDate = Convert.ToDateTime(args.NewValue);
                dtp.CalDisplay.DisplayDate  = Convert.ToDateTime(args.NewValue);
            }
        }
Пример #4
0
        private static object CoerceDate(DependencyObject d, object value)
        {
            PosDatePicker dtpicker = (PosDatePicker)d;
            DateTime      current  = Convert.ToDateTime(value);

            if (current < dtpicker.MinimumDate)
            {
                current = dtpicker.MinimumDate;
            }

            if (current > dtpicker.MaximumDate)
            {
                current = dtpicker.MaximumDate;
            }

            return(current);
        }