Ejemplo n.º 1
0
 private void panelPreview_Paint(object sender, PaintEventArgs e)
 {
     try {
         if (cboLayout.Text.Trim() == string.Empty)
         {
             base.OnPaint(e);
         }
         else
         {
             CalendarLayout.LayoutType type   = (CalendarLayout.LayoutType)Enum.Parse(typeof(CalendarLayout.LayoutType), cboLayout.Text);
             CalendarLayout            l      = new CalendarLayout(type);
             MonthObject[]             months = l.GetMonthObject(null, panelPreview.ClientRectangle, 0, DateTime.Today.Year, DateTime.Today.Month, null, null);
             Pen          p  = Pens.Blue;
             StringFormat sf = new StringFormat();
             sf.Alignment     = StringAlignment.Center;
             sf.LineAlignment = StringAlignment.Center;
             int   iCount = 1;
             Brush br     = Brushes.Black;
             foreach (MonthObject m in months)
             {
                 e.Graphics.DrawLines(p, m.PointAroundRect);
                 e.Graphics.DrawString(iCount.ToString(), this.Font, br, m.ClientRectangle, sf);
                 iCount++;
             }
         }
     } catch (Exception ex) {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 2
0
 public void SetDay(DateTime dt)
 {
     m_date       = new DateTime(dt.Year, dt.Month, 1);
     m_iWeekCount = CalendarLayout.WeekInMonth(dt.Year, dt.Month);
 }