private void PresetHolidays() { var aprilFools = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 4, 1), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "April Fools Day" }; AddEvent(aprilFools); var memorialDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 5, 28), RecurringFrequency = RecurringFrequencies.Custom, EventText = "Memorial Day", CustomRecurringFunction = MemorialDayHandler }; AddEvent(memorialDay); var newYears = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 1, 1), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "New Years Day" }; AddEvent(newYears); var mlkDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 1, 15), RecurringFrequency = RecurringFrequencies.Custom, EventText = "Martin Luther King Jr. Day", CustomRecurringFunction = MlkDayHandler }; AddEvent(mlkDay); var presidentsDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 2, 15), RecurringFrequency = RecurringFrequencies.Custom, EventText = "President's Day", CustomRecurringFunction = MlkDayHandler }; AddEvent(presidentsDay); var independanceDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 7, 4), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Independence Day" }; AddEvent(independanceDay); var laborDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 9, 1), RecurringFrequency = RecurringFrequencies.Custom, EventText = "Labor Day", CustomRecurringFunction = LaborDayHandler }; AddEvent(laborDay); var columbusDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 10, 14), RecurringFrequency = RecurringFrequencies.Custom, EventText = "Columbus Day", CustomRecurringFunction = ColumbusDayHandler }; AddEvent(columbusDay); var veteransDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 11, 11), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Veteran's Day" }; AddEvent(veteransDay); var thanksgivingDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 11, 11), RecurringFrequency = RecurringFrequencies.Custom, EventText = "Thanksgiving Day", CustomRecurringFunction = ThanksgivingDayHandler }; AddEvent(thanksgivingDay); var christmas = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 12, 25), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Christmas Day" }; AddEvent(christmas); }
public Form1() { InitializeComponent(); calendar1.CalendarDate = new DateTime(2012, 5, 2, 0, 0, 0); calendar1.CalendarView = CalendarViews.Month; calendar1.AllowEditingEvents = true; var groundhogEvent = new HolidayEvent { Date = new DateTime(2012, 2, 2), EventText = "Groundhog Day", RecurringFrequency = RecurringFrequencies.Yearly }; calendar1.AddEvent(groundhogEvent); var exerciseEvent = new CustomEvent { Date = DateTime.Now, RecurringFrequency = RecurringFrequencies.EveryMonWedFri, EventLengthInHours = 1, EventText = "Time for Exercise!" }; calendar1.AddEvent(exerciseEvent); var rehabEvent = new CustomEvent { Date = DateTime.Now, RecurringFrequency = RecurringFrequencies.Custom, EventText = "Rehab Therapy", Rank = 3, CustomRecurringFunction = RehabDays }; calendar1.AddEvent(rehabEvent); //var ce = new CustomEvent(); //ce.EventText = "My Event"; //ce.Date = new DateTime(2012, 4, 1); //ce.RecurringFrequency = RecurringFrequencies.Monthly; //ce.EventFont = new Font("Verdana", 12, FontStyle.Regular); //ce.ThisDayForwardOnly = true; //ce.Enabled = true; //calendar1.AddEvent(ce); //var ce2 = new HolidayEvent(); //ce2.EventText = "test"; //ce2.Date = new DateTime(2012, 4, 2); //ce2.RecurringFrequency = RecurringFrequencies.EveryMonWedFri; //ce2.Rank = 3; //calendar1.AddEvent(ce2); var ce = new CustomEvent(); ce.IgnoreTimeComponent = false; ce.EventText = "Interview"; ce.Date = new DateTime(2012, 5, 2, 15, 30, 0); ce.EventLengthInHours = 2f; ce.RecurringFrequency = RecurringFrequencies.None; ce.EventFont = new Font("Verdana", 12, FontStyle.Regular); ce.Enabled = true; calendar1.AddEvent(ce); var ce2 = new CustomEvent { IgnoreTimeComponent = false, EventText = "Dinner", Date = new DateTime(2012, 5, 15, 18, 0, 0), EventLengthInHours = 2f, RecurringFrequency = RecurringFrequencies.None, EventFont = new Font("Verdana", 12, FontStyle.Regular), Enabled = true, EventColor = Color.FromArgb(120, 255, 120), EventTextColor = Color.Black, ThisDayForwardOnly=true }; calendar1.AddEvent(ce2); }
private void PresetHolidays() { var newYears = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 1, 1), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "New Years Day" }; AddEvent(newYears); DateTime familyDate = new DateTime (DateTime.Now.Year, 2, 15); while (familyDate.DayOfWeek != DayOfWeek.Monday) { familyDate.AddDays(1); } var familyDay = new HolidayEvent { Date = familyDate, RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Family Day", }; AddEvent(familyDay); DateTime victoriaDate = new DateTime(DateTime.Now.Year, 5, 18); while (victoriaDate.DayOfWeek != DayOfWeek.Monday) { victoriaDate.AddDays(1); } var victoriaDay = new HolidayEvent { Date = victoriaDate, RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Victoria Day", }; AddEvent(victoriaDay); DateTime civicDate = new DateTime(DateTime.Now.Year, 8, 1); while (civicDate.DayOfWeek != DayOfWeek.Monday) { civicDate.AddDays(1); } var civicHoliday = new HolidayEvent { Date = civicDate, RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Civic Holiday", }; AddEvent(victoriaDay); DateTime labourDate = new DateTime(DateTime.Now.Year, 9, 1); while (labourDate.DayOfWeek != DayOfWeek.Monday) { labourDate.AddDays(1); } var labourDay = new HolidayEvent { Date = labourDate, RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Labour Day", }; AddEvent(labourDay); DateTime thanksgivingDate = new DateTime(DateTime.Now.Year, 10, 8); while (thanksgivingDate.DayOfWeek != DayOfWeek.Monday) { thanksgivingDate.AddDays(1); } var thanksgiving = new HolidayEvent { Date = thanksgivingDate, RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Thanksgiving" }; AddEvent(thanksgiving); var canadaDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 7, 1), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Canada Day" }; AddEvent(canadaDay); var veteransDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 11, 11), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Remembrance Day" }; AddEvent(veteransDay); var christmas = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 12, 25), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Christmas Day" }; AddEvent(christmas); var boxingDay = new HolidayEvent { Date = new DateTime(DateTime.Now.Year, 12, 26), RecurringFrequency = RecurringFrequencies.Yearly, EventText = "Boxing Day" }; AddEvent(boxingDay); }