78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace CPM.Monthcalendar
|
|
{
|
|
public class LV_MonthCalendar : MonthCalendar
|
|
{
|
|
// Fields for appearance
|
|
private Color titleBackColor = Color.MediumSlateBlue;
|
|
private Color titleForeColor = Color.White;
|
|
private Color dayForeColor = Color.Black;
|
|
private Color borderColor = Color.PaleVioletRed;
|
|
private int borderSize = 2;
|
|
|
|
// Properties
|
|
public Color TitleBackColor
|
|
{
|
|
get { return titleBackColor; }
|
|
set { titleBackColor = value; this.Invalidate(); }
|
|
}
|
|
|
|
public Color TitleForeColor
|
|
{
|
|
get { return titleForeColor; }
|
|
set { titleForeColor = value; this.Invalidate(); }
|
|
}
|
|
|
|
public Color DayForeColor
|
|
{
|
|
get { return dayForeColor; }
|
|
set { dayForeColor = value; this.Invalidate(); }
|
|
}
|
|
|
|
public Color BorderColor
|
|
{
|
|
get { return borderColor; }
|
|
set { borderColor = value; this.Invalidate(); }
|
|
}
|
|
|
|
public int BorderSize
|
|
{
|
|
get { return borderSize; }
|
|
set { borderSize = value; this.Invalidate(); }
|
|
}
|
|
|
|
public LV_MonthCalendar()
|
|
{
|
|
// Customizations on creation
|
|
this.TitleBackColor = titleBackColor;
|
|
this.TitleForeColor = titleForeColor;
|
|
this.ForeColor = dayForeColor;
|
|
this.Font = new Font("Arial", 10F, FontStyle.Regular);
|
|
}
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
base.OnPaint(e);
|
|
// Drawing custom border
|
|
using (Pen borderPen = new Pen(borderColor, borderSize))
|
|
{
|
|
e.Graphics.DrawRectangle(borderPen, this.ClientRectangle.X, this.ClientRectangle.Y,
|
|
this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1);
|
|
}
|
|
}
|
|
|
|
// Example method to adjust title colors dynamically
|
|
protected override void OnDateChanged(DateRangeEventArgs e)
|
|
{
|
|
base.OnDateChanged(e);
|
|
this.TitleBackColor = Color.FromArgb(100, 150, 200); // Dynamic title color change
|
|
}
|
|
}
|
|
}
|