Exemple #1
0
        // CurrentShowingMonthChanged事件处理程序
        private void CurrentShowingMonthChangedHandler(object o)
        {
            DateMonth dateMonth = o as DateMonth;

            if (dateMonth == null)
            {
                throw new ArgumentException();
            }

            currentSelectedDate = new DateTime(dateMonth.Year, dateMonth.Month, currentSelectedDate.Day);

            OnCurrentSelectedDateChanged();
        }
Exemple #2
0
 /// <summary>
 /// 比较两个DateMonth类型相距的月份数,返回正数说明this更大,否则anotherMonth更大
 /// </summary>
 /// <param name="anotherMonth">待比较的月份</param>
 /// <returns></returns>
 public int Compare(DateMonth anotherMonth)
 {
     if (this.Year == anotherMonth.Year)
     {
         return(this.Month - anotherMonth.Month);
     }
     else if (this.Year - anotherMonth.Year == 1)
     {
         return(this.Month + (12 - anotherMonth.Month));
     }
     else if (this.Year - anotherMonth.Year == -1)
     {
         return(-((12 - this.Month) + anotherMonth.Month));
     }
     else if (this.Year - anotherMonth.Year > 1)
     {
         return((this.Year - anotherMonth.Year - 1) * 12 + this.Month + (12 - anotherMonth.Month));
     }
     else
     {
         return(-(this.Year - anotherMonth.Year - 1) * 12 + -((12 - this.Month) + anotherMonth.Month));
     }
 }
Exemple #3
0
        /// <summary>
        /// 比较该月份与另一月份相距的月份数,返回正数说明this更大,否则anotherMonth更大
        /// </summary>
        /// <param name="year">年</param>
        /// <param name="month">月</param>
        /// <returns></returns>
        public int Compare(int year, int month)
        {
            DateMonth dateMonth = new DateMonth(year, month);

            return(Compare(dateMonth));
        }
Exemple #4
0
 private static void OnCurrentShowingMonthChanged(DateMonth dateMonth)
 {
     CurrentShowingMonthChanged?.Invoke(dateMonth);
 }