public override void DrawDayHeader(System.Drawing.Graphics g, System.Drawing.Rectangle rect, DateTime date)
{
if (g == null)
throw new ArgumentNullException("g");
using (StringFormat format = new StringFormat())
{
format.Alignment = StringAlignment.Center;
format.FormatFlags = StringFormatFlags.NoWrap;
format.LineAlignment = StringAlignment.Center;
using (StringFormat formatdd = new StringFormat())
{
formatdd.Alignment = StringAlignment.Near;
formatdd.FormatFlags = StringFormatFlags.NoWrap;
formatdd.LineAlignment = StringAlignment.Center;
using (SolidBrush brush = new SolidBrush(this.BackColor))
g.FillRectangle(brush, rect);
using (Pen aPen = new Pen(Color.FromArgb(205, 219, 238)))
g.DrawLine(aPen, rect.Left, rect.Top + (int)rect.Height / 2, rect.Right, rect.Top + (int)rect.Height / 2);
using (Pen aPen = new Pen(Color.FromArgb(141, 174, 217)))
g.DrawRectangle(aPen, rect);
rect.X += 1;
rect.Width -= 1;
using (Pen aPen = new Pen(Color.FromArgb(141, 174, 217)))
g.DrawRectangle(aPen, rect);
Rectangle topPart = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, (int)(rect.Height / 2) - 1);
Rectangle lowPart = new Rectangle(rect.Left + 1, rect.Top + (int)(rect.Height / 2) + 1, rect.Width - 1, (int)(rect.Height / 2) - 1);
using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(228, 236, 246), Color.FromArgb(214, 226, 241), LinearGradientMode.Vertical))
g.FillRectangle(aGB, topPart);
using (LinearGradientBrush aGB = new LinearGradientBrush(lowPart, Color.FromArgb(194, 212, 235), Color.FromArgb(208, 222, 239), LinearGradientMode.Vertical))
g.FillRectangle(aGB, lowPart);
if (date.Date.Equals(DateTime.Now.Date))
{
topPart.Inflate((int)(-topPart.Width / 4 + 1), 1); //top left orange area
topPart.Offset(rect.Left - topPart.Left + 1, 1);
topPart.Inflate(1, 0);
using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(247, 207, 114), Color.FromArgb(251, 230, 148), LinearGradientMode.Horizontal))
{
topPart.Inflate(-1, 0);
g.FillRectangle(aGB, topPart);
}
topPart.Offset(rect.Right - topPart.Right, 0); //top right orange
topPart.Inflate(1, 0);
using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(251, 230, 148), Color.FromArgb(247, 207, 114), LinearGradientMode.Horizontal))
{
topPart.Inflate(-1, 0);
g.FillRectangle(aGB, topPart);
}
using (Pen aPen = new Pen(Color.FromArgb(128, 240, 154, 30))) //center line
g.DrawLine(aPen, rect.Left, topPart.Bottom - 1, rect.Right, topPart.Bottom - 1);
topPart.Inflate(0, -1);
topPart.Offset(0, topPart.Height + 1); //lower right
using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.BackwardDiagonal))
g.FillRectangle(aGB, topPart);
topPart.Offset(rect.Left - topPart.Left + 1, 0); //lower left
using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.ForwardDiagonal))
g.FillRectangle(aGB, topPart);
using (Pen aPen = new Pen(Color.FromArgb(238, 147, 17)))
g.DrawRectangle(aPen, rect);
}
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
//get short dayabbr. if narrow dayrect
string sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek);
if (rect.Width < 105)
sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);
rect.Offset(2, 1);
using (Font fntDay = new Font("Segoe UI", 8))
g.DrawString(sTodaysName, fntDay, SystemBrushes.WindowText, rect, format);
rect.Offset(-2, -1);
using (Font fntDayDate = new Font("Segoe UI", 9, FontStyle.Bold))
g.DrawString(date.ToString(" d"), fntDayDate, SystemBrushes.WindowText, rect, formatdd);
}
}
}