public MainWindow() { InitializeComponent(); // Creating instance for custom appointment class Meeting meeting = new Meeting(); // Setting start time of an event meeting.From = new DateTime(2017, 06, 11, 10, 0, 0); // Setting end time of an event meeting.To = meeting.From.AddHours(2); // Setting start time for an event meeting.EventName = "Client Meeting"; // Setting color for an event meeting.Color = new SolidColorBrush(Color.FromArgb(0xFf, 0xD8, 0x00, 0x73)); meeting.IsRecursive = true; // Creating recurrence rule RecurrenceProperties recurrenceProperties = new RecurrenceProperties(); recurrenceProperties.RecurrenceType = RecurrenceType.Weekly; recurrenceProperties.IsWeeklyTuesday = true; recurrenceProperties.IsWeeklyWednesday = true; recurrenceProperties.IsWeeklyThursday = true; recurrenceProperties.RangeRecurrenceCount = 10; recurrenceProperties.RecurrenceRule = ScheduleHelper.RRuleGenerator(recurrenceProperties, meeting.From, meeting.To); // Setting recursive rule for an event meeting.RecurrenceRule = recurrenceProperties.RecurrenceRule; // Creating instance for collection of custom appointments var Meetings = new ObservableCollection <Meeting>(); // Adding a custom appointment in CustomAppointmentCollection Meetings.Add(meeting); this.schedule.ItemsSource = Meetings; schedule.MoveToDate(meeting.From); }
//Creating appointments for ScheduleAppointmentCollection public void GetAppointments() { appointmentCollection = new ScheduleAppointmentCollection(); //Recurrence Appointment 1 ScheduleAppointment appointment1 = new ScheduleAppointment(); Calendar currentDate = Calendar.Instance; Calendar startTime = (Calendar)currentDate.Clone(); Calendar endTime = (Calendar)currentDate.Clone(); startTime.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 4, 0, 0); endTime.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 6, 0, 0); appointment1.StartTime = startTime; appointment1.EndTime = endTime; appointment1.Color = Color.ParseColor("#FF1BA1E2"); appointment1.Subject = "Occurs once in every two days"; RecurrenceProperties recurrenceProp1 = new RecurrenceProperties(); recurrenceProp1.RecurrenceType = RecurrenceType.Daily; recurrenceProp1.Interval = 2; recurrenceProp1.RecurrenceRange = RecurrenceRange.Count; recurrenceProp1.RecurrenceCount = 10; appointment1.RecurrenceRule = ScheduleHelper.RRuleGenerator(recurrenceProp1, appointment1.StartTime, appointment1.EndTime); appointmentCollection.Add(appointment1); //Recurrence Appointment 2 ScheduleAppointment scheduleAppointment1 = new ScheduleAppointment(); Calendar currentDate1 = Calendar.Instance; Calendar startTime1 = (Calendar)currentDate1.Clone(); Calendar endTime1 = (Calendar)currentDate1.Clone(); startTime1.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 10, 0, 0); endTime1.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 12, 0, 0); scheduleAppointment1.StartTime = startTime1; scheduleAppointment1.EndTime = endTime1; scheduleAppointment1.Color = Color.ParseColor("#FFD80073"); scheduleAppointment1.Subject = "Occurs every Monday"; RecurrenceProperties recurrenceProperties1 = new RecurrenceProperties(); recurrenceProperties1.RecurrenceType = RecurrenceType.Weekly; recurrenceProperties1.RecurrenceRange = RecurrenceRange.Count; recurrenceProperties1.Interval = 1; recurrenceProperties1.WeekDays = WeekDays.Monday; recurrenceProperties1.RecurrenceCount = 10; scheduleAppointment1.RecurrenceRule = ScheduleHelper.RRuleGenerator(recurrenceProperties1, scheduleAppointment1.StartTime, scheduleAppointment1.EndTime); appointmentCollection.Add(scheduleAppointment1); }
public RecurrenceAppointment() { ApplicationLanguages.PrimaryLanguageOverride = "en-US"; this.InitializeComponent(); DateTime today = DateTime.Now; DateTime currentdate = today.AddDays(-7); ScheduleAppointmentCollection AppointmentCollection = new ScheduleAppointmentCollection(); // Daily Recursive Appointment ScheduleAppointment SchApp = new ScheduleAppointment(); SchApp.Subject = "Team Meeting"; SchApp.Notes = "Daily Recurrence"; SchApp.Location = "Meeting Hall 1"; SchApp.StartTime = currentdate; SchApp.EndTime = currentdate.AddHours(4); SchApp.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0xD8, 0x00, 0x73))); // Setting Recurrence Properties RecurrenceProperties RecurrenceProperty = new RecurrenceProperties(); RecurrenceProperty.RecurrenceType = RecurrenceType.Daily; RecurrenceProperty.IsDailyEveryNDays = false; //RecProp.DailyNDays = 2; RecurrenceProperty.IsRangeRecurrenceCount = true; RecurrenceProperty.IsRangeNoEndDate = false; RecurrenceProperty.IsRangeEndDate = false; RecurrenceProperty.RangeRecurrenceCount = 100; // Generating RRule using ScheduleHelper SchApp.RecurrenceRule = ScheduleHelper.RRuleGenerator(RecurrenceProperty, SchApp.StartTime, SchApp.EndTime); SchApp.IsRecursive = true; AppointmentCollection.Add(SchApp); Schedule.Appointments = AppointmentCollection; // Weekly Recursive Appointment ScheduleAppointment SchAppointmentWeek = new ScheduleAppointment(); SchAppointmentWeek.Subject = "Doctor Appointment"; SchAppointmentWeek.Notes = "Weekly Recurrence"; SchAppointmentWeek.Location = "Global Hospital"; SchAppointmentWeek.StartTime = currentdate; SchAppointmentWeek.EndTime = currentdate.AddHours(4); SchAppointmentWeek.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0xA2, 0xC1, 0x39))); // Setting Recurrence Properties RecurrenceProperties RecurrencePropertyWeek = new RecurrenceProperties(); RecurrencePropertyWeek.RecurrenceType = RecurrenceType.Weekly; RecurrencePropertyWeek.WeeklyEveryNWeeks = 1; RecurrencePropertyWeek.IsWeeklySunday = true; RecurrencePropertyWeek.IsRangeRecurrenceCount = true; RecurrencePropertyWeek.IsRangeNoEndDate = false; RecurrencePropertyWeek.IsRangeEndDate = false; RecurrencePropertyWeek.RangeRecurrenceCount = 20; // Generating RRule using ScheduleHelper SchAppointmentWeek.RecurrenceRule = ScheduleHelper.RRuleGenerator(RecurrencePropertyWeek, SchAppointmentWeek.StartTime, SchAppointmentWeek.EndTime); SchAppointmentWeek.IsRecursive = true; AppointmentCollection.Add(SchAppointmentWeek); // Yearly Recursive Appointment ScheduleAppointment SchAppointmentYear = new ScheduleAppointment(); SchAppointmentYear.Subject = "Wedding Anniversary"; SchAppointmentYear.Notes = "Yearly Recurrence"; SchAppointmentYear.Location = "Home"; SchAppointmentYear.StartTime = currentdate; SchAppointmentYear.EndTime = currentdate.AddHours(4); SchAppointmentYear.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0x00, 0xAB, 0xA9))); // Setting Recurrence Properties using RRule SchAppointmentYear.RecurrenceRule = "FREQ=YEARLY;COUNT=3;BYMONTHDAY=" + (DateTime.Now.Day).ToString() + ";BYMONTH=" + (DateTime.Now.Month).ToString() + ""; SchAppointmentYear.IsRecursive = true; AppointmentCollection.Add(SchAppointmentYear); }
private ScheduleAppointmentCollection GenerateRandomAppointments() { DateTime today = DateTime.Now; if (today.Month == 12) { today = today.AddMonths(-1); } else if (today.Month == 1) { today = today.AddMonths(1); } DateTime currentdate = new DateTime(today.Year, today.Month - 1, 1, 0, 0, 0); var Appointments = new ScheduleAppointmentCollection(); var exceptionDate = new ObservableCollection <DateTime>(); //DAILY RECURSIVE APPOINTMENTS ScheduleAppointment SchApp = new ScheduleAppointment(); SchApp.Subject = "Team Meeting"; SchApp.Notes = "Daily Recurrence"; SchApp.Location = "Meeting Hall 1"; SchApp.StartTime = currentdate; SchApp.EndTime = currentdate.AddHours(4); SchApp.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0xD8, 0x00, 0x73))); //Avoid the recurrence appoinments for following specified dates for (int i = 0; i < 14; i++) { exceptionDate.Add(currentdate.AddMonths(1).AddDays(i + 15)); } SchApp.RecursiveExceptionDates = exceptionDate; // Setting Recurrence Properties RecurrenceProperties RecProp = new RecurrenceProperties(); RecProp.RecurrenceType = RecurrenceType.Weekly; RecProp.IsWeeklyTuesday = true; RecProp.IsWeeklyWednesday = true; RecProp.IsWeeklyThursday = true; RecProp.IsDailyEveryNDays = false; RecProp.IsRangeRecurrenceCount = true; RecProp.IsRangeNoEndDate = false; RecProp.IsRangeEndDate = false; RecProp.RangeRecurrenceCount = 50; // Generating RRule using ScheduleHelper SchApp.RecurrenceRule = ScheduleHelper.RRuleGenerator(RecProp, SchApp.StartTime, SchApp.EndTime); SchApp.IsRecursive = true; Appointments.Add(SchApp); //WEEKLY RECURSIVE APPOINTMENT ScheduleAppointment SchAppWeek = new ScheduleAppointment(); SchAppWeek.Subject = "Doctor Appointment"; SchAppWeek.Notes = "Weekly Recurrence"; SchAppWeek.Location = "Global Hospital"; SchAppWeek.StartTime = currentdate; SchAppWeek.EndTime = currentdate.AddHours(4); SchAppWeek.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0xA2, 0xC1, 0x39))); //Setting RRule as per ICalc standard by generating from RecurrenceProperties. You can assign string directly also. RecurrenceProperties RecPropWeek = new RecurrenceProperties(); RecPropWeek.RecurrenceType = RecurrenceType.Weekly; RecPropWeek.WeeklyEveryNWeeks = 1; RecPropWeek.IsWeeklySunday = true; RecPropWeek.IsRangeRecurrenceCount = true; RecPropWeek.IsRangeNoEndDate = false; RecPropWeek.IsRangeEndDate = false; RecPropWeek.RangeRecurrenceCount = 20; SchAppWeek.RecurrenceRule = "FREQ=WEEKLY;COUNT=20;BYDAY=SU"; SchAppWeek.IsRecursive = true; Appointments.Add(SchAppWeek); //Montly Recursive Appointment var SchAppMonth = new ScheduleAppointment(); SchAppMonth.Subject = "Client Meeting"; SchAppMonth.Notes = "Monthly Recurrence"; SchAppMonth.Location = "Chennai"; SchAppMonth.StartTime = currentdate; SchAppMonth.EndTime = currentdate.AddHours(4); SchAppMonth.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0x33, 0x99, 0x33))); //Setting RRule as per ICalc standard. SchAppMonth.RecurrenceRule = "FREQ=MONTHLY;COUNT=5;BYDAY=6;BYSETPOS=3"; SchAppMonth.IsRecursive = true; Appointments.Add(SchAppMonth); // Yearly Recursive Appointment var SchAppYear = new ScheduleAppointment(); SchAppYear.Subject = "Wedding Anniversary"; SchAppYear.Notes = "Yearly Recurrence"; SchAppYear.Location = "Home"; SchAppYear.StartTime = currentdate.AddHours(9); SchAppYear.EndTime = currentdate.AddHours(12); SchAppYear.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0x00, 0xAB, 0xA9))); //Setting RRule as per ICalc standard. SchAppYear.RecurrenceRule = "FREQ=YEARLY;COUNT=3;BYMONTHDAY=" + (DateTime.Now.Day).ToString() + ";BYMONTH=" + (DateTime.Now.Month).ToString() + ""; SchAppYear.IsRecursive = true; Appointments.Add(SchAppYear); return(Appointments); }
public MainWindow() { this.InitializeComponent(); DateTime today = DateTime.Now; if (today.Month == 12) { today = today.AddMonths(-1); } else if (today.Month == 1) { today = today.AddMonths(1); } DateTime currentdate = new DateTime(today.Year, today.Month - 1, 1, 0, 0, 0); ScheduleAppointmentCollection AppointmentCollection = new ScheduleAppointmentCollection(); // Daily Recursive Appointment ScheduleAppointment SchApp = new ScheduleAppointment(); SchApp.Subject = "Team Meeting"; SchApp.Notes = "Daily Recurrence"; SchApp.Location = "Meeting Hall 1"; SchApp.StartTime = currentdate; SchApp.EndTime = currentdate.AddHours(4); SchApp.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0xD8, 0x00, 0x73))); // Setting Recurrence Properties RecurrenceProperties RecProp = new RecurrenceProperties(); RecProp.RecurrenceType = RecurrenceType.Daily; RecProp.IsDailyEveryNDays = true; RecProp.DailyNDays = 2; RecProp.IsRangeRecurrenceCount = true; RecProp.IsRangeNoEndDate = false; RecProp.IsRangeEndDate = false; RecProp.RangeRecurrenceCount = 50; // Generating RRule using ScheduleHelper SchApp.RecurrenceRule = ScheduleHelper.RRuleGenerator(RecProp, SchApp.StartTime, SchApp.EndTime); SchApp.IsRecursive = true; AppointmentCollection.Add(SchApp); Schedule.Appointments = AppointmentCollection; // Weekly Recursive Appointment ScheduleAppointment SchAppWeek = new ScheduleAppointment(); SchAppWeek.Subject = "Doctor Appointment"; SchAppWeek.Notes = "Weekly Recurrence"; SchAppWeek.Location = "Global Hospital"; SchAppWeek.StartTime = currentdate; SchAppWeek.EndTime = currentdate.AddHours(4); SchAppWeek.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0xA2, 0xC1, 0x39))); // Setting Recurrence Properties RecurrenceProperties RecPropWeek = new RecurrenceProperties(); RecPropWeek.RecurrenceType = RecurrenceType.Weekly; RecPropWeek.WeeklyEveryNWeeks = 1; RecPropWeek.IsWeeklySunday = true; RecPropWeek.IsRangeRecurrenceCount = true; RecPropWeek.IsRangeNoEndDate = false; RecPropWeek.IsRangeEndDate = false; RecPropWeek.RangeRecurrenceCount = 20; // Generating RRule using ScheduleHelper SchAppWeek.RecurrenceRule = ScheduleHelper.RRuleGenerator(RecPropWeek, SchAppWeek.StartTime, SchAppWeek.EndTime); SchAppWeek.IsRecursive = true; AppointmentCollection.Add(SchAppWeek); // Montly Recursive Appointment ScheduleAppointment SchAppMonth = new ScheduleAppointment(); SchAppMonth.Subject = "Client Meeting"; SchAppMonth.Notes = "Monthly Recurrence"; SchAppMonth.Location = "Chennai"; SchAppMonth.StartTime = currentdate; SchAppMonth.EndTime = currentdate.AddHours(4); SchAppMonth.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0x33, 0x99, 0x33))); // Setting Recurrence Properties using RRule SchAppMonth.RecurrenceRule = "FREQ=MONTHLY;COUNT=5;BYDAY=6;BYSETPOS=3"; SchAppMonth.IsRecursive = true; AppointmentCollection.Add(SchAppMonth); // Yearly Recursive Appointment ScheduleAppointment SchAppYear = new ScheduleAppointment(); SchAppYear.Subject = "Wedding Anniversary"; SchAppYear.Notes = "Yearly Recurrence"; SchAppYear.Location = "Home"; SchAppYear.StartTime = currentdate; SchAppYear.EndTime = currentdate.AddHours(4); SchAppYear.AppointmentBackground = new SolidColorBrush((Color.FromArgb(0xFF, 0x00, 0xAB, 0xA9))); // Setting Recurrence Properties using RRule SchAppYear.RecurrenceRule = "FREQ=YEARLY;COUNT=3;BYMONTHDAY=" + (DateTime.Now.Day).ToString() + ";BYMONTH=" + (DateTime.Now.Month).ToString() + ""; SchAppYear.IsRecursive = true; AppointmentCollection.Add(SchAppYear); }
//Creating appointments for ScheduleAppointmentCollection public void getAppointments() { appointmentCollection = new ScheduleAppointmentCollection(); //Recurrence Appointment 1 ScheduleAppointment appointment1 = new ScheduleAppointment(); Calendar currentDate = Calendar.Instance; Calendar startTime = (Calendar)currentDate.Clone(); Calendar endTime = (Calendar)currentDate.Clone(); startTime.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 4, 0, 0 ); endTime.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 6, 0, 0 ); appointment1.StartTime = startTime; appointment1.EndTime = endTime; appointment1.Color = Color.ParseColor("#FF1BA1E2"); appointment1.Subject = "Occurs once in every two days"; appointment1.IsRecursive = true; RecurrenceProperties recurrenceProp1 = new RecurrenceProperties(); recurrenceProp1.RecurrenceType = RecurrenceType.Daily; recurrenceProp1.IsDailyEveryNDays = true; recurrenceProp1.DailyNDays = 2; recurrenceProp1.IsRangeRecurrenceCount = true; recurrenceProp1.IsRangeNoEndDate = false; recurrenceProp1.IsRangeEndDate = false; recurrenceProp1.RangeRecurrenceCount = 10; recurrenceProp1.RecurrenceRule = ScheduleHelper.RRuleGenerator(recurrenceProp1, appointment1.StartTime, appointment1.EndTime); appointment1.RecurrenceRule = recurrenceProp1.RecurrenceRule; appointmentCollection.Add(appointment1); //Recurrence Appointment 2 ScheduleAppointment scheduleAppointment1 = new ScheduleAppointment(); Calendar currentDate1 = Calendar.Instance; Calendar startTime1 = (Calendar)currentDate1.Clone(); Calendar endTime1 = (Calendar)currentDate1.Clone(); startTime1.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 10, 0, 0 ); endTime1.Set( currentDate.Get(CalendarField.Year), currentDate.Get(CalendarField.Month), currentDate.Get(CalendarField.DayOfMonth), 12, 0, 0 ); scheduleAppointment1.StartTime = startTime1; scheduleAppointment1.EndTime = endTime1; scheduleAppointment1.Color = Color.ParseColor("#FFD80073"); scheduleAppointment1.Subject = "Occurs every Monday"; scheduleAppointment1.IsRecursive = true; RecurrenceProperties recurrenceProperties1 = new RecurrenceProperties(); recurrenceProperties1.RecurrenceType = RecurrenceType.Weekly; recurrenceProperties1.IsRangeRecurrenceCount = true; recurrenceProperties1.WeeklyEveryNWeeks = 1; recurrenceProperties1.IsWeeklySunday = false; recurrenceProperties1.IsWeeklyMonday = true; recurrenceProperties1.IsWeeklyTuesday = false; recurrenceProperties1.IsWeeklyWednesday = false; recurrenceProperties1.IsWeeklyThursday = false; recurrenceProperties1.IsWeeklyFriday = false; recurrenceProperties1.IsWeeklySaturday = false; recurrenceProperties1.RangeRecurrenceCount = 10; recurrenceProperties1.RecurrenceRule = ScheduleHelper.RRuleGenerator(recurrenceProperties1, scheduleAppointment1.StartTime, scheduleAppointment1.EndTime); scheduleAppointment1.RecurrenceRule = recurrenceProperties1.RecurrenceRule; appointmentCollection.Add(scheduleAppointment1); }