Example #1
0
        private static void SelectedSecondChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AduTimeSelector AduTimeSelector = d as AduTimeSelector;

            AduTimeSelector.Second = e.NewValue == null ? 0 : (int)e.NewValue;
            AduTimeSelector.SetSelectedTime();
        }
Example #2
0
        private static void SelectedTimeChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AduTimeSelector AduTimeSelector = d as AduTimeSelector;
            DateTime        dt = (DateTime)e.NewValue;

            AduTimeSelector.SetButtonSelected();

            AduTimeSelector.OnSelectedTimeChanged((DateTime?)e.OldValue, (DateTime?)e.NewValue);
        }
Example #3
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.PART_TextBox      = this.GetTemplateChild("PART_TextBox") as TextBox;
            this.PART_TimeSelector = this.GetTemplateChild("PART_TimeSelector") as AduTimeSelector;
            this.PART_Popup        = this.GetTemplateChild("PART_Popup") as Popup;
            if (this.PART_TimeSelector != null)
            {
                this.PART_TimeSelector.Owner = this;
                this.PART_TimeSelector.SelectedTimeChanged += PART_TimeSelector_SelectedTimeChanged;
            }
            if (this.PART_Popup != null)
            {
                this.PART_Popup.Opened += PART_Popup_Opened;
            }
        }
Example #4
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 AduCalendar;
            this.PART_Calendar_Second        = GetTemplateChild("PART_Calendar_Second") as AduCalendar;
            this.PART_TimeSelector           = GetTemplateChild("PART_TimeSelector") as AduTimeSelector;
            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();
        }