Exemple #1
0
        /// <summary>
        /// 双日历模式下的第二个日历的日期点击处理事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PART_Calendar_Second_DateClick(object sender, RoutedPropertyChangedEventArgs <DateTime?> e)
        {
            if (this.PART_Calendar_Second.SelectedDate == null)
            {
                return;
            }

            if (sender is ZCalendar)
            {
                if (this.PART_Calendar_Second.DisplayMode == CalendarMode.Month)
                {
                    ZCalendar calendar = sender as ZCalendar;
                    if (calendar == null)
                    {
                        return;
                    }
                    if (calendar.SelectedDate == null)
                    {
                        return;
                    }
                    switch (this.Type)
                    {
                    case EnumDatePickerType.SingleDateRange:
                        this.HandleSingleDateRange(calendar);
                        break;
                    }
                }
            }
        }
Exemple #2
0
        private static void SelectedDatesChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ZCalendar calendar = d as ZCalendar;

            if (calendar.PART_CalendarItem == null)
            {
                return;
            }
            calendar.PART_CalendarItem.SetSelectedDatesHighlight(calendar.SelectedDates);
        }
Exemple #3
0
        private static void DisplayModeChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ZCalendar calendar = d as ZCalendar;

            if (calendar != null)
            {
                calendar.UpdateCellItems();
                calendar.OnDisplayModeChanged((CalendarMode)e.OldValue, (CalendarMode)e.NewValue);
            }
        }
Exemple #4
0
        private static void DisplayDateChangedCalllback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ZCalendar calendar = d as ZCalendar;
            DateTime  oldTime  = Convert.ToDateTime(e.OldValue);
            DateTime  newTime  = Convert.ToDateTime(e.NewValue);

            if (calendar != null)
            {
                calendar.UpdateCellItems();
                calendar.OnDisplayDateChanged(oldTime, newTime);
            }
        }
Exemple #5
0
        private static void SelectedDateChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ZCalendar calendar = d as ZCalendar;

            if (calendar.SelectionMode == CalendarSelectionMode.SingleDate)
            {
                calendar.OnSelectedDateChanged(new DateTime?(Convert.ToDateTime(e.OldValue)), new DateTime?(Convert.ToDateTime(e.NewValue)));
            }
            if (calendar.PART_CalendarItem != null)
            {
                calendar.PART_CalendarItem.UpdateMonthMode();
            }
        }
Exemple #6
0
        /// <summary>
        /// 日期连选
        /// </summary>
        /// <param name="calendar"></param>
        private void HandleSingleDateRange(ZCalendar calendar)
        {
            DateTime?dateTime = calendar.SelectedDate;

            if (this.SelectedDateStart != null && this.SelectedDateEnd != null)
            {
                this.SelectedDates.Clear();
                this.PART_Calendar.SelectedDates.Clear();
                this.PART_Calendar_Second.SelectedDates.Clear();
                this.SelectedDateStart                 = null;
                this.SelectedDateEnd                   = null;
                this.PART_Calendar.SelectedDate        = null;
                this.PART_Calendar_Second.SelectedDate = null;
            }

            if (this.SelectedDateStart == null)
            {
                this.SelectedDateStart = dateTime;
                calendar.SelectedDate  = dateTime;
            }
            else if (calendar.SelectedDate < this.SelectedDateStart)
            {
                this.SelectedDates.Clear();
                this.PART_Calendar.SelectedDates.Clear();
                this.PART_Calendar_Second.SelectedDates.Clear();
                this.SelectedDateStart                 = dateTime;
                this.PART_Calendar.SelectedDate        = null;
                this.PART_Calendar_Second.SelectedDate = null;
                calendar.SelectedDate = dateTime;
            }
            else
            {
                this.SelectedDateEnd = dateTime;
                this.SetSelectedDates(this.SelectedDateStart, this.SelectedDateEnd);

                this.SetRangeDateToTextBox(this.SelectedDateStart, this.SelectedDateEnd);
            }
        }
Exemple #7
0
        public override void OnApplyTemplate()
        {
            if (this.PART_Calendar != null)
            {
                this.PART_Calendar.Owner = null;
            }
            if (this.PART_Calendar_Second != null)
            {
                this.PART_Calendar_Second.Owner = null;
            }

            base.OnApplyTemplate();

            this.PART_Popup_New              = GetTemplateChild("PART_Popup_New") as Popup;
            this.PART_Popup_TimeSelector     = GetTemplateChild("PART_Popup_TimeSelector") as Popup;
            this.PART_Calendar               = GetTemplateChild("PART_Calendar") as ZCalendar;
            this.PART_Calendar_Second        = GetTemplateChild("PART_Calendar_Second") as ZCalendar;
            this.PART_TimeSelector           = GetTemplateChild("PART_TimeSelector") as TimeSelector;
            this.PART_TextBox_New            = GetTemplateChild("PART_TextBox_New") as TextBox;
            this.PART_Btn_Today              = GetTemplateChild("PART_Btn_Today") as Button;
            this.PART_Btn_Yestday            = GetTemplateChild("PART_Btn_Yestday") as Button;
            this.PART_Btn_AWeekAgo           = GetTemplateChild("PART_Btn_AWeekAgo") as Button;
            this.PART_Btn_RecentlyAWeek      = GetTemplateChild("PART_Btn_RecentlyAWeek") as Button;
            this.PART_Btn_RecentlyAMonth     = GetTemplateChild("PART_Btn_RecentlyAMonth") as Button;
            this.PART_Btn_RecentlyThreeMonth = GetTemplateChild("PART_Btn_RecentlyThreeMonth") as Button;
            this.PART_ConfirmSelected        = GetTemplateChild("PART_ConfirmSelected") as Button;
            this.PART_ClearDate              = GetTemplateChild("PART_ClearDate") as Button;

            if (this.PART_Popup_New != null)
            {
                this.PART_Popup_New.Opened += PART_Popup_New_Opened;
            }

            if (this.PART_Popup_TimeSelector != null)
            {
                this.PART_Popup_TimeSelector.Opened += PART_Popup_TimeSelector_Opened;
            }

            if (this.PART_Calendar != null)
            {
                this.PART_Calendar.Owner               = this;
                this.PART_Calendar.DateClick          += PART_Calendar_DateClick;
                this.PART_Calendar.DisplayDateChanged += PART_Calendar_DisplayDateChanged;
                if (this.Type == EnumDatePickerType.SingleDateRange)
                {
                    this.PART_Calendar.DisplayDate = new DateTime(this.DisplayDate.Year, this.DisplayDate.Month, 1);
                }
            }

            if (this.PART_Calendar_Second != null)
            {
                this.PART_Calendar_Second.Owner       = this;
                this.PART_Calendar_Second.DisplayMode = CalendarMode.Month;
                this.PART_Calendar_Second.DisplayDate = this.PART_Calendar.DisplayDate.AddMonths(1);

                this.PART_Calendar_Second.DisplayDateChanged += PART_Calendar_Second_DisplayDateChanged;
                this.PART_Calendar_Second.DateClick          += PART_Calendar_Second_DateClick;
            }

            if (this.PART_TimeSelector != null)
            {
                this.PART_TimeSelector.SelectedTimeChanged += PART_TimeSelector_SelectedTimeChanged;
            }

            if (this.PART_Btn_Today == null)
            {
                this.PART_Btn_Today.Click -= this.PART_Btn_Today_Click;
            }
            if (this.PART_Btn_Yestday == null)
            {
                this.PART_Btn_Yestday.Click -= this.PART_Btn_Yestday_Click;
            }
            if (this.PART_Btn_AWeekAgo == null)
            {
                this.PART_Btn_AWeekAgo.Click -= PART_Btn_AnWeekAgo_Click;
            }

            if (this.PART_Btn_Today != null)
            {
                this.PART_Btn_Today.Click += PART_Btn_Today_Click;
            }
            if (this.PART_Btn_Yestday != null)
            {
                this.PART_Btn_Yestday.Click += PART_Btn_Yestday_Click;
            }
            if (this.PART_Btn_AWeekAgo != null)
            {
                this.PART_Btn_AWeekAgo.Click += PART_Btn_AnWeekAgo_Click;
            }
            if (this.PART_Btn_RecentlyAWeek != null)
            {
                this.PART_Btn_RecentlyAWeek.Click += PART_Btn_RecentlyAWeek_Click;;
            }
            if (this.PART_Btn_RecentlyAMonth != null)
            {
                this.PART_Btn_RecentlyAMonth.Click += PART_Btn_RecentlyAMonth_Click;;
            }
            if (this.PART_Btn_RecentlyThreeMonth != null)
            {
                this.PART_Btn_RecentlyThreeMonth.Click += PART_Btn_RecentlyThreeMonth_Click;;
            }

            if (this.PART_ConfirmSelected != null)
            {
                this.PART_ConfirmSelected.Click += (o, e) => { this.IsDropDownOpen = false; };
            }

            if (this.PART_ClearDate != null)
            {
                this.PART_ClearDate.Click += PART_ClearDate_Click;
            }

            if (this.SelectedDate.HasValue)
            {
                this.SetSingleDateToTextBox(this.SelectedDate);
                this.SetSelectedDate();
            }

            if (this.SelectedDateStart.HasValue && this.SelectedDateEnd.HasValue)
            {
                this.SetRangeDateToTextBox(this.SelectedDateStart, this.SelectedDateEnd);
                this.SetSelectedDates(this.SelectedDateStart, this.SelectedDateEnd);
            }
            this.SetSelectionMode(this, this.Type);
            this.SetIsShowConfirm();
        }