Example #1
0
        /// <summary>
        /// Adds some random appointments for the given date.
        /// </summary>
        /// <param name="appointments"></param>
        /// <param name="date"></param>
        private void AddRandomAppointments(NAppointmentCollection appointments, DateTime date)
        {
            for (int i = 0; i < AppointmentsPerDay; i++)
            {
                // Generate random subject
                string subject = AppointmentSubjects[m_Random.Next(0, AppointmentSubjects.Length)];

                // Generate random start hour from 0 to 24
                double startHour = m_Random.NextDouble() * 24;

                // Generate random duration from 0.5 to 2.5 hours
                double duration = 0.5 + m_Random.NextDouble() * 2;

                // Create and add the appointment
                NAppointment appointment = new NAppointment(subject, date.AddHours(startHour),
                                                            date.AddHours(startHour + duration));
                appointments.Add(appointment);
            }
        }
Example #2
0
        protected override void InitSchedule(NSchedule schedule)
        {
            m_Random = new Random();

            int      totalDays = TotalAppointments / AppointmentsPerDay;
            DateTime date      = DateTime.Today.AddDays(-totalDays / 2);

            // Generate the random appointments
            NAppointmentCollection appointments = schedule.Appointments;

            for (int i = 0; i < totalDays; i++)
            {
                AddRandomAppointments(appointments, date);
                date = date.AddDays(1);
            }

            // Switch the schedule to week view
            schedule.ViewMode = ENScheduleViewMode.Week;
        }