Пример #1
0
        private void btnCalendar_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var modelFrom = new MyDatePicker.DateModel();
            var dateFrom  = _Value.ToDateTime();

            dateFrom        = dateFrom.Equals(DateTime.MinValue) ? DateTime.Now : dateFrom;
            modelFrom.Year  = dateFrom.Year;
            modelFrom.Month = dateFrom.Month;
            modelFrom.Day   = dateFrom.Day;

            var modelTo = new MyDatePicker.DateModel();
            var dateTo  = _Value2.ToDateTime();

            dateTo        = dateTo.Equals(DateTime.MinValue) ? DateTime.Now : dateTo;
            modelTo.Year  = dateTo.Year;
            modelTo.Month = dateTo.Month;
            modelTo.Day   = dateTo.Day;

            var model = new DateRangeModel();

            model.DateFrom = modelFrom;
            model.DateTo   = modelTo;

            var form = new MyCalendarDouble();

            form._Mode = _Mode;
            form._Init(model);
            FormCommon.ShowForm("", form, model, AfterCloseCallBack);
        }
Пример #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="date"></param>
        public void _Init(MyDatePicker.DateModel date, bool selectDateClose = true)
        {
            lblDate.Content      = string.Format("{0}-{1}", date.Year, date.Month.ToString().PadLeft(2, '0'));
            this.Year            = date.Year;
            this.Month           = date.Month;
            this.Date            = date;
            this.Year_Year       = date.Year;
            this.Year_Month      = date.Year;
            this.SelectDateClose = selectDateClose;
            SetCalendar(date.Year, date.Month);
            SetMonthCalendar(date.Year);
            SetYearCalendar(date.Year);

            if (_Mode == DateMode.Month)
            {
                this.Mode = 2;
                SetByMode();
            }
            else if (_Mode == DateMode.Year)
            {
                this.Mode = 3;
                SetByMode();
            }
        }