예제 #1
0
 private void UpdateCurSel(DateTime newDate, bool redraw, int monthIndex, bool setNone)
 {
     bool isNone = this.m_isNone;
     this.m_isNone = setNone;
     bool flag2 = (this.m_curSel.Month != newDate.Month) || (this.m_curSel.Year != newDate.Year);
     DateTime curSel = this.m_curSel;
     DateTime date = newDate;
     MonthChangeBeforeEventArgs e = new MonthChangeBeforeEventArgs(curSel, newDate);
     if (flag2)
     {
         this.OnMonthChangeBefore(e);
         newDate = e.NewDate;
     }
     bool flag3 = ((this.m_curSel != newDate) || (this.m_isNone != isNone)) ? !e.Cancel : false;
     if ((newDate >= this.MinDate) && (newDate <= this.MaxDate))
     {
         DateTime time3 = this.m_curSel;
         if (!e.Cancel)
         {
             this.m_curSel = newDate;
             this.m_hoverSel = newDate;
         }
         if (!e.Cancel)
         {
             if (monthIndex == -1)
             {
                 if ((this.m_curYear == -1) || (this.m_curMonth == -1))
                 {
                     this.m_curMonth = newDate.Month;
                     this.m_curYear = newDate.Year;
                     this.CalculateDays(this.m_monthCount);
                     redraw = true;
                 }
                 else
                 {
                     DateTime time4 = new DateTime(this.m_curYear, this.m_curMonth, 1);
                     if ((newDate < time4) || (newDate >= time4.AddMonths(this.m_monthCount)))
                     {
                         if (newDate < time4)
                         {
                             this.m_curMonth = newDate.Month;
                             this.m_curYear = newDate.Year;
                         }
                         if (newDate >= time4.AddMonths(this.m_monthCount))
                         {
                             DateTime time5 = newDate.AddMonths(-(this.m_monthCount - 1));
                             this.m_curMonth = time5.Month;
                             this.m_curYear = time5.Year;
                         }
                         this.CalculateDays(this.m_monthCount);
                         redraw = true;
                     }
                     else
                     {
                         redraw = false;
                     }
                 }
             }
             else
             {
                 DateTime time6 = newDate.AddMonths(-monthIndex);
                 this.m_curMonth = time6.Month;
                 this.m_curYear = time6.Year;
                 this.CalculateDays(this.m_monthCount);
                 redraw = true;
             }
         }
         if (base.Visible && (this.m_graphics != null))
         {
             if (redraw)
             {
                 this.m_redraw = true;
             }
             else
             {
                 if (e.Cancel || (newDate != date))
                 {
                     int mIndex = this.GetMonthIndex(date);
                     int dayIndex = this.GetDayIndex(date, mIndex);
                     if (this.IsInsideAnyGrid(mIndex, dayIndex))
                     {
                         if (this.DaysGrid)
                         {
                             this.DrawHoverSelection(this.m_graphics, date, false);
                         }
                         this.DrawDay(this.m_graphics, date, false, true, false, this.m_layout.GetMonthLayout(mIndex).GetCellBounds(dayIndex), mIndex);
                     }
                     this.RedrawBrokenBorders(mIndex, dayIndex);
                 }
                 if (!e.Cancel)
                 {
                     int num3 = this.GetMonthIndex(time3);
                     int num4 = this.GetDayIndex(time3, num3);
                     if (this.IsInsideAnyGrid(num3, num4))
                     {
                         if (this.DaysGrid)
                         {
                             this.DrawHoverSelection(this.m_graphics, time3, false);
                         }
                         this.DrawDay(this.m_graphics, time3, false, true, false, this.m_layout.GetMonthLayout(num3).GetCellBounds(num4), num3);
                     }
                     this.RedrawBrokenBorders(num3, num4);
                     if (!setNone)
                     {
                         num3 = this.GetMonthIndex(newDate);
                         num4 = this.GetDayIndex(newDate, num3);
                         if (this.IsInsideAnyGrid(num3, num4))
                         {
                             this.DrawDay(this.m_graphics, newDate, true, true, false, this.m_layout.GetMonthLayout(num3).GetCellBounds(num4), num3);
                         }
                     }
                     this.DrawTodaySelection(this.m_graphics);
                     if (!setNone)
                     {
                         this.DrawHoverSelection(this.m_graphics, newDate, true);
                     }
                 }
             }
             base.Invalidate();
         }
         if (!e.Cancel && flag2)
         {
             this.OnMonthChangeAfter(new MonthChangeAfterEventArgs(curSel, newDate));
         }
         if ((this.ValueChanged != null) && flag3)
         {
             this.ValueChanged(this, EventArgs.Empty);
         }
     }
 }
예제 #2
0
 protected void OnMonthChangeBefore(MonthChangeBeforeEventArgs e)
 {
     if (this.MonthChangeBefore != null)
     {
         this.MonthChangeBefore(this, e);
     }
 }