Exemple #1
0
        public List<ScheduleItem> GenerateSchedule(DateTime from, DateTime to)
        {
            Random rnd = new Random();

            List<ScheduleItem> result = new List<ScheduleItem>();

            for (DateTime day = from; day <= to; day = day.AddDays(1))
            {
                ScheduleItem scheduleItem = new ScheduleItem();
                scheduleItem.Day = day.Date;

                if (scheduleItem.Day.DayOfWeek != DayOfWeek.Saturday && scheduleItem.Day.DayOfWeek != DayOfWeek.Sunday)
                {
                    int startTime = rnd.Next(8, 11),
                    endTime = rnd.Next(17, 19);

                    for (int i = startTime; i < endTime; i++)
                    {
                        AppointmentItem appointment = new AppointmentItem();
                        appointment.Time = day.Date.AddHours(i);
                        appointment.Occupied = rnd.Next(0, 100) > 70;

                        scheduleItem.Appointments.Add(appointment);
                    }
                }

                result.Add(scheduleItem);

            }

            return result;
        }
Exemple #2
0
        private View InflateScheduleItem(Context context, ScheduleItem item)
        {
            View result = LayoutInflater.From (context).Inflate (Resource.Layout.DatesListView, null, false);
            TextView txtDate = result.FindViewById<TextView> (Resource.Id.txtDate),
            txtDayOfWeek = result.FindViewById<TextView> (Resource.Id.txtDayOfWeek);
            if (item.Day.DayOfWeek == DayOfWeek.Saturday || item.Day.DayOfWeek == DayOfWeek.Sunday) {
                txtDate.SetTextAppearance (this, Resource.Style.largeWeekendDate);
                txtDayOfWeek.SetTextAppearance (this, Resource.Style.smallWeekendDate);
            }
            txtDate.Text = item.Day.ToString ("dd");
            txtDayOfWeek.Text = item.Day.ToString ("ddd");

            return result;
        }