Пример #1
0
 public void EndPreviewOptions()
 {
     if (_optionsType == null)
     {
         return;
     }
     _optionsType = null;
     Invalidate();
 }
Пример #2
0
 public void PreviewOptions(Type type)
 {
     if (type == null)
     {
         return;
     }
     if (_optionsType == type)
     {
         return;
     }
     _optionsType = type;
     Invalidate();
 }
Пример #3
0
 private bool CheckDirectClash(Type a)
 {
     return(a.Required && _timetable.TypeList.Where(b => a != b).Where(b => b.Required).Any(a.ClashesWith));
 }
 private static Stream FindStream(Type type, TimeOfWeek time)
 {
     return(Timetable.From(type).FindClassAt(time, false).Stream);
 }
Пример #5
0
 public void BeginDrag(Type type)
 {
     PreviewOptions(type);
 }
        private void ParseSubjectStream(ref Timetable.Timetable timetable, SubjectStream subs, bool currentlyAllocated, int multipleAllocationIndex)
        {
            if (!ImportUnselectableStreams && !currentlyAllocated && subs.Selectable == "full")
            {
                return;
            }

            var endTime = subs.Date.AddMinutes(double.Parse(subs.Duration));
            int currentDay;

            switch (subs.DayOfWeek)
            {
            case "Sun":
                currentDay = 0;
                break;

            case "Mon":
                currentDay = 1;
                break;

            case "Tue":
                currentDay = 2;
                break;

            case "Wed":
                currentDay = 3;
                break;

            case "Thu":
                currentDay = 4;
                break;

            case "Fri":
                currentDay = 5;
                break;

            case "Sat":
                currentDay = 6;
                break;

            default:
                return;
            }

            var session = new Session(currentDay, subs.Date.DayOfYear, subs.Date.Hour,
                                      subs.Date.Minute, endTime.Hour, endTime.Minute, subs.Location, subs.WeekPattern);

            Subject subject;

            if (timetable.SubjectList.Exists(element => element.Name == subs.SubjectCode))
            {
                subject = timetable.SubjectList.Find(element => element.Name == subs.SubjectCode);
            }
            else
            {
                subject = new Subject(subs.SubjectCode);
                timetable.SubjectList.Add(subject);
            }

            // Set the session type
            Type type;

            if (multipleAllocationIndex == -1 && subject.Types.Exists(types => types.Code == subs.ActivityGroupCode))
            {
                type = subject.Types.Find(types => types.Code == subs.ActivityGroupCode);
            }
            else // The session type doesn't exist, create it.
            {
                var groupCode = subs.ActivityGroupCode;
                type = new Type(subs.ActivityType, groupCode, subject);
                switch (subs.ActivityGroupCode)
                {
                case "tes":
                    type.Required = false;
                    break;

                default:
                    type.Required = true;
                    break;
                }
                timetable.TypeList.Add(type);
            }

            // Set the session
            var streamNumber = subs.ActivityCode;

            Timetable.Stream stream;
            if (type.Streams.Exists(x => x.Number == streamNumber))
            {
                stream = type.Streams.Find(x => x.Number == streamNumber);
            }
            else
            {
                stream = new Timetable.Stream(streamNumber);
                timetable.StreamList.Add(stream); // Add it to the stream list
            }

            // Link the subject and type
            if (!subject.Types.Contains(type))
            {
                subject.Types.Add(type);
                type.Subject = subject;
            }

            // Link the stream and type.
            if (!type.Streams.Contains(stream))
            {
                type.Streams.Add(stream);
                stream.Type = type;
            }

            // Link the stream and class together.
            // Add it to our list of classes.
            timetable.ClassList.Add(session);
            stream.Classes.Add(session);
            session.Stream = stream;
        }