本文整理汇总了C#中PurplePen.EventDB.GetCourseControl方法的典型用法代码示例。如果您正苦于以下问题:C# EventDB.GetCourseControl方法的具体用法?C# EventDB.GetCourseControl怎么用?C# EventDB.GetCourseControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PurplePen.EventDB
的用法示例。
在下文中一共展示了EventDB.GetCourseControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSimpleLeg
// Create a single object associated with the leg from courseControlId1 to courseControlId2. Does not consider
// flagging (but does consider bends and gaps.) Used for highlighting on the map.
public static CourseObj CreateSimpleLeg(EventDB eventDB, float scaleRatio, CourseAppearance appearance, Id<CourseControl> courseControlId1, Id<CourseControl> courseControlId2)
{
Id<ControlPoint> controlId1 = eventDB.GetCourseControl(courseControlId1).control;
Id<ControlPoint> controlId2 = eventDB.GetCourseControl(courseControlId2).control;
ControlPoint control1 = eventDB.GetControl(controlId1);
ControlPoint control2 = eventDB.GetControl(controlId2);
LegGap[] gaps;
SymPath legPath = GetLegPath(eventDB, control1.location, control1.kind, controlId1, control2.location, control2.kind, controlId2, scaleRatio, appearance, out gaps);
if (legPath == null)
return null;
return new LegCourseObj(controlId1, courseControlId1, courseControlId2, scaleRatio, appearance, legPath, gaps);
}
示例2: AllVariationsOfCourseControl
// If a course control is the beginning of a variation split, return all course controls assigned to that variation split.
// Otherwise, return just that course control.
public static IEnumerable<Id<CourseControl>> AllVariationsOfCourseControl(EventDB eventDB, Id<CourseControl> courseControlId)
{
CourseControl courseControl = eventDB.GetCourseControl(courseControlId);
if (courseControl.split) {
return courseControl.splitCourseControls;
}
else {
return new[] { courseControlId };
}
}
示例3: GetControlLabelText
// Get the text for a control lable
private static string GetControlLabelText(EventDB eventDB, ControlLabelKind labelKind, CourseView.ControlView controlView, CourseView courseView)
{
string text = "";
List<CourseView.ControlView> repeatedControlViews = FindControlViewsWithControlId(courseView, controlView.controlId);
if (repeatedControlViews.Count > 1 && repeatedControlViews[0] != controlView) {
// This control is repeated (e.g., like a butterfly course) and is not the first use of this control. Don't put any text.
return "";
}
if (labelKind == ControlLabelKind.Sequence || labelKind == ControlLabelKind.SequenceAndCode || labelKind == ControlLabelKind.SequenceAndScore) {
text += controlView.ordinal.ToString();
// Add in numbers for repeated controls.
for (int i = 1; i < repeatedControlViews.Count; ++i) {
text += "/";
text += repeatedControlViews[i].ordinal.ToString();
}
}
if (labelKind == ControlLabelKind.SequenceAndCode)
text += "-";
if (labelKind == ControlLabelKind.SequenceAndCode || labelKind == ControlLabelKind.Code || labelKind == ControlLabelKind.CodeAndScore) {
ControlPoint control = eventDB.GetControl(controlView.controlId);
text += control.code;
}
if (labelKind == ControlLabelKind.CodeAndScore || labelKind == ControlLabelKind.SequenceAndScore) {
int points = eventDB.GetCourseControl(controlView.courseControlIds[0]).points;
if (points > 0) {
text += "(" + points.ToString() + ")";
}
}
return text;
}
示例4: CreateAllVariationsCourseView
// Create the view of all variations of a course with variations. Cannot be a single part of a multi-part course.
// Does not contain ordinals.
private static CourseView CreateAllVariationsCourseView(EventDB eventDB, CourseDesignator courseDesignator)
{
Course course = eventDB.GetCourse(courseDesignator.CourseId);
if (!courseDesignator.AllParts)
throw new ApplicationException("Cannot create all variations of a single part");
CourseView courseView = new CourseView(eventDB, courseDesignator);
courseView.courseName = course.name;
courseView.scoreColumn = -1;
// To get the ordinals correct, we get the course control ids for all parts.
List<Id<CourseControl>> courseControls = QueryEvent.EnumCourseControlIds(eventDB, courseDesignator).ToList();
for (int index = 0; index < courseControls.Count; ++index) {
Id<CourseControl> courseControlId = courseControls[index];
CourseControl courseControl = eventDB.GetCourseControl(courseControlId);
// We add each split control only once, even though it has multiple variations. Check to see if we have already
// handled it.
bool alreadyHandled = false;
if (courseControl.split) {
foreach (ControlView cv in courseView.controlViews) {
if (cv.courseControlIds.Contains(courseControlId))
alreadyHandled = true;
}
}
if (!alreadyHandled) {
ControlView controlView = new ControlView();
controlView.controlId = courseControl.control;
// Set the ordinal number. All variations does not include an ordinal.
controlView.ordinal = -1;
// Set all course control ids associated with split control, or a single one for a non-split control.
// Set the legTo array with the next courseControlID(s). This is later updated
// to the indices.
if (courseControl.split) {
controlView.courseControlIds = QueryEvent.AllVariationsOfCourseControl(eventDB, courseControlId).ToArray();
if (courseControl.nextCourseControl.IsNotNone) {
controlView.legTo = new int[controlView.courseControlIds.Length];
for (int i = 0; i < controlView.legTo.Length; ++i) {
controlView.legTo[i] = eventDB.GetCourseControl(controlView.courseControlIds[i]).nextCourseControl.id;
}
}
if (courseControl.loop)
controlView.joinIndex = courseControlId.id;
else
controlView.joinIndex = courseControl.splitEnd.id;
}
else {
controlView.courseControlIds = new[] { courseControlId };
if (courseControl.nextCourseControl.IsNotNone)
controlView.legTo = new int[1] { courseControl.nextCourseControl.id }; // legTo initially holds course control ids, later changed.
controlView.joinIndex = -1;
}
// Add the controlview.
courseView.controlViews.Add(controlView);
}
}
courseView.Finish();
return courseView;
}
示例5: GetVariantCodeMapping
// Get the mapping from split course control to letter.
public static Dictionary<Id<CourseControl>, char> GetVariantCodeMapping(EventDB eventDB, CourseDesignator courseDesignator)
{
Debug.Assert(!courseDesignator.IsVariation);
char nextLetter = 'A';
Dictionary<Id<CourseControl>, char> result = new Dictionary<Id<CourseControl>, char>();
foreach (Id<CourseControl> courseControlId in EnumCourseControlIds(eventDB, courseDesignator)) {
CourseControl courseControl = eventDB.GetCourseControl(courseControlId);
if (courseControl.split) {
foreach (Id<CourseControl> splitId in courseControl.splitCourseControls) {
// The loop escape path doesn't get a letter.
if (!(courseControl.loop && courseControl.splitCourseControls[0] == splitId)) {
if (!result.ContainsKey(splitId)) {
result.Add(splitId, nextLetter);
if (nextLetter == 'Z')
nextLetter = 'a';
else
++nextLetter;
}
}
}
}
}
return result;
}
示例6: GetCourseControlsInCourse
// Find all the course controls for a particular control in a particular course. If the course
// doesn't contain the given controlId, an empty array is returned.
public static Id<CourseControl>[] GetCourseControlsInCourse(EventDB eventDB, CourseDesignator courseDesignator, Id<ControlPoint> controlId)
{
List<Id<CourseControl>> list = new List<Id<CourseControl>>();
foreach (Id<CourseControl> courseControlId in EnumCourseControlIds(eventDB, courseDesignator)) {
if (eventDB.GetCourseControl(courseControlId).control == controlId)
list.Add(courseControlId);
}
return list.ToArray();
}
示例7: FindClosestLeg
// Find the closest leg to a given point on a course. The leg might be None/None if the course has no legs.
public static LegInfo FindClosestLeg(EventDB eventDB, CourseDesignator courseDesignator, PointF pt)
{
LegInfo closestLegSoFar = new LegInfo();
float closestSoFar = 1E10F;
foreach (LegInfo leg in EnumLegs(eventDB, courseDesignator)) {
PointF temp;
SymPath legPath = GetLegPath(eventDB, eventDB.GetCourseControl(leg.courseControlId1).control, eventDB.GetCourseControl(leg.courseControlId2).control);
float distance = legPath.DistanceFromPoint(pt, out temp);
if (distance < closestSoFar) {
closestSoFar = distance;
closestLegSoFar = leg;
}
else if (distance == closestSoFar) {
// Distances are equal. Use leg with the largest angle between the end points.
SymPath closestLegPath = GetLegPath(eventDB, eventDB.GetCourseControl(closestLegSoFar.courseControlId1).control, eventDB.GetCourseControl(closestLegSoFar.courseControlId2).control);
if (Geometry.Angle(legPath.FirstPoint, pt, legPath.LastPoint) > Geometry.Angle(closestLegPath.FirstPoint, pt, closestLegPath.LastPoint)) {
closestSoFar = distance;
closestLegSoFar = leg;
}
}
}
return closestLegSoFar;
}
示例8: CourseUsesControl
// Return if a give course uses a given control.
public static bool CourseUsesControl(EventDB eventDB, CourseDesignator courseDesignator, Id<ControlPoint> controlId)
{
eventDB.CheckControlId(controlId);
foreach (Id<CourseControl> courseControlId in EnumCourseControlIds(eventDB, courseDesignator)) {
if (eventDB.GetCourseControl(courseControlId).control == controlId)
return true;
}
return false;
}
示例9: CourseIsForked
public static bool CourseIsForked(EventDB eventDB, CourseDesignator courseDesignator)
{
foreach (Id<CourseControl> courseControlId in EnumCourseControlIds(eventDB, courseDesignator)) {
if (eventDB.GetCourseControl(courseControlId).split)
return true;
}
return false;
}
示例10: 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;
}
示例11: HasFinishControl
// Does the course have a finish control?
public static bool HasFinishControl(EventDB eventDB, Id<Course> courseId)
{
Id<CourseControl> lastId = QueryEvent.LastCourseControl(eventDB, courseId, false);
if (lastId.IsNone || eventDB.GetControl(eventDB.GetCourseControl(lastId).control).kind != ControlPointKind.Finish)
return false;
else
return true;
}
示例12: DescribeLeg
// Describe a leg.
private static TextPart[] DescribeLeg(EventDB eventDB, Id<CourseControl> courseControlId1, Id<CourseControl> courseControlId2, DescKind descKind)
{
Debug.Assert(descKind == DescKind.Tooltip || descKind == DescKind.DescPane);
Id<ControlPoint> controlId1 = eventDB.GetCourseControl(courseControlId1).control;
Id<ControlPoint> controlId2 = eventDB.GetCourseControl(courseControlId2).control;
Id<Leg> legId = QueryEvent.FindLeg(eventDB, controlId1, controlId2);
List<TextPart> list = new List<TextPart>();
// Course name
list.Add(new TextPart(TextFormat.Title, string.Format("{0} \u2013 {1}", Util.ControlPointName(eventDB, controlId1, NameStyle.Long), Util.ControlPointName(eventDB, controlId2, NameStyle.Long))));
// Course length
list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Length));
list.Add(new TextPart(TextFormat.SameLine,
string.Format("{0:#,###} m", QueryEvent.ComputeLegLength(eventDB, controlId1, controlId2, legId))));
// Which courses
list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.UsedIn : SelectionDescriptionText.UsedInCourses)));
Id<Course>[] coursesUsingControl = QueryEvent.CoursesUsingLeg(eventDB, controlId1, controlId2);
list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, CourseListText(eventDB, coursesUsingControl)));
// What is the competitor load?
int load = QueryEvent.GetLegLoad(eventDB, controlId1, controlId2);
if (load >= 0) {
list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.Load : SelectionDescriptionText.CompetitorLoad)));
list.Add(new TextPart(TextFormat.SameLine, string.Format("{0}", load)));
}
if (descKind == DescKind.DescPane) {
// Flagging
list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Flagging + " "));
list.Add(new TextPart(TextFormat.SameLine, FlaggingType(eventDB, controlId1, controlId2, legId)));
}
return list.ToArray();
}
示例13: CreateLegHighlights
// Create highlights to and from a point to course controls. If controlDrag is set (optional), it is
// used to get the correct bends for legs.
// Static because it is used from DragControlMode also.
public static CourseObj[] CreateLegHighlights(EventDB eventDB, PointF newPoint, Id<ControlPoint>controlDrag, ControlPointKind controlKind, Id<CourseControl> courseControlId1, Id<CourseControl> courseControlId2, float scaleRatio, CourseAppearance appearance)
{
List<CourseObj> highlights = new List<CourseObj>();
if (courseControlId1.IsNotNone) {
Id<ControlPoint> controlId1 = eventDB.GetCourseControl(courseControlId1).control;
ControlPoint control1 = eventDB.GetControl(controlId1);
LegCourseObj highlight = CreateLegHighlight(eventDB, control1.location, control1.kind, controlId1, newPoint, controlKind, controlDrag, scaleRatio, appearance);
if (highlight != null)
highlights.Add(highlight);
}
if (courseControlId2.IsNotNone) {
Id<ControlPoint> controlId2 = eventDB.GetCourseControl(courseControlId2).control;
ControlPoint control2 = eventDB.GetControl(controlId2);
LegCourseObj highlight = CreateLegHighlight(eventDB, newPoint, controlKind, controlDrag, control2.location, control2.kind, controlId2, scaleRatio, appearance);
if (highlight != null)
highlights.Add(highlight);
}
return highlights.ToArray();
}
示例14: WriteLegLoadSection
void WriteLegLoadSection(EventDB eventDB)
{
// Maps legs to load infos, so we only process each leg once.
Dictionary<Pair<Id<ControlPoint>, Id<ControlPoint>>, LegLoadInfo> loadInfos = new Dictionary<Pair<Id<ControlPoint>, Id<ControlPoint>>, LegLoadInfo>();
// Get load information about each leg. To enumerate all legs, just enumerate all courses and all legs on each course.
foreach (Id<Course> courseId in eventDB.AllCourseIds) {
foreach (QueryEvent.LegInfo leg in QueryEvent.EnumLegs(eventDB, new CourseDesignator(courseId))) {
Id<ControlPoint> controlId1 = eventDB.GetCourseControl(leg.courseControlId1).control;
Id<ControlPoint> controlId2 = eventDB.GetCourseControl(leg.courseControlId2).control;
Pair<Id<ControlPoint>, Id<ControlPoint>> key = new Pair<Id<ControlPoint>, Id<ControlPoint>>(controlId1, controlId2);
if (!loadInfos.ContainsKey(key)) {
// This leg hasn't been processed yet. Process it.
LegLoadInfo loadInfo = new LegLoadInfo();
loadInfo.controlId1 = controlId1;
loadInfo.controlId2 = controlId2;
loadInfo.text = string.Format("{0}\u2013{1}", Util.ControlPointName(eventDB, controlId1, NameStyle.Medium), Util.ControlPointName(eventDB, controlId2, NameStyle.Medium));
loadInfo.numCourses = QueryEvent.CoursesUsingLeg(eventDB, controlId1, controlId2).Length;
loadInfo.load = QueryEvent.GetLegLoad(eventDB, controlId1, controlId2);
loadInfos.Add(key, loadInfo);
}
}
}
// Remove legs used only once.
List<LegLoadInfo> loadInfoList = new List<LegLoadInfo>(loadInfos.Values);
loadInfoList = loadInfoList.FindAll(delegate(LegLoadInfo loadInfo) { return loadInfo.numCourses > 1; });
// Sort the list of legs, first by load, then by number of courses
loadInfoList.Sort(delegate(LegLoadInfo loadInfo1, LegLoadInfo loadInfo2) {
if (loadInfo1.load < loadInfo2.load) return 1;
else if (loadInfo1.load > loadInfo2.load) return -1;
if (loadInfo1.numCourses < loadInfo2.numCourses) return 1;
else if (loadInfo1.numCourses > loadInfo2.numCourses) return -1;
return 0;
});
// Write the table.
WritePara(ReportText.Load_OnlyLegsMoreThanOnce);
BeginTable("", 3, "leftalign", "rightalign", "rightalign");
WriteTableHeaderRow(ReportText.ColumnHeader_Leg, ReportText.ColumnHeader_NumberOfCourses, ReportText.ColumnHeader_Load);
foreach (LegLoadInfo loadInfo in loadInfoList) {
WriteTableRow(loadInfo.text,
Convert.ToString(loadInfo.numCourses),
loadInfo.load >= 0 ? Convert.ToString(loadInfo.load) : "");
}
EndTable();
}
示例15: 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;
}