示例#1
0
        public void DisplayAllCourseViews()
        {
            UndoMgr  undomgr  = new UndoMgr(5);
            EventDB  eventDB  = new EventDB(undomgr);
            SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));

            eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe"));
            eventDB.Validate();

            foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB))
            {
                CourseDesignator designator;
                if (QueryEvent.HasVariations(eventDB, courseId))
                {
                    var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
                    designator = new CourseDesignator(courseId, variationInfo);
                }
                else
                {
                    designator = new CourseDesignator(courseId);
                }

                CourseView courseView = CourseView.CreateViewingCourseView(eventDB, designator);
                DumpCourseView(courseView, Console.Out);
                Console.WriteLine();
            }
        }
示例#2
0
        private void courseTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            bool             courseHasVariations = false;
            CourseDesignator courseDesignator    = courseTreeView.SelectedNode.Tag as CourseDesignator;

            if (courseDesignator != null && courseDesignator.IsNotAllControls)
            {
                courseHasVariations = QueryEvent.HasVariations(eventDB, courseDesignator.CourseId);
            }

            buttonChooseVariations.Enabled = courseHasVariations;
        }
示例#3
0
        // Update the names of all course views, and get the active course view, based on the active course id.
        void UpdateCourseViews()
        {
            List<KeyValuePair<Id<Course>,string>> courseViewPairs = new List<KeyValuePair<Id<Course>,string>>(); // Holds the list of course views and names, for sorting. Does NOT include all controls.

            // Get all the pairs of course ids in sorted order.
            Id<Course>[] courseIds = QueryEvent.SortedCourseIds(eventDB);

            // Copy to the names and ids arrays, adding in All Controls as the first element.
            courseViewNames = new string[courseIds.Length + 1];
            courseViewIds = new Id<Course>[courseIds.Length + 1];
            courseViewNames[0] = MiscText.AllControls;
            courseViewIds[0] = Id<Course>.None;
            for (int i = 1; i < courseViewIds.Length; ++i) {
                courseViewNames[i] = eventDB.GetCourse(courseIds[i - 1]).name;
                courseViewIds[i] = courseIds[i-1];
            }

            // Figure out which course view is the active one. We have already validate that the active course id
            // is present.
            if (activeCourseDesignator.IsAllControls) {
                activeCourseViewIndex = 0;
                activeCourseView = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls);
            }
            else {
                for (int i = 1; i < courseViewIds.Length; ++i) {
                    if (courseViewIds[i] == activeCourseDesignator.CourseId) {
                        activeCourseViewIndex = i;
                        activeCourseView = CourseView.CreateViewingCourseView(eventDB, activeCourseDesignator);
                    }
                }
            }

            // Get/create the topology course view. Not supported (null) for score and all controls. Always shows
            // all variations for a course with variations.
            if (activeCourseView.Kind == CourseView.CourseViewKind.Normal) {
                if (QueryEvent.HasVariations(activeCourseView.EventDB, activeCourseView.BaseCourseId) || !activeCourseView.CourseDesignator.AllParts) {
                    topologyCourseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(activeCourseView.BaseCourseId));
                }
                else {
                    topologyCourseView = activeCourseView;
                }
            }
            else if (activeCourseView.Kind == CourseView.CourseViewKind.AllVariations) {
                topologyCourseView = activeCourseView;
            }
            else {
                topologyCourseView = null;
            }
        }
示例#4
0
 void WriteTeamAssignments()
 {
     foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB))
     {
         if (QueryEvent.HasVariations(eventDB, courseId))
         {
             Course course = eventDB.GetCourse(courseId);
             if (course.relaySettings.relayTeams > 0)
             {
                 RelayVariations relayVariations = new RelayVariations(eventDB, courseId, course.relaySettings);
                 WriteRelayVariations(courseId, relayVariations);
             }
         }
     }
 }
示例#5
0
        public CourseDesignator DesignatorFromCourseId(EventDB eventDB, Id <Course> courseId)
        {
            CourseDesignator designator;

            if (QueryEvent.HasVariations(eventDB, courseId))
            {
                var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
                designator = new CourseDesignator(courseId, variationInfo);
            }
            else
            {
                designator = new CourseDesignator(courseId);
            }
            return(designator);
        }
示例#6
0
 void WriteCourseVariations(Id <Course> courseId, string courseName, int courseNumber, string[] classNames, bool isScore)
 {
     if (QueryEvent.HasVariations(eventDB, courseId))
     {
         VariationInfo[] variations = QueryEvent.GetAllVariations(eventDB, courseId).ToArray();
         for (int variationNumber = 0; variationNumber < variations.Length; ++variationNumber)
         {
             WriteSingleCourseVariation(new CourseDesignator(courseId, variations[variationNumber]), courseName, courseNumber, classNames, isScore, variationNumber, variations[variationNumber]);
         }
     }
     else
     {
         // No variations.
         WriteSingleCourseVariation(new CourseDesignator(courseId), courseName, courseNumber, classNames, isScore, 0, null);
     }
 }
        public void DisplayAllCourses()
        {
            UndoMgr              undomgr  = new UndoMgr(5);
            EventDB              eventDB  = new EventDB(undomgr);
            SymbolDB             symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            CourseView           courseView;
            DescriptionFormatter descFormatter;

            DescriptionLine[] description;

            eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent1.coursescribe"));
            eventDB.Validate();

            foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB))
            {
                CourseDesignator designator;
                if (QueryEvent.HasVariations(eventDB, courseId))
                {
                    var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
                    designator = new CourseDesignator(courseId, variationInfo);
                }
                else
                {
                    designator = new CourseDesignator(courseId);
                }
                courseView    = CourseView.CreateViewingCourseView(eventDB, designator);
                descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);
                description   = descFormatter.CreateDescription(false);
                DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out);
                Console.WriteLine();
            }

            courseView    = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls);
            descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);
            description   = descFormatter.CreateDescription(false);
            DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out);
        }
示例#8
0
        // Check the validate of the selected course view/selected object and update accordingly.
        void UpdateSelection()
        {
            // Check the selection validity.
            if (!activeCourseDesignator.IsAllControls && !eventDB.IsCoursePresent(activeCourseDesignator.CourseId)) {
                // Active course was deleted. Switch to all controls.
                activeCourseDesignator = CourseDesignator.AllControls;
                ClearSelection();
            }

            // Check that variation still exists.
            if (activeCourseDesignator.IsVariation && QueryEvent.HasVariations(eventDB, activeCourseDesignator.CourseId)) {
                IEnumerable<VariationInfo> variations = QueryEvent.GetAllVariations(eventDB, activeCourseDesignator.CourseId);
                if (!variations.Any(v => v.Equals(activeCourseDesignator.VariationInfo)))
                    activeCourseDesignator = activeCourseDesignator.WithAllVariations();
            }

            // Does the current part still exist?
            int numberOfParts = QueryEvent.CountCourseParts(eventDB, activeCourseDesignator);
            if (!activeCourseDesignator.IsAllControls && !activeCourseDesignator.AllParts && 
                (numberOfParts == 1 || activeCourseDesignator.Part >= numberOfParts)) 
            {
                // No part that large any more.
                if (numberOfParts > 1)
                    activeCourseDesignator = activeCourseDesignator.WithPart(numberOfParts - 1);
                else
                    activeCourseDesignator = activeCourseDesignator.WithAllParts();
                ClearSelection();
            }

            if (selectedCourseControl.IsNotNone && !eventDB.IsCourseControlPresent(selectedCourseControl)) {
                // Selected course control is no longer there.
                selectedCourseControl = Id<CourseControl>.None;
                ClearSelection();
            }

            if (selectedCourseControl.IsNotNone && activeCourseDesignator.IsNotAllControls && 
                (!activeCourseDesignator.AllParts || activeCourseDesignator.IsVariation) && 
                !QueryEvent.IsCourseControlInPart(eventDB, activeCourseDesignator, selectedCourseControl)) {
                // Selected course control is not in active part.
                // Could be allowed if it's the finish.
                Id<ControlPoint> controlId = eventDB.GetCourseControl(selectedCourseControl).control;
                if (!(eventDB.IsControlPresent(controlId) && 
                      eventDB.GetControl(controlId).kind == ControlPointKind.Finish &&
                      QueryEvent.GetPartOptions(eventDB, activeCourseDesignator).ShowFinish))
                {
                    selectedCourseControl = Id<CourseControl>.None;
                    ClearSelection();
                }
            }

            if (selectedCourseControl2.IsNotNone && !eventDB.IsCourseControlPresent(selectedCourseControl2)) {
                // Selected course control 2 is no longer there.
                selectedCourseControl2 = Id<CourseControl>.None;
                ClearSelection();
            }

            if (selectedCourseControl2.IsNotNone && activeCourseDesignator.IsNotAllControls && !activeCourseDesignator.AllParts && 
                !QueryEvent.IsCourseControlInPart(eventDB, activeCourseDesignator, selectedCourseControl2)) {
                // Selected course control 2 is not in active part.
                selectedCourseControl2 = Id<CourseControl>.None;
                ClearSelection();
            }

            if (selectedControl.IsNotNone && !eventDB.IsControlPresent(selectedControl)) {
                // Selected control is no longer there.
                ClearSelection();
            }

            if (selectedSpecial.IsNotNone && !eventDB.IsSpecialPresent(selectedSpecial)) {
                // Selected special is no longer there.
                ClearSelection();
            }

            if (selectedSpecial.IsNotNone && !(activeCourseDesignator.IsAllControls || QueryEvent.CourseContainsSpecial(eventDB, activeCourseDesignator, selectedSpecial))) {
                // Selected special is not in current course
                ClearSelection();
            }
        }