Beispiel #1
0
        /// <summary>
        /// A static method that provides random data, not really a part of the implementations.
        /// </summary>
        /// <returns>A SimpleScheduleAppointmentList object holding sample data.</returns>
        public static SimpleScheduleAppointmentList InitializeRandomData()
        {
            //int tc = Environment.TickCount;
            //int tc = 26260100;// simple spread
            int tc = 28882701; // split the appointment across midnight & 3 items at 8am on 2 days ago

            //Console.WriteLine("Random seed: {0}", tc);
            Random r  = new Random(tc);
            Random r1 = new Random(tc);

            // set the number of sample items you want in this list.
            //int count = r.Next(20) + 4;
            int count = 400;//1000;//200;//30;

            SimpleScheduleAppointmentList masterList = new SimpleScheduleAppointmentList();
            DateTime now = DateTime.Now.Date;

            for (int i = 0; i < count; ++i)
            {
                ScheduleAppointment item = masterList.NewScheduleAppointment() as ScheduleAppointment;

                int dayOffSet = 30 - r.Next(60);

                int hourOffSet = 24 - r.Next(48);

                int len = 30 * (r.Next(4) + 1);
                item.StartTime     = now.AddDays((double)dayOffSet).AddHours((double)hourOffSet);;
                item.EndTime       = item.StartTime.AddMinutes((double)len);
                item.Subject       = string.Format("subject{0}", i);
                item.Content       = string.Format("content{0}", i);
                item.LabelValue    = r1.Next(10) < 3 ? 0 : r1.Next(10);
                item.LocationValue = string.Format("location{0}", r1.Next(5));

                item.ReminderValue = r1.Next(10) < 5 ? 0 : r1.Next(12);
                item.Reminder      = r1.Next(10) > 1;
                item.AllDay        = r1.Next(10) < 1;


                item.MarkerValue = r1.Next(4);
                item.Dirty       = false;
                masterList.Add(item);
            }

            ////set explicit values if needed for testing...
            //masterList[142].Reminder = true;
            //masterList[142].ReminderValue = 9;//  hrs; // 7;//3 hrs


            //DisplayList("Before Sort", masterList);
            masterList.SortStartTime();
            //DisplayList("After Sort", masterList);

            return(masterList);
        }