コード例 #1
0
        /// <summary>
        /// Constructs a new dynamic course object and links it to an existing dynamic course.
        /// </summary>
        /// <param name="name">The name of the course container.</param>
        /// <param name="linkedCourse">An existing dynamic course object to link to.</param>
        public DynamicCourse(string name, DynamicCourse linkedCourse)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (linkedCourse == null)
            {
                throw new ArgumentNullException("linkedCourse");
            }
            _name    = name;
            _courses = linkedCourse._courses;
            DynamicCourse head = linkedCourse;

            if (head._linkedHead != null)
            {
                // Course is already linked to another course
                // Get the actual root of the link chain
                head = head._linkedHead;
                if (head._linkedChildren.Count >= _courses.Length)
                {
                    throw new InvalidOperationException("More linked courses than course options");
                }
            }
            else
            {
                // Course is standalone
                // Let head know it's the root of a chain now
                head._linkedHead     = head;
                head._linkedChildren = new List <DynamicCourse>();
            }
            head._linkedChildren.Add(this);
            _linkedHead     = head;
            _selectedCourse = GetNextCourseChoice();
        }
コード例 #2
0
 public DynamicCourseNameControl(DynamicCourse course)
 {
     CheckBox enabledCheckBox = new CheckBox();
     _courseComboBox = new ComboBox();
     Controls.Add(_enabledCheckBox);
     Controls.Add(_courseComboBox);
     _course = course;
     _enabledCheckBox = enabledCheckBox;
 }
コード例 #3
0
ファイル: CourseLoader.cs プロジェクト: apsun/EzGPA
 private static DynamicCourse LoadMultiCourseWithLink(DynamicCourse linkedCourse, XElement courseElement)
 {
     // Make sure no attributes other than link and name are defined
     string courseName = XmlHelper.GetAttributeValue(courseElement, "name");
     if (courseElement.Attribute("scores") != null)
         throw XmlHelper.CreateException(courseElement, "Cannot define score for linked course");
     if (courseElement.Attribute("levels") != null)
         throw XmlHelper.CreateException(courseElement, "Cannot define levels for linked course");
     if (courseElement.Attribute("credits") != null)
         throw XmlHelper.CreateException(courseElement, "Cannot define credits for linked course");
     return new DynamicCourse(courseName, linkedCourse);
 }
コード例 #4
0
ファイル: DynamicCourse.cs プロジェクト: apsun/EzGPA
 /// <summary>
 /// Constructs a new dynamic course object and links it to an existing dynamic course.
 /// </summary>
 /// <param name="name">The name of the course container.</param>
 /// <param name="linkedCourse">An existing dynamic course object to link to.</param>
 public DynamicCourse(string name, DynamicCourse linkedCourse)
 {
     if (name == null)
         throw new ArgumentNullException("name");
     if (linkedCourse == null)
         throw new ArgumentNullException("linkedCourse");
     _name = name;
     _courses = linkedCourse._courses;
     DynamicCourse head = linkedCourse;
     if (head._linkedHead != null)
     {
         // Course is already linked to another course
         // Get the actual root of the link chain
         head = head._linkedHead;
         if (head._linkedChildren.Count >= _courses.Length)
             throw new InvalidOperationException("More linked courses than course options");
     }
     else
     {
         // Course is standalone
         // Let head know it's the root of a chain now
         head._linkedHead = head;
         head._linkedChildren = new List<DynamicCourse>();
     }
     head._linkedChildren.Add(this);
     _linkedHead = head;
     _selectedCourse = GetNextCourseChoice();
 }