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(); } }
// 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; } }
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); } } } }
public void Initialize(EventDB eventDB, SymbolDB symbolDB) { eventDB.Validate(); this.eventDB = eventDB; this.symbolDB = symbolDB; descriptionControl1.SymbolDB = symbolDB; listBoxCourses.Items.Add(new CourseItem(eventDB, Id <Course> .None)); foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { listBoxCourses.Items.Add(new CourseItem(eventDB, courseId)); } listBoxCourses.SelectedIndex = 0; }
void WriteCourses() { WriteAllCoursesStart(); // Sport Software requires that the courses be numbers started at 0. int courseNumber = 0; foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { if (WriteCourse(courseId, courseNumber)) { ++courseNumber; } } WriteAllCoursesEnd(); }
public void Initialize(EventDB eventDB, SymbolDB symbolDB) { this.symbolDB = symbolDB; this.eventDB = eventDB; eventDB.Validate(); popup = new SymbolPopup(symbolDB, 26); popup.Selected += PopupSelected; popup.Canceled += PopupCanceled; descriptionRenderer = new DescriptionRenderer(symbolDB); listBoxCourses.Items.Add(new CourseItem(eventDB, Id <Course> .None)); foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { listBoxCourses.Items.Add(new CourseItem(eventDB, courseId)); } comboBoxKind.SelectedIndex = 0; listBoxCourses.SelectedIndex = 0; }
// Get the text for a list of courses. Returns "None" for no courses. Returns "All courses" for all courses. // The list of course names in the canonical order of courses (same as the tab order). 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(); Id <Course>[] sortedCourseIds = QueryEvent.SortedCourseIds(eventDB); List <string> courseNames = new List <string>(); if (courseIds.Contains(new Id <Course>(0))) { courseNames.Add(MiscText.AllControls); } for (int i = 0; i < sortedCourseIds.Length; ++i) { if (courseIds.Contains(sortedCourseIds[i])) { courseNames.Add(eventDB.GetCourse(sortedCourseIds[i]).name); } } for (int i = 0; i < courseNames.Count; ++i) { if (i != 0) { builder.Append(", "); } builder.Append(courseNames[i]); } return(builder.ToString()); }
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); }
private void LoadList() { if (eventDB != null && !loaded) { if (showAllControls) { courseTreeView.Nodes.Add(new TreeNode(MiscText.AllControls) { Tag = CourseDesignator.AllControls }); } foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB)) { TreeNode[] parts = null; // If the course has parts, get all the parts. int numberParts = QueryEvent.CountCourseParts(eventDB, new CourseDesignator(courseId), true); if (showCourseParts && numberParts > 1) { parts = new TreeNode[numberParts]; for (int part = 0; part < numberParts; ++part) { CourseDesignator partDesignator = new CourseDesignator(courseId, part); if (CheckFilter(partDesignator)) { parts[part] = new TreeNode(string.Format(MiscText.PartN, part + 1)) { Tag = partDesignator, Checked = true }; } } } // Add node for the course to the tree. CourseDesignator designator = new CourseDesignator(courseId); if (CheckFilter(designator)) { TreeNode node; if (parts != null) { node = new TreeNode(eventDB.GetCourse(courseId).name, parts); } else { node = new TreeNode(eventDB.GetCourse(courseId).name); } node.Tag = designator; node.Checked = true; courseTreeView.Nodes.Add(node); } } courseTreeView.ExpandAll(); buttonChooseVariations.Visible = (ShowVariationChooser && eventHasVariations); loaded = true; } }