Example #1
0
        /// <summary>
        /// recursive appointments
        /// </summary>
        ////creating RecurrsiveAppointments
        private void CreateRecurrsiveExceptionAppointments()
        {
            this.RecursiveExceptionAppointmentCollection = new ObservableCollection <SchedulerModel>();

            DateTime currentDate = DateTime.Now.AddMonths(-1);

            SchedulerModel dailyEvent = new SchedulerModel
            {
                EventName      = "Daily scrum meeting",
                From           = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 10, 0, 0),
                To             = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 11, 0, 0),
                Color          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")),
                RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=50",
                Id             = 1
            };

            RecursiveExceptionAppointmentCollection.Add(dailyEvent);

            //Add ExceptionDates to avoid occurrence on specific dates.
            DateTime changedExceptionDate1 = DateTime.Now.AddDays(-1).Date;
            DateTime changedExceptionDate2 = DateTime.Now.Date.AddDays(4).Date;
            DateTime deletedExceptionDate1 = DateTime.Now.Date.AddDays(2);
            DateTime deletedExceptionDate2 = DateTime.Now.Date.AddDays(6);
            DateTime deletedExceptionDate3 = DateTime.Now.Date.AddDays(8);

            dailyEvent.RecurrenceExceptions = new ObservableCollection <DateTime>()
            {
                changedExceptionDate1,
                changedExceptionDate2,
                deletedExceptionDate1,
                deletedExceptionDate2,
            };

            //Change start time or end time of an occurrence.
            SchedulerModel changedEvent = new SchedulerModel
            {
                EventName      = "Scrum meeting - Changed Occurrence",
                From           = new DateTime(changedExceptionDate1.Year, changedExceptionDate1.Month, changedExceptionDate1.Day, 12, 0, 0),
                To             = new DateTime(changedExceptionDate1.Year, changedExceptionDate1.Month, changedExceptionDate1.Day, 13, 0, 0),
                Color          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")),
                RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10",
                Id             = 2,
                RecurrenceId   = 1
            };

            RecursiveExceptionAppointmentCollection.Add(changedEvent);

            SchedulerModel changedEvent1 = new SchedulerModel
            {
                EventName    = "Scrum meeting - Changed Occurrence",
                From         = new DateTime(changedExceptionDate2.Year, changedExceptionDate2.Month, changedExceptionDate2.Day, 12, 0, 0),
                To           = new DateTime(changedExceptionDate2.Year, changedExceptionDate2.Month, changedExceptionDate2.Day, 13, 0, 0),
                Color        = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")),
                Id           = 3,
                RecurrenceId = 1
            };

            RecursiveExceptionAppointmentCollection.Add(changedEvent1);
        }
Example #2
0
        /// <summary>
        /// recursive appointments
        /// </summary>
        ////creating RecurrsiveAppointments
        private void CreateRecurrsiveAppointments()
        {
            this.RecursiveAppointmentCollection = new ObservableCollection <SchedulerModel>();

            DateTime currentDate = DateTime.Now.AddMonths(-1);

            SchedulerModel dailyEvent = new SchedulerModel
            {
                EventName            = "Daily recurring meeting",
                From                 = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 9, 0, 0),
                To                   = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 10, 0, 0),
                Color                = new SolidColorBrush((Color.FromRgb(191, 235, 97))),
                ForegroundColor      = new SolidColorBrush(Color.FromRgb(51, 51, 51)),
                RecurrenceRule       = "FREQ=DAILY;INTERVAL=1;COUNT=100",
                RecurrenceExceptions = new ObservableCollection <DateTime>()
            };

            RecursiveAppointmentCollection.Add(dailyEvent);

            SchedulerModel weeklyEvent = new SchedulerModel
            {
                EventName            = "Weekly recurring meeting",
                From                 = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 11, 0, 0),
                To                   = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 12, 0, 0),
                Color                = new SolidColorBrush((Color.FromRgb(45, 216, 175))),
                ForegroundColor      = new SolidColorBrush(Color.FromRgb(51, 51, 51)),
                RecurrenceRule       = "FREQ=WEEKLY;BYDAY=MO,WE,FR;INTERVAL=1;COUNT=20",
                RecurrenceExceptions = new ObservableCollection <DateTime>()
            };

            RecursiveAppointmentCollection.Add(weeklyEvent);

            SchedulerModel monthlyEvent = new SchedulerModel
            {
                EventName            = "Monthly recurring Meeting",
                From                 = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 12, 0, 0),
                To                   = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 13, 0, 0),
                Color                = Brushes.Red,
                RecurrenceRule       = "FREQ=MONTHLY;BYDAY=TU;BYSETPOS=1;INTERVAL=1;COUNT=50",
                RecurrenceExceptions = new ObservableCollection <DateTime>()
            };

            RecursiveAppointmentCollection.Add(monthlyEvent);

            SchedulerModel yearlyEvent = new SchedulerModel
            {
                EventName            = "Yearly recurring Meeting",
                From                 = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 2, 0, 0),
                To                   = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 3, 0, 0),
                Color                = Brushes.Yellow,
                RecurrenceRule       = "FREQ=YEARLY;BYMONTHDAY=3;BYMONTH=5;INTERVAL=1;COUNT=50",
                RecurrenceExceptions = new ObservableCollection <DateTime>()
            };

            RecursiveAppointmentCollection.Add(yearlyEvent);
        }
Example #3
0
        /// <summary>
        /// Method for booking appointments.
        /// </summary>
        private void BookingResourceAppointments()
        {
            Random       randomTime           = new Random();
            List <Point> randomTimeCollection = this.GettingTimeRanges();

            ResourceAppointments = new ObservableCollection <SchedulerModel>();
            DateTime date;
            DateTime dateFrom       = DateTime.Now.AddDays(-80);
            DateTime dateTo         = DateTime.Now.AddDays(80);
            DateTime dateRangeStart = DateTime.Now.AddDays(-70);
            DateTime dateRangeEnd   = DateTime.Now.AddDays(70);

            for (date = dateFrom; date < dateTo; date = date.AddDays(1))
            {
                if ((DateTime.Compare(date, dateRangeStart) > 0) && (DateTime.Compare(date, dateRangeEnd) < 0))
                {
                    for (int additionalAppointmentIndex = 0; additionalAppointmentIndex < 8; additionalAppointmentIndex++)
                    {
                        SchedulerModel meeting = new SchedulerModel();
                        meeting.From      = new DateTime(date.Year, date.Month, date.Day, randomTime.Next(0, 23), 0, 0);
                        meeting.To        = meeting.From.AddHours(randomTime.Next(1, 3));
                        meeting.EventName = this.currentDayMeetings[randomTime.Next(9)];
                        meeting.Color     = this.colorCollection[randomTime.Next(8)];
                        meeting.IsAllDay  = false;

                        var coll = new ObservableCollection <object>
                        {
                            (resources[randomTime.Next(Resources.Count)] as Employee).ID
                        };
                        meeting.Resources = coll;

                        this.ResourceAppointments.Add(meeting);
                    }
                }
                else
                {
                    SchedulerModel meeting = new SchedulerModel();
                    meeting.From      = new DateTime(date.Year, date.Month, date.Day, randomTime.Next(0, 23), 0, 0);
                    meeting.To        = meeting.From.AddDays(2).AddHours(1);
                    meeting.EventName = this.currentDayMeetings[randomTime.Next(9)];
                    meeting.Color     = this.colorCollection[randomTime.Next(8)];
                    meeting.IsAllDay  = true;
                    var coll = new ObservableCollection <object>
                    {
                        (resources[randomTime.Next(Resources.Count)] as Employee).ID
                    };
                    meeting.Resources = coll;
                    this.ResourceAppointments.Add(meeting);
                }
            }
        }
        /// <summary>
        /// Method to generate scheduler appointments based on current visible date range.
        /// </summary>
        /// <param name="dateRange">Current visible date range.</param>
        private IEnumerable GenerateSchedulerAppointments(DateRange dateRange)
        {
            var brush = new ObservableCollection <SolidColorBrush>();

            brush.Add(new SolidColorBrush(Color.FromRgb(133, 81, 242)));
            brush.Add(new SolidColorBrush(Color.FromRgb(140, 245, 219)));
            brush.Add(new SolidColorBrush(Color.FromRgb(83, 99, 250)));
            brush.Add(new SolidColorBrush(Color.FromRgb(255, 222, 133)));
            brush.Add(new SolidColorBrush(Color.FromRgb(45, 153, 255)));
            brush.Add(new SolidColorBrush(Color.FromRgb(253, 183, 165)));
            brush.Add(new SolidColorBrush(Color.FromRgb(198, 237, 115)));
            brush.Add(new SolidColorBrush(Color.FromRgb(253, 185, 222)));
            brush.Add(new SolidColorBrush(Color.FromRgb(83, 99, 250)));

            var subjectCollection = new ObservableCollection <string>();

            subjectCollection.Add("Business Meeting");
            subjectCollection.Add("Conference");
            subjectCollection.Add("Medical check up");
            subjectCollection.Add("Performance Check");
            subjectCollection.Add("Consulting");
            subjectCollection.Add("Project Status Discussion");
            subjectCollection.Add("Client Meeting");
            subjectCollection.Add("General Meeting");
            subjectCollection.Add("Yoga Therapy");
            subjectCollection.Add("GoToMeeting");
            subjectCollection.Add("Plan Execution");
            subjectCollection.Add("Project Plan");

            Random ran          = new Random();
            int    daysCount    = (dateRange.ActualEndDate - dateRange.ActualStartDate).Days;
            var    appointments = new ObservableCollection <SchedulerModel>();

            for (int i = 0; i < 50; i++)
            {
                var            startTime = dateRange.ActualStartDate.AddDays(ran.Next(0, daysCount + 1)).AddHours(ran.Next(0, 24));
                SchedulerModel meeting   = new SchedulerModel();
                meeting.From            = startTime;
                meeting.To              = startTime.AddHours(1);
                meeting.EventName       = subjectCollection[ran.Next(0, subjectCollection.Count)];
                meeting.Color           = brush[ran.Next(0, brush.Count)];
                meeting.ForegroundColor = GetAppointmentForeground(meeting.Color);

                appointments.Add(meeting);
            }

            return(appointments);
        }
Example #5
0
        private void CustomizationAppointments()
        {
            CustomizeAppointments = new ObservableCollection <SchedulerModel>();
            var random = new Random();

            this.eventCollection = new List <string>();
            this.eventCollection.Add("Conference");
            this.eventCollection.Add("System Troubleshoot");
            this.eventCollection.Add("Birthday");
            this.eventCollection.Add("Checkup");
            this.eventCollection.Add("Conference");

            for (int i = 0; i < 50; i++)
            {
                var year     = DateTime.Now.Date.Year;
                var month    = DateTime.Now.Date.AddMonths(random.Next(-1, 2)).Month;
                var day      = random.Next(1, 30);
                var hour     = random.Next(9, 14);
                var newEvent = new SchedulerModel();
                newEvent.EventName = this.eventCollection[random.Next(0, 4)];
                newEvent.From      = new DateTime(year, month, day, hour, 0, 0);
                newEvent.To        = newEvent.From.AddHours(1);
                if (newEvent.EventName == "Conference")
                {
                    newEvent.Color = this.colorCollection[0];
                }
                else if (newEvent.EventName == "System Troubleshoot")
                {
                    newEvent.Color = this.colorCollection[1];
                }
                else if (newEvent.EventName == "Birthday")
                {
                    newEvent.Color = this.colorCollection[2];
                }
                else if (newEvent.EventName == "Checkup")
                {
                    newEvent.Color = this.colorCollection[3];
                }
                this.CustomizeAppointments.Add(newEvent);
            }
        }
Example #6
0
        /// <summary>
        /// Method to create appointments for special time region sample.
        /// </summary>
        private void CreateSpecialTimeRegionAppointments()
        {
            Random     randomTime           = new Random();
            List <int> randomTimeCollection = new List <int>()
            {
                9, 11, 12, 14, 15, 16, 17, 18
            };

            this.SpecialTimeRegionAppointments = new ObservableCollection <SchedulerModel>();
            DateTime date;
            DateTime dateFrom       = DateTime.Now.AddDays(-100);
            DateTime dateTo         = DateTime.Now.AddDays(100);
            var      random         = new Random();
            var      dateCount      = random.Next(4);
            DateTime dateRangeStart = DateTime.Now.AddDays(0);
            DateTime dateRangeEnd   = DateTime.Now.AddDays(1);

            for (date = dateFrom; date < dateTo; date = date.AddDays(1))
            {
                if (date.Day % 7 != 0)
                {
                    // Normal meetings.
                    for (int additionalAppointmentIndex = 0; additionalAppointmentIndex < 1; additionalAppointmentIndex++)
                    {
                        SchedulerModel meeting = new SchedulerModel();
                        int            hour    = randomTimeCollection[randomTime.Next(0, 7)];
                        meeting.From            = new DateTime(date.Year, date.Month, date.Day, hour, 0, 0);
                        meeting.To              = meeting.From.AddHours(1);
                        meeting.EventName       = this.currentDayMeetings[randomTime.Next(9)];
                        meeting.Color           = this.colorCollection[randomTime.Next(9)];
                        meeting.ForegroundColor = GetAppointmentForeground(meeting.Color);
                        meeting.IsAllDay        = false;
                        meeting.Notes           = this.notesCollection[randomTime.Next(9)];
                        meeting.StartTimeZone   = string.Empty;
                        meeting.EndTimeZone     = string.Empty;
                        this.SpecialTimeRegionAppointments.Add(meeting);
                    }
                }
                else
                {
                    // All day meetings.
                    SchedulerModel meeting = new SchedulerModel();
                    meeting.From            = new DateTime(date.Year, date.Month, date.Day, randomTime.Next(14, 17), 0, 0);
                    meeting.To              = meeting.From.AddDays(2).AddHours(1);
                    meeting.EventName       = this.currentDayMeetings[randomTime.Next(9)];
                    meeting.Color           = this.colorCollection[randomTime.Next(9)];
                    meeting.ForegroundColor = GetAppointmentForeground(meeting.Color);
                    meeting.IsAllDay        = true;
                    meeting.Notes           = this.notesCollection[randomTime.Next(9)];
                    meeting.StartTimeZone   = string.Empty;
                    meeting.EndTimeZone     = string.Empty;
                    this.SpecialTimeRegionAppointments.Add(meeting);
                }
            }

            // Minimum Height Meetings.
            DateTime minDate;
            DateTime minDateFrom = DateTime.Now.AddDays(-2);
            DateTime minDateTo   = DateTime.Now.AddDays(2);

            for (minDate = minDateFrom; minDate < minDateTo; minDate = minDate.AddDays(1))
            {
                SchedulerModel meeting = new SchedulerModel();
                meeting.From            = new DateTime(minDate.Year, minDate.Month, minDate.Day, randomTimeCollection[randomTime.Next(0, 7)], 30, 0);
                meeting.To              = meeting.From;
                meeting.EventName       = this.minTimeMeetings[randomTime.Next(0, 4)];
                meeting.Color           = this.colorCollection[randomTime.Next(9)];
                meeting.ForegroundColor = GetAppointmentForeground(meeting.Color);
                meeting.Notes           = this.noteCollection[randomTime.Next(0, 4)];
                meeting.StartTimeZone   = string.Empty;
                meeting.EndTimeZone     = string.Empty;

                this.SpecialTimeRegionAppointments.Add(meeting);
            }
        }
Example #7
0
        /// <summary>
        /// Initialize appointments
        /// </summary>
        /// <param name="count">count value</param>
        private void IntializeAppoitments()
        {
            Random       randomTime           = new Random();
            List <Point> randomTimeCollection = this.GettingTimeRanges();

            DateTime date;
            DateTime dateFrom       = DateTime.Now.AddDays(-100);
            DateTime dateTo         = DateTime.Now.AddDays(100);
            var      random         = new Random();
            var      dateCount      = random.Next(4);
            DateTime dateRangeStart = DateTime.Now.AddDays(0);
            DateTime dateRangeEnd   = DateTime.Now.AddDays(1);

            for (date = dateFrom; date < dateTo; date = date.AddDays(1))
            {
                if (date.Day % 7 != 0)
                {
                    for (int additionalAppointmentIndex = 0; additionalAppointmentIndex < 1; additionalAppointmentIndex++)
                    {
                        SchedulerModel meeting = new SchedulerModel();
                        int            hour    = randomTime.Next((int)randomTimeCollection[additionalAppointmentIndex].X, (int)randomTimeCollection[additionalAppointmentIndex].Y);
                        meeting.From            = new DateTime(date.Year, date.Month, date.Day, hour, 0, 0);
                        meeting.To              = meeting.From.AddHours(1);
                        meeting.EventName       = this.currentDayMeetings[randomTime.Next(9)];
                        meeting.Color           = this.colorCollection[randomTime.Next(9)];
                        meeting.ForegroundColor = GetAppointmentForeground(meeting.Color);
                        meeting.IsAllDay        = false;
                        meeting.Notes           = this.notesCollection[randomTime.Next(9)];
                        meeting.StartTimeZone   = string.Empty;
                        meeting.EndTimeZone     = string.Empty;
                        this.Appointments.Add(meeting);
                    }
                }
                else
                {
                    SchedulerModel meeting = new SchedulerModel();
                    meeting.From            = new DateTime(date.Year, date.Month, date.Day, randomTime.Next(9, 11), 0, 0);
                    meeting.To              = meeting.From.AddDays(2).AddHours(1);
                    meeting.EventName       = this.currentDayMeetings[randomTime.Next(9)];
                    meeting.Color           = this.colorCollection[randomTime.Next(9)];
                    meeting.ForegroundColor = GetAppointmentForeground(meeting.Color);
                    meeting.IsAllDay        = true;
                    meeting.Notes           = this.notesCollection[randomTime.Next(9)];
                    meeting.StartTimeZone   = string.Empty;
                    meeting.EndTimeZone     = string.Empty;
                    this.Appointments.Add(meeting);
                }
            }

            // Minimum Height Meetings
            DateTime minDate;
            DateTime minDateFrom = DateTime.Now.AddDays(-2);
            DateTime minDateTo   = DateTime.Now.AddDays(2);

            for (minDate = minDateFrom; minDate < minDateTo; minDate = minDate.AddDays(1))
            {
                SchedulerModel meeting = new SchedulerModel();
                meeting.From            = new DateTime(minDate.Year, minDate.Month, minDate.Day, randomTime.Next(9, 18), 30, 0);
                meeting.To              = meeting.From;
                meeting.EventName       = this.minTimeMeetings[randomTime.Next(0, 4)];
                meeting.Color           = this.colorCollection[randomTime.Next(9)];
                meeting.ForegroundColor = GetAppointmentForeground(meeting.Color);
                meeting.Notes           = this.noteCollection[randomTime.Next(0, 4)];
                meeting.StartTimeZone   = string.Empty;
                meeting.EndTimeZone     = string.Empty;

                this.Appointments.Add(meeting);
            }
        }
        private void OnSchedulerViewChanged(object sender, ViewChangedEventArgs e)
        {
            if (e.NewValue != null)
            {
                var startDate = e.NewValue.StartDate;
                var random    = new Random();
                appointments = new ObservableCollection <SchedulerModel>();
                if (this.AssociatedObject.ViewType == SchedulerViewType.Week || this.AssociatedObject.ViewType == SchedulerViewType.WorkWeek)
                {
                    List <DateTime> visibleDates = new List <DateTime>();

                    List <string> eventCollection = new List <string>()
                    {
                        "Environmental Discussion", "Health Checkup", "Cancer awareness", "Happiness", "Tourism"
                    };

                    List <string> notesCollection = new List <string>()
                    {
                        "A day that creates awareness to promote the healthy planet and reduce the air pollution crisis on nature earth.",
                        "A day that raises awareness on different healthy issue. It marks the anniversary of the foundation of WHO.",
                        "A day that raises awareness on cancer and its preventive measures. Early detection saves life.",
                        "A general idea is to promote happiness and smile around the world.",
                        "A day that raises awareness on the role of tourism and its effect on social and economic values."
                    };

                    List <Brush> colorCollection = new List <Brush>()
                    {
                        new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF56AB56")),
                        new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF357CD2")),
                        new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF7FA90E")),
                        new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff8c00")),
                        new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF5BBEAF"))
                    };

                    for (DateTime date = startDate; date <= e.NewValue.EndDate; date = date.AddDays(1))
                    {
                        visibleDates.Add(date.Date);
                    }
                    if (!visibleDates.Contains(DateTime.Now.Date))
                    {
                        this.AssociatedObject.ItemsSource = appointments;
                    }
                    else
                    {
                        startDate = startDate.AddDays(1);
                        for (int i = 0; i < 5; i++)
                        {
                            SchedulerModel schedulerModel = new SchedulerModel();
                            schedulerModel.Color     = colorCollection[i];
                            schedulerModel.From      = startDate.AddDays(i).AddHours(10);
                            schedulerModel.To        = startDate.AddDays(i).AddHours(16);
                            schedulerModel.EventName = eventCollection[i];
                            schedulerModel.TimeValue = "Time: " + schedulerModel.From.ToShortTimeString() + " - " + schedulerModel.To.ToShortTimeString();
                            schedulerModel.Notes     = notesCollection[i];
                            appointments.Add(schedulerModel);
                        }
                        this.AssociatedObject.ItemsSource = appointments;
                    }
                }

                else
                {
                    List <Brush> colorCollection = new List <Brush>()
                    {
                        Brushes.Red, Brushes.Green, Brushes.DarkOrange, Brushes.DarkMagenta, Brushes.DarkSeaGreen, Brushes.Brown, Brushes.Chocolate, Brushes.DarkOrange, Brushes.DeepSkyBlue, Brushes.Purple
                    };

                    List <string> currentDayMeetings = new List <string>()
                    {
                        "General Meeting", "Scrum", "Project Plan", "Consulting", "Support", "Yoga Therapy", "Plan Execution", "Project Plan", "Consulting", "Performance Check"
                    };

                    for (DateTime date = startDate; date <= e.NewValue.EndDate; date = date.AddDays(1))
                    {
                        SchedulerModel schedulerModel = new SchedulerModel();
                        schedulerModel.Color     = colorCollection[random.Next(0, 9)];
                        schedulerModel.From      = date.AddHours(random.Next(9, 13));
                        schedulerModel.To        = schedulerModel.From.AddHours(4);
                        schedulerModel.EventName = currentDayMeetings[random.Next(0, 9)];
                        schedulerModel.TimeValue = schedulerModel.From.ToShortTimeString();
                        appointments.Add(schedulerModel);
                    }

                    for (DateTime date = startDate; date <= e.NewValue.EndDate; date = date.AddDays(2))
                    {
                        SchedulerModel schedulerModel = new SchedulerModel();
                        schedulerModel.Color     = colorCollection[random.Next(0, 9)];
                        schedulerModel.From      = date.AddHours(random.Next(13, 16));
                        schedulerModel.To        = schedulerModel.From.AddHours(4);
                        schedulerModel.EventName = currentDayMeetings[random.Next(0, 9)];
                        schedulerModel.TimeValue = schedulerModel.From.ToShortTimeString();
                        appointments.Add(schedulerModel);
                    }
                    this.AssociatedObject.ItemsSource = appointments;
                }
            }
        }