public bool DoesOverlap(TimeFrame time)
 {
     foreach (TimeFrame tf in Times)
     {
         if (time.DoesOverlap(tf)) return true;
     }
     return false;
 }
Beispiel #2
0
        // 1  1.5  2  2.5  3  3.5  4
        // |-----------|
        //           |------------|
        public bool DoesOverlap(TimeFrame otherTimeFrame)
        {
            if (_startTime.GetTickNumber() <= otherTimeFrame._startTime.GetTickNumber())
            {
                if (_endTime.GetTickNumber() >= otherTimeFrame._startTime.GetTickNumber())
                {
                    return true;
                }
            }

            if (_startTime.GetTickNumber() <= otherTimeFrame._endTime.GetTickNumber())
            {
                if (_endTime.GetTickNumber() >= otherTimeFrame._endTime.GetTickNumber())
                {
                    return true;
                }
            }

            if (otherTimeFrame._startTime.GetTickNumber() <= _startTime.GetTickNumber())
            {
                if (otherTimeFrame._endTime.GetTickNumber() >= _startTime.GetTickNumber())
                {
                    return true;
                }
            }

            if (otherTimeFrame._startTime.GetTickNumber() <= _endTime.GetTickNumber())
            {
                if (otherTimeFrame._endTime.GetTickNumber() >= _endTime.GetTickNumber())
                {
                    return true;
                }
            }

            return false;
        }
 TimeFrame EnterTimeFrame()
 {
     TimeFrame tf = new TimeFrame();
     Console.WriteLine("Enter Start Time");
     tf.StartTime = EnterWeekyTime();
     Console.WriteLine("Enter End Time");
     tf.EndTime = EnterWeekyTime(tf.StartTime.Day);
     return tf;
 }
        public void LoadXMLClassList(string filename)
        {
            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
            xdoc.Load(filename);
            System.Xml.XmlElement root = (System.Xml.XmlElement)xdoc.ChildNodes[1];

            foreach (System.Xml.XmlElement classNode in root.ChildNodes)
            {
                ScheduleClass sc = new ScheduleClass();
                sc.Title = classNode.Attributes["Title"].Value;
                sc.Subject = Int32.Parse(classNode.Attributes["Subject"].Value);
                sc.Sch = Int32.Parse(classNode.Attributes["Sch"].Value);
                sc.Index = Int32.Parse(classNode.Attributes["Index"].Value);
                sc.Credits = Int32.Parse(classNode.Attributes["Credits"].Value);

                foreach (System.Xml.XmlElement scheduleNode in classNode.ChildNodes)
                {
                    ClassSection cs = new ClassSection();
                    cs.parentClass = sc;
                    cs.Section = scheduleNode.Attributes["SectionCode"].Value;
                    cs.RegistrationIndex = scheduleNode.Attributes["RegistrationIndex"].Value;
                    foreach (System.Xml.XmlElement timeframeNode in scheduleNode.ChildNodes)
                    {
                        TimeFrame tf = new TimeFrame();
                        tf.StartTime = new WeeklyTime((DayOfWeek)Enum.Parse(typeof(DayOfWeek), timeframeNode.Attributes["startDay"].Value, true),
                            Int32.Parse(timeframeNode.Attributes["startHour"].Value), Int32.Parse(timeframeNode.Attributes["startMin"].Value));
                        tf.EndTime = new WeeklyTime((DayOfWeek)Enum.Parse(typeof(DayOfWeek), timeframeNode.Attributes["startDay"].Value, true),
                            Int32.Parse(timeframeNode.Attributes["endHour"].Value), Int32.Parse(timeframeNode.Attributes["endMin"].Value));
                        cs.Times.Add(tf);
                    }
                    sc.Sections.Add(cs);
                }
                classList.Add(sc);
            }
        }