Exemplo n.º 1
0
        private void CalendarButton_Click(object sender, RoutedEventArgs e)
        {
            ZCalendarButton calendarButton = sender as ZCalendarButton;
            DateTime        dateTime       = (DateTime)calendarButton.DataContext;

            if (this.Owner.DisplayMode == CalendarMode.Year)
            {
                this.Owner.DisplayMode = CalendarMode.Month;
                this.Owner.DisplayDate = new DateTime(dateTime.Year, dateTime.Month, 1);
            }
            else
            {
                this.Owner.DisplayMode = CalendarMode.Year;
                this.Owner.DisplayDate = new DateTime(dateTime.Year, this.DisplayDate.Month, 1);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设置Decade模式下的子项(例:2010~2019)
        /// </summary>
        private void SetYearButtons()
        {
            int decadeStart = this.DisplayDate.Year - this.DisplayDate.Year % 10;

            int num = 0;

            foreach (object item in this.PART_YearView.Children)
            {
                DateTime        dateTime       = new DateTime(decadeStart + num, 1, 1);
                ZCalendarButton calendarButton = item as ZCalendarButton;
                calendarButton.DataContext      = dateTime;
                calendarButton.Content          = dateTime.Year;
                calendarButton.HasSelectedDates = false;
                if (this.Owner != null && this.Owner.DisplayDate != null && dateTime.Year == this.Owner.DisplayDate.Year)
                {
                    calendarButton.HasSelectedDates = true;
                }
                num++;
            }
        }
Exemplo n.º 3
0
        private void InitYearGrid()
        {
            if (this.PART_YearView == null)
            {
                return;
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    ZCalendarButton calendarButton = new ZCalendarButton();
                    calendarButton.SetValue(Grid.RowProperty, i);
                    calendarButton.SetValue(Grid.ColumnProperty, j);
                    calendarButton.SetValue(ZCalendarButton.HasSelectedDatesProperty, false);
                    calendarButton.Click += CalendarButton_Click;
                    this.PART_YearView.Children.Add(calendarButton);
                    this.CalendarButtons[i, j] = calendarButton;
                }
            }
        }