Example #1
0
        /// <summary>
        /// 加载默认的工作计划表
        /// </summary>
        /// <param name="date">The start date.</param>
        /// <returns></returns>
        private static AppointmentList CreateDefualtAppointments(DateTime date)
        {
            List <Brush> brushes = new List <Brush>();

            brushes.Add(Brushes.LimeGreen);
            brushes.Add(Brushes.PowderBlue);
            brushes.Add(Brushes.DarkGreen);
            brushes.Add(Brushes.Green);
            brushes.Add(Brushes.DimGray);
            brushes.Add(Brushes.Red);
            brushes.Add(Brushes.Yellow);
            brushes.Add(Brushes.Aquamarine);
            brushes.Add(Brushes.Plum);
            brushes.Add(Brushes.Orange);
            brushes.Add(Brushes.Pink);



            //create 7am of last monday
            DateTime timeStart = new DateTime(date.Year, date.Month, date.Day, 8, 30, 0);
            //while (timeStart.DayOfWeek != DayOfWeek.Monday)
            //{
            //    timeStart = timeStart.AddDays(-1);
            //}

            AppointmentList appts = new AppointmentList();

            int hoursToAdd = 1;

            for (int i = 0; i < 12; i++)
            {
                BrakePlanAppointments app = new BrakePlanAppointments();

                app.Subject         = "无型号";
                app.ColorBlockBrush = Brushes.LimeGreen;
                app.DateStart       = timeStart.AddHours(i * hoursToAdd);
                app.DateEnd         = app.DateStart.AddMinutes(60);
                appts.Add(app);
            }


            appts.SortAppointments();

            return(appts);
        }
Example #2
0
        /// <summary>
        /// The appointment list or an appointment in it has changed,
        /// so we need to refresh everything from the underlying
        /// grid control to the boundaries of the appointments.
        /// </summary>
        public void RefreshAppointments()
        {
            //sort the appointments by date
            Appointments.SortAppointments();

//            if (appointments != null)
//            {
//                var sortedApps =
//                from a in appointments
//                orderby a.DateStart
//                select a;
//
//                appointments = sortedApps.ToList();
//                appointments.Clear();
//                foreach (var app in sortedApps.ToList())
//                  appointments.Add(app);
//            }
            //BoundsValidTimeSlot = false;
            BoundsValidAppointment     = false;
            AppointmentGrid.DataSource = Appointments as List <Appointment>;
            //RefreshAppointments();
        }