public void ResizeDayObject(DayObjectCollections selectedDays, DayObjectCollections checkedDays) { if (selectedDays == null) { selectedDays = new DayObjectCollections(); } if (checkedDays == null) { checkedDays = new DayObjectCollections(); } // Calculate Day in this month int iAreaWidth = m_rcClient.Width; int iAreaHeight = m_rcClient.Height - base.Style.CalendarHeader.Height - base.Style.WeekHeader.Height;// this.HeaderSizeToDraw - this.HeaderSizeWeek; int iWidth = iAreaWidth / 7; int iHeight = iAreaHeight / m_iWeekCount; int iWidthLast = iAreaWidth - iWidth * 6; int iHeightLast = iAreaHeight - iHeight * (m_iWeekCount - 1); int iCount = 0; int x1, y1; DateTime dtTmp = m_date; dtTmp = dtTmp.AddDays(-1 * (int)dtTmp.DayOfWeek); for (int i = 0; i < m_iWeekCount; ++i) { for (int j = 0; j < DAY_PER_WEEK; ++j) { x1 = m_rcClient.Left + j * iWidth; y1 = m_rcClient.Top + base.Style.CalendarHeader.Height + base.Style.WeekHeader.Height /*this.HeaderSizeToDraw + this.HeaderSizeWeek*/ + i * iHeight; Rectangle rc = new Rectangle(x1, y1, j < DAY_PER_WEEK - 1 ? iWidth : iWidthLast, i < m_iWeekCount - 1 ? iHeight : iHeightLast); if (iCount < m_arDays.Count) { DayObject dob = (DayObject)m_arDays[iCount]; dob.Selected = selectedDays.Contains(dob); dob.Checked = checkedDays.Contains(dob); dob.ClientRectangle = rc; if (dob.EditorControl != null) { dob.EditorControl.Location = new Point(dob.ClientRectangle.Location.X + 1, dob.ClientRectangle.Location.Y + 1);// m_rcClient.Location; dob.EditorControl.Size = new Size(dob.ClientRectangle.Size.Width - 1, dob.ClientRectangle.Size.Height - 1); } } iCount++; //DayObject dob = new DayObject(m_owner, rc, dtTmp); //dob.Selected = false; //m_arDays.Add(dob); //dtTmp = dtTmp.AddDays(1); //iCount++; } } }
public void CreateDayObject(DayObjectCollections selectedDays, DayObjectCollections checkedDays) { if (selectedDays == null) { selectedDays = new DayObjectCollections(); } if (checkedDays == null) { checkedDays = new DayObjectCollections(); } // Calculate Day in this month int iAreaWidth = m_rcClient.Width; int iAreaHeight = m_rcClient.Height - base.Style.CalendarHeader.Height - base.Style.WeekHeader.Height;// this.HeaderSizeToDraw - this.HeaderSizeWeek; int iWidth = iAreaWidth / 7; int iHeight = iAreaHeight / m_iWeekCount; int iWidthLast = iAreaWidth - iWidth * 6; int iHeightLast = iAreaHeight - iHeight * (m_iWeekCount - 1); int iCount = 1; int x1, y1; DateTime dtTmp = m_date; dtTmp = dtTmp.AddDays(-1 * (int)dtTmp.DayOfWeek); m_arDays.Clear(); for (int i = 0; i < m_iWeekCount; ++i) { for (int j = 0; j < DAY_PER_WEEK; ++j) { x1 = m_rcClient.Left + j * iWidth; y1 = m_rcClient.Top + base.Style.CalendarHeader.Height + base.Style.WeekHeader.Height /*this.HeaderSizeToDraw + this.HeaderSizeWeek*/ + i * iHeight; Rectangle rc = new Rectangle(x1, y1, j < DAY_PER_WEEK - 1 ? iWidth : iWidthLast, i < m_iWeekCount - 1 ? iHeight : iHeightLast); DayObject dob = new DayObject(m_owner, rc, dtTmp); dob.Show = false; if (m_date.Month == dob.Date.Month) { dob.Show = true; } else { if (dob.Date < m_date && m_bShowDayBeforeThisMonth) { dob.Show = true; } else if (dob.Date > m_date && m_bShowDayAfterThisMonth) { dob.Show = true; } } dob.MonthObject = this; //if (m_date.Month == dob.Date.Month) { if (selectedDays.Contains(dob)) { //int index = selectedDays.IndexOf(dob); //dob = (DayObject)selectedDays[index].Clone(); dob.Selected = true; dob.ClientRectangle = rc; } else { dob.Selected = false; } if (checkedDays.Contains(dob)) { dob.Checked = true; } else { dob.Checked = false; } //} dob.ShowCheckBox = this.ShowCheckBox; if (this.m_editorControl != null) { Type t = m_editorControl.GetType(); dob.EditorControl = (Control)Activator.CreateInstance(t); } m_arDays.Add(dob); dtTmp = dtTmp.AddDays(1); iCount++; } } m_arDays.Sort(); }