int IComparer.Compare(object x, object y) { DayObject dx = (DayObject)x; DayObject dy = (DayObject)y; return(DateTime.Compare(dx.Date, dy.Date)); }
public object Clone() { DayObject dNew = new DayObject(m_owner, m_rcClient, m_date); PropertyInfo[] pInfo = dNew.GetType().GetProperties(); foreach (PropertyInfo p in pInfo) { if (p.CanWrite) { PropertyInfo pCur = this.GetType().GetProperty(p.Name); if (pCur != null) { if (pCur.CanRead) { object oValue = pCur.GetValue(this, null); if (oValue != null) { p.SetValue(dNew, oValue, null); } } } } } return(dNew); }
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 Dispose() { for (int i = 0; i < m_arDays.Count; ++i) { DayObject dob = (DayObject)m_arDays[i]; dob.Dispose(); dob = null; } m_arDays.Clear(); GC.Collect(); }
//public DayObject[] GetDaysInRect(Rectangle rc) { // DayObject dayStart = GetFirstStartDayFromPoint(rc.Location); // DayObject dayEnd = GetFirstEndDayFromPoint(new Point(rc.Top, rc.Right)); // ArrayList ar = new ArrayList(); // foreach (DayObject d in m_arDays) { // if (d.Show && d.Date >= dayStart.Date && d.Date <= dayEnd.Date) { // ar.Add(d); // } // } // DayObject[] r = new DayObject[ar.Count]; // ar.CopyTo(r); // return r; //} public DayObject[] GetDaysBetweenDate(DateTime d1, DateTime d2) { ArrayList ar = new ArrayList(); foreach (DayObject d in m_arDays) { if (d.Show && d.Date >= d1 && d.Date <= d2) { ar.Add(d); } } DayObject[] r = new DayObject[ar.Count]; ar.CopyTo(r); return(r); }
public DayObject GetFirstEndDayFromPoint(Point pt) { DayObject dayEnd = GetDateFromPoint(pt.X, pt.Y); if (dayEnd == null) { Rectangle rc = new Rectangle(m_rcClient.Left, m_rcClient.Top, m_rcClient.Width - (m_rcClient.Right - pt.X), m_rcClient.Height - (m_rcClient.Bottom - pt.Y)); for (int i = m_arDays.Count - 1; i >= 0; --i) { DayObject d = (DayObject)m_arDays[i]; if (d.Show) { if (rc.IntersectsWith(d.ClientRectangle)) { dayEnd = d; break; } } } } return(dayEnd); }
public DayObject GetFirstStartDayFromPoint(Point pt) { DayObject dayStart = GetDateFromPoint(pt.X, pt.Y); if (dayStart == null) // { Rectangle rc = new Rectangle(pt.X, pt.Y, m_rcClient.Right - pt.X, m_rcClient.Bottom - pt.Y); for (int i = 0; i < m_arDays.Count; ++i) { DayObject d = (DayObject)m_arDays[i]; if (d.Show) { if (rc.IntersectsWith(d.ClientRectangle)) { dayStart = d; break; } } } } return(dayStart); }
public bool Contains(DayObject value) { // If value is not of type DayObject, this will return false. return(List.Contains(value)); }
public void Remove(DayObject value) { List.Remove(value); }
public void Insert(int index, DayObject value) { List.Insert(index, value); }
public int IndexOf(DayObject value) { return(List.IndexOf(value)); }
public int Add(DayObject value) { return(List.Add(value)); }
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(); }
public override void PaintDay(Calendar calendar, Graphics g, MonthObject monthObj, DayObject dayObj) { base.PaintDay(calendar, g, monthObj, dayObj); StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; string v = this.Value.ToString(); if (v == string.Empty) { v = "NONE"; } g.DrawString(v, calendar.Font, Brushes.Blue, dayObj.ClientRectangle, sf); }
public virtual void PaintDay(Calendar calendar, Graphics g, MonthObject monthObj, DayObject dayObj) { calendar.PaintDay(g, monthObj, dayObj); }