当前位置: 首页>>代码示例>>C#>>正文


C# EventDB.GetCourse方法代码示例

本文整理汇总了C#中PurplePen.EventDB.GetCourse方法的典型用法代码示例。如果您正苦于以下问题:C# EventDB.GetCourse方法的具体用法?C# EventDB.GetCourse怎么用?C# EventDB.GetCourse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PurplePen.EventDB的用法示例。


在下文中一共展示了EventDB.GetCourse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddCourseControl

        // Add a new course control to a course. Adds a new CourseControl referencing controlId into courseId. The place to insert is
        // given by courseControl1 and courseControl2. These control should have been gotten by calling FindControlInsertionPoint.
        public static Id<CourseControl> AddCourseControl(EventDB eventDB, Id<ControlPoint> controlId, Id<Course> courseId, Id<CourseControl> courseControl1, Id<CourseControl> courseControl2)
        {
            CourseControl newCourseControl;
            Id<CourseControl> newCourseControlId;

            // When adding a new course controls, they fit into variations fine because we are never adding or changing an split, just
            // fitting into existing splits.

            if (courseControl1.IsNone) {
                // Adding at start.
                Course course = (Course) eventDB.GetCourse(courseId).Clone();
                Debug.Assert(courseControl2 == course.firstCourseControl);
                newCourseControl = new CourseControl(controlId, course.firstCourseControl);
                newCourseControlId = eventDB.AddCourseControl(newCourseControl);
                course.firstCourseControl = newCourseControlId;
                eventDB.ReplaceCourse(courseId, course);
            }
            else {
                // Adding after courseControl1.
                CourseControl before = (CourseControl) eventDB.GetCourseControl(courseControl1).Clone();
                Debug.Assert(courseControl2 == before.nextCourseControl);
                newCourseControl = new CourseControl(controlId, before.nextCourseControl);
                newCourseControlId = eventDB.AddCourseControl(newCourseControl);
                before.nextCourseControl = newCourseControlId;
                eventDB.ReplaceCourseControl(courseControl1, before);
            }

            return newCourseControlId;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:31,代码来源:ChangeEvent.cs

示例2: WriteXml

        public void WriteXml(string filename, RelayVariations relayVariations, EventDB eventDB, Id<Course> courseId)
        {
            this.relayVariations = relayVariations;
            this.eventDB = eventDB;
            this.courseId = courseId;
            this.modificationDate = DateTimeOffset.Now;
            this.courseName = eventDB.GetCourse(courseId).name;

            // Create the XML writer.
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.Encoding = new UTF8Encoding(false);
            xmlWriter = XmlWriter.Create(filename, settings);

            WriteStart();

            for (int teamNumber = 1; teamNumber < relayVariations.NumberOfTeams; ++teamNumber) {
                WriteTeam(teamNumber);
            }

            WriteEnd();

            // And done.
            xmlWriter.Close();
            eventDB = null;
            xmlWriter = null;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:27,代码来源:ExportXml.cs

示例3: SelectVariations

        public SelectVariations(EventDB eventDB, Id<Course> courseId)
        {
            InitializeComponent();

            this.eventDB = eventDB;
            this.courseId = courseId;

            Course course = eventDB.GetCourse(courseId);
            if (course.relayTeams > 0)
                lastTeam = course.relayTeams;
            else
                lastTeam = null;

            comboBoxVariations.SelectedIndex = 0;
            if (lastTeam.HasValue) {
                upDownFirstTeam.Maximum = upDownLastTeam.Maximum = lastTeam.Value;
                upDownFirstTeam.Minimum = upDownLastTeam.Minimum = 1;
                upDownFirstTeam.Value = 1;
                upDownLastTeam.Value = lastTeam.Value;

                labelNumberOfTeams.Text = string.Format(labelNumberOfTeams.Text, lastTeam.Value);
            }

            UpdateControls();
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:25,代码来源:SelectVariations.cs

示例4: CreateCourseView

        //  -----------  Static methods to create a new CourseView.  -----------------
        // Create a normal course view -- the standard view in order, from start control to finish control. courseId may NOT be None.
        private static CourseView CreateCourseView(EventDB eventDB, CourseDesignator courseDesignator, bool addNonDescriptionSpecials, bool addDescriptionSpecials)
        {
            Debug.Assert(! courseDesignator.IsAllControls);

            Course course = eventDB.GetCourse(courseDesignator.CourseId);
            CourseView courseView;
            if (course.kind == CourseKind.Score)
                courseView = CreateScoreCourseView(eventDB, courseDesignator);
            else if (course.kind == CourseKind.Normal) {
                if (QueryEvent.HasVariations(eventDB, courseDesignator.CourseId) && !courseDesignator.IsVariation)
                    courseView = CreateAllVariationsCourseView(eventDB, courseDesignator);
                else
                    courseView = CreateStandardCourseView(eventDB, courseDesignator);
            }
            else {
                Debug.Fail("Bad course kind"); return null;
            }

            courseView.AddSpecials(courseDesignator, addNonDescriptionSpecials, addDescriptionSpecials);

            return courseView;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:24,代码来源:CourseView.cs

示例5: CreateStandardCourseView

        // Create the standard view onto a regular course, or a single variation of a variation course.
        private static CourseView CreateStandardCourseView(EventDB eventDB, CourseDesignator courseDesignator)
        {
            Course course = eventDB.GetCourse(courseDesignator.CourseId);

            if (QueryEvent.HasVariations(eventDB, courseDesignator.CourseId) && courseDesignator.VariationInfo == null)
                throw new ApplicationException("Cannot create course view without specifying which variation");

            // Get sub-part of the course. firstCourseControls is the first control to process, lastCourseControl is the last one to
            // process, or None if process to the end of the course.
            Id<CourseControl> firstCourseControl, lastCourseControl;
            if (courseDesignator.AllParts) {
                firstCourseControl = course.firstCourseControl;
                lastCourseControl = Id<CourseControl>.None;
            }
            else {
                QueryEvent.GetCoursePartBounds(eventDB, courseDesignator, out firstCourseControl, out lastCourseControl);
            }

            CourseView courseView = new CourseView(eventDB, courseDesignator);
            int ordinal;

            courseView.courseName = course.name;
            courseView.scoreColumn = -1;

            ordinal = 1;
            ordinal = course.firstControlOrdinal;

            // To get the ordinals correct, we get the course control ids for all parts.
            List<Id<CourseControl>> courseControls = QueryEvent.EnumCourseControlIds(eventDB, courseDesignator.WithAllParts()).ToList();
            int index = 0;

            // Increase the ordinal value for each normal control before the first one we're considering.
            while (index < courseControls.Count && courseControls[index] != firstCourseControl) {
                CourseControl courseControl = eventDB.GetCourseControl(courseControls[index]);
                ControlPoint control = eventDB.GetControl(courseControl.control);
                if (control.kind == ControlPointKind.Normal)
                    ++ordinal;
                ++index;
            }

            for (; index < courseControls.Count; ++index) {
                Id<CourseControl> courseControlId = courseControls[index];

                ControlView controlView = new ControlView();
                CourseControl courseControl = eventDB.GetCourseControl(courseControlId);
                ControlPoint control = eventDB.GetControl(courseControl.control);

                controlView.courseControlIds = new[] { courseControlId };
                controlView.controlId = courseControl.control;

                // Set the ordinal number.
                if (control.kind == ControlPointKind.Normal)
                    controlView.ordinal = ordinal++;
                else if (control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapExchange)
                    controlView.ordinal = 0;
                else
                    controlView.ordinal = -1;

                controlView.joinIndex = -1;

                // Don't show the map exchange for the next part at the end of this part.
                if (courseControlId == lastCourseControl && !courseDesignator.AllParts && control.kind == ControlPointKind.MapExchange) {
                    controlView.hiddenControl = true;
                }

                // Set the legTo array with the next courseControlID. This is later updated
                // to the indices.
                if (index < courseControls.Count - 1 && courseControlId != lastCourseControl) {
                    Id<CourseControl> nextCourseControl = courseControls[index + 1];
                    controlView.legTo = new int[1] { nextCourseControl.id };   // legTo initially holds course control ids, later changed.
                }
                // Add the controlview.
                courseView.controlViews.Add(controlView);

                if (courseControlId == lastCourseControl)
                    break;
            }

            // If this is a part that should also have the finish on it, and it isn't the last part, then
            // add the finish.
            if (courseDesignator.IsNotAllControls && !courseDesignator.AllParts &&
                courseDesignator.Part != QueryEvent.CountCourseParts(eventDB, courseDesignator.CourseId) - 1 &&
                QueryEvent.GetPartOptions(eventDB, courseDesignator).ShowFinish)
            {
                if (QueryEvent.HasFinishControl(eventDB, courseDesignator.CourseId))
                    courseView.extraCourseControls.Add(QueryEvent.LastCourseControl(eventDB, courseDesignator.CourseId, false));
            }

            courseView.Finish();
            return courseView;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:92,代码来源:CourseView.cs

示例6: GetPrintArea

        // Get the print area for a course, or for all controls if CourseId is none.
        public static PrintArea GetPrintArea(EventDB eventDB, CourseDesignator courseDesignator)
        {
            PrintArea printArea;

            if (courseDesignator.IsAllControls)
                printArea = eventDB.GetEvent().printArea;
            else {
                Course course = eventDB.GetCourse(courseDesignator.CourseId);
                printArea = course.printArea;
                if (!courseDesignator.AllParts && course.partPrintAreas.ContainsKey(courseDesignator.Part))
                    printArea = course.partPrintAreas[courseDesignator.Part];
            }

            return printArea;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:16,代码来源:QueryEvent.cs

示例7: GetDesignatorsFromVariationChoices

        // Given a VariationChoices, select all the course designators that match.
        public static IEnumerable<CourseDesignator> GetDesignatorsFromVariationChoices(EventDB eventDB, Id<Course> courseId, VariationChoices variationChoices)
        {
            switch (variationChoices.Kind) {
                case VariationChoices.VariationChoicesKind.Combined:
                    return new[] { new CourseDesignator(courseId) };

                case VariationChoices.VariationChoicesKind.AllVariations:
                    return (from vi in GetAllVariations(eventDB, courseId)
                            select new PurplePen.CourseDesignator(courseId, vi)).ToArray();

                case VariationChoices.VariationChoicesKind.ChosenVariations:
                    return (from vi in GetAllVariations(eventDB, courseId)
                            where variationChoices.ChosenVariations.Contains(vi.CodeString)
                            select new PurplePen.CourseDesignator(courseId, vi)).ToArray();

                case VariationChoices.VariationChoicesKind.ChosenTeams:
                    Course course = eventDB.GetCourse(courseId);
                    RelayVariations relayVariations = new RelayVariations(eventDB, courseId, course.relayTeams, course.relayLegs);

                    List<CourseDesignator> result = new List<CourseDesignator>();
                    for (int team = variationChoices.FirstTeam; team <= variationChoices.LastTeam; ++team) {
                        for (int leg = 1; leg <= relayVariations.NumberOfLegs; ++leg) {
                            result.Add(new CourseDesignator(courseId, relayVariations.GetVariation(team, leg)));
                        }
                    }

                    return result;

                default:
                    Debug.Fail("Bad variation choices kind");
                    return null;
            }
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:34,代码来源:QueryEvent.cs

示例8: GetCourseSortOrder

 // What is the sort order for this course. Order is integer > 0.
 public static int GetCourseSortOrder(EventDB eventDB, Id<Course> courseId)
 {
     return eventDB.GetCourse(courseId).sortOrder;
 }
开发者ID:petergolde,项目名称:PurplePen,代码行数:5,代码来源:QueryEvent.cs

示例9: GetAllVariations

        // Get all the possible variations for a given course, based on the loops/forks. Returns a list of VariationInfo,
        // giving the code string, VariationPath, and name. Sorted by code string.
        public static IEnumerable<VariationInfo> GetAllVariations(EventDB eventDB, Id<Course> courseId)
        {
            HashSet<Id<CourseControl>> alreadyVisited = new HashSet<PurplePen.Id<PurplePen.CourseControl>>();

            CourseDesignator courseDesignator = new CourseDesignator(courseId);
            Dictionary<Id<CourseControl>, char> variationMapper = GetVariantCodeMapping(eventDB, courseDesignator);
            List<List<Id<CourseControl>>> variations = GetVariations(eventDB, courseDesignator, eventDB.GetCourse(courseId).firstCourseControl, alreadyVisited);

            List<VariationInfo> result = new List<VariationInfo>();

            // Check for no variations.
            if (variations.Count == 1 && variations[0].Count == 0)
                return result;

            foreach (var choices in variations) {
                string variationString = GetVariationString(eventDB, choices, variationMapper);
                VariationInfo.VariationPath variationPath = new VariationInfo.VariationPath(choices);
                result.Add(new VariationInfo(variationString, variationPath));
            }
            result.Sort((vi1, vi2) => string.Compare(vi1.CodeString, vi2.CodeString, StringComparison.OrdinalIgnoreCase));

            return result;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:25,代码来源:QueryEvent.cs

示例10: HasVariations

        // See if course has any variations.
        public static bool HasVariations(EventDB eventDB, Id<Course> courseId)
        {
            if (courseId.IsNone)
                return false;  // All Control has no variations.
            Course course = eventDB.GetCourse(courseId);
            if (course.kind == CourseKind.Score)
                return false;  // Score courses don't have variations.

            return EnumCourseControlIds(eventDB, new CourseDesignator(courseId)).Any(courseControlId => eventDB.GetCourseControl(courseControlId).split);
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:11,代码来源:QueryEvent.cs

示例11: HasStartControl

 // Does the course have a start control?
 public static bool HasStartControl(EventDB eventDB, Id<Course> courseId)
 {
     Id<CourseControl> firstId = eventDB.GetCourse(courseId).firstCourseControl;
     if (firstId.IsNone || eventDB.GetControl(eventDB.GetCourseControl(firstId).control).kind != ControlPointKind.Start)
         return false;
     else
         return true;
 }
开发者ID:petergolde,项目名称:PurplePen,代码行数:9,代码来源:QueryEvent.cs

示例12: HasPartSpecificPrintArea

 // Returns true if the course designator is a specific part and that part has a custom print area
 // just for that part.
 public static bool HasPartSpecificPrintArea(EventDB eventDB, CourseDesignator courseDesignator)
 {
     if (courseDesignator.IsAllControls)
         return false;
     else {
         return (!courseDesignator.AllParts && eventDB.GetCourse(courseDesignator.CourseId).partPrintAreas.ContainsKey(courseDesignator.Part));
     }
 }
开发者ID:petergolde,项目名称:PurplePen,代码行数:10,代码来源:QueryEvent.cs

示例13: CourseListText

        // Get the text for a list of courses. Returns "None" for no courses. Returns "All courses" for all courses.
        // The list of course names is sorted.
        private static string CourseListText(EventDB eventDB, Id<Course>[] courseIds)
        {
            if (courseIds.Length == 0)
                return SelectionDescriptionText.CourseList_None;

            if (courseIds.Length == QueryEvent.CountCourses(eventDB))
                return SelectionDescriptionText.CourseList_AllCourses;

            StringBuilder builder = new StringBuilder();
            string[] courseNames = new string[courseIds.Length];

            for (int i = 0; i < courseIds.Length; ++i) {
                courseNames[i] = eventDB.GetCourse(courseIds[i]).name;
            }
            Array.Sort(courseNames);

            for (int i = 0; i < courseNames.Length; ++i) {
                if (i != 0)
                    builder.Append(", ");
                builder.Append(courseNames[i]);
            }

            return builder.ToString();
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:26,代码来源:SelectionDescriber.cs

示例14: MissingScores

        // Get missing points.
        List<MissingThing> MissingScores(EventDB eventDB)
        {
            List<MissingThing> missingScores = new List<MissingThing>();

            foreach (Id<Course> courseId in QueryEvent.SortedCourseIds(eventDB)) {
                Course course = eventDB.GetCourse(courseId);
                bool anyScores = false;
                List<MissingThing> missingScoresThisCourse = new List<MissingThing>();

                if (course.kind == CourseKind.Score) {
                    for (Id<CourseControl> courseControlId = course.firstCourseControl;
                          courseControlId.IsNotNone;
                          courseControlId = eventDB.GetCourseControl(courseControlId).nextCourseControl)
                    {
                        CourseControl courseControl = eventDB.GetCourseControl(courseControlId);

                        if (eventDB.GetControl(courseControl.control).kind == ControlPointKind.Normal) {
                            if (courseControl.points <= 0)
                                missingScoresThisCourse.Add(new MissingThing(courseId, courseControl.control, ReportText.EventAudit_MissingScore));
                            else
                                anyScores = true;
                        }
                    }

                    if (anyScores)
                        missingScores.AddRange(missingScoresThisCourse);  // only report missing scores if some control in this course has a score.
                }
            }

            return missingScores;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:32,代码来源:Reports.cs

示例15: MissingCourseThings

        // Get missing things in courses. Sorted in correct course sort order.
        List<MissingThing> MissingCourseThings(EventDB eventDB)
        {
            List<MissingThing> list = new List<MissingThing>();

            bool checkLoad = QueryEvent.AnyCoursesHaveLoads(eventDB);       // only check load if some courses have it.

            foreach (Id<Course> courseId in QueryEvent.SortedCourseIds(eventDB)) {
                Course course = eventDB.GetCourse(courseId);
                if (course.kind == CourseKind.Normal)
                    AddMissingThingsInRegularCourse(eventDB, courseId, list);
                else if (course.kind == CourseKind.Score)
                    AddMissingThingsInScoreCourse(eventDB, courseId, list);
                else
                    Debug.Fail("bad course kind");

                if (checkLoad && eventDB.GetCourse(courseId).load < 0)
                    list.Add(new MissingThing(courseId, ReportText.ColumnHeader_Load, ReportText.EventAudit_MissingLoad));
            }

            return list;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:22,代码来源:Reports.cs


注:本文中的PurplePen.EventDB.GetCourse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。