本文整理汇总了C#中PurplePen.EventDB.GetControl方法的典型用法代码示例。如果您正苦于以下问题:C# EventDB.GetControl方法的具体用法?C# EventDB.GetControl怎么用?C# EventDB.GetControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PurplePen.EventDB
的用法示例。
在下文中一共展示了EventDB.GetControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeAngleOut
// Get the angle from the given control index to the next control.
public static double ComputeAngleOut(EventDB eventDB, CourseView courseView, int controlIndex)
{
PointF pt1 = eventDB.GetControl(courseView.ControlViews[controlIndex].controlId).location;
// Get index of next control.
int nextControlIndex = courseView.GetNextControl(controlIndex);
if (nextControlIndex < 0)
return double.NaN;
// By default, the location of the next control is the direction.
PointF pt2 = eventDB.GetControl(courseView.ControlViews[nextControlIndex].controlId).location;
// If there is a custom leg, then use the location of the first bend instead.
Id<Leg> legId = QueryEvent.FindLeg(eventDB, courseView.ControlViews[controlIndex].controlId, courseView.ControlViews[nextControlIndex].controlId);
if (legId.IsNotNone) {
Leg leg = eventDB.GetLeg(legId);
if (leg.bends != null && leg.bends.Length > 0)
pt2 = leg.bends[0];
}
return Math.Atan2(pt2.Y - pt1.Y, pt2.X - pt1.X);
}
示例2: GetOtherLocations
// Get all the locations in the course exception controlView.
private static PointF[] GetOtherLocations(EventDB eventDB, CourseView courseView, CourseView.ControlView controlViewExcept)
{
List<PointF> list = new List<PointF>();
foreach (CourseView.ControlView controlView in courseView.ControlViews) {
if (controlView != controlViewExcept)
list.Add(eventDB.GetControl(controlView.controlId).location);
}
return list.ToArray();
}
示例3: CreateFilteredAllControlsView
// Create an filtered All Controls view -- show controls from the control collection, but only includes some.
// excludedCourses contains an array of course ids to excluded from the contgrols.
// kindFilter, if non-null, limits the controls to this kind of controls.
public static CourseView CreateFilteredAllControlsView(EventDB eventDB, CourseDesignator[] excludedCourses, ControlPointKind kindFilter, bool addSpecials, bool addDescription)
{
CourseView courseView = new CourseView(eventDB, CourseDesignator.AllControls);
courseView.courseName = MiscText.AllControls;
courseView.scoreColumn = -1;
// Add every control to the course view, subject to the filters.
foreach (Id<ControlPoint> controlId in eventDB.AllControlPointIds) {
ControlPoint control = eventDB.GetControl(controlId);
// Check if the control is filtered out.
if (excludedCourses != null) {
// Filter excluded courses.
foreach (CourseDesignator excludedCourseDesignator in excludedCourses) {
if (QueryEvent.CourseUsesControl(eventDB, excludedCourseDesignator, controlId))
goto SKIP;
}
}
if (kindFilter != ControlPointKind.None) {
// Filter on control type.
if (control.kind != kindFilter)
goto SKIP;
}
// We are going to include this control in the collection.
ControlView controlView = new ControlView();
controlView.courseControlIds = new[] { Id<CourseControl>.None };
controlView.controlId = controlId;
// All controls doesn't have ordinals.
controlView.ordinal = -1;
controlView.joinIndex = -1;
courseView.controlViews.Add(controlView);
SKIP: ;
}
// Sort the control views: first by kind, then by code.
courseView.controlViews.Sort((view1, view2) => QueryEvent.CompareControlIds(eventDB, view1.controlId, view2.controlId));
courseView.Finish();
if (addSpecials) {
// Add every special, regardless of courses it is on, except for descriptions. Descriptions are added to all
// controls only if they appear in all courses (or specifically for the all controls view), and if "addDescription" is true
foreach (Id<Special> specialId in eventDB.AllSpecialIds) {
Special special = eventDB.GetSpecial(specialId);
if (special.kind == SpecialKind.Descriptions) {
if (addDescription && QueryEvent.CourseContainsSpecial(eventDB, CourseDesignator.AllControls, specialId))
courseView.descriptionViews.Add(new DescriptionView(specialId, CourseDesignator.AllControls));
}
else
courseView.specialIds.Add(specialId);
}
}
return courseView;
}
示例4: GetLegPath
// Find the SymPath of the path between controls, taking any bends into account. If no bends, the path is just the
// simple path between the controls.
public static SymPath GetLegPath(EventDB eventDB, Id<ControlPoint> controlId1, Id<ControlPoint> controlId2, Id<Leg> legId)
{
PointF location1 = eventDB.GetControl(controlId1).location;
PointF location2 = eventDB.GetControl(controlId2).location;
if (legId.IsNotNone) {
Leg leg = eventDB.GetLeg(legId);
Debug.Assert(leg.controlId1 == controlId1 && leg.controlId2 == controlId2);
if (leg.bends != null) {
List<PointF> points = new List<PointF>();
points.Add(location1);
points.AddRange(leg.bends);
points.Add(location2);
return new SymPath(points.ToArray());
}
}
// No bends.
return new SymPath(new PointF[] { location1, location2 });
}
示例5: GetControlGaps
// Get the gaps in a control for a given scale.
// Returns null if no gaps defined for that scale.
public static CircleGap[] GetControlGaps(EventDB eventDB, Id<ControlPoint> controlId, float scale)
{
int scaleInt = (int)Math.Round(scale);
ControlPoint control = eventDB.GetControl(controlId);
if (control.gaps == null)
return null;
else if (!control.gaps.ContainsKey(scaleInt))
return null;
else {
return control.gaps[scaleInt];
}
}
示例6: FindCode
// Find the control with a code, and return its ID. Else return None.
public static Id<ControlPoint> FindCode(EventDB eventDB, string code)
{
if (string.IsNullOrWhiteSpace(code))
return Id<ControlPoint>.None;
foreach (Id<ControlPoint> controlId in eventDB.AllControlPointIds) {
if (eventDB.GetControl(controlId).code == code)
return controlId;
}
return Id<ControlPoint>.None;
}
示例7: ComputeLegLength
// Compute the length of a leg between two controls, in meters. The indicated leg id, if non-zero, is used
// to get bend information. The event map scale converts between the map scale, in mm, which is used
// for the coordinate information, to meters in the world scale.
public static float ComputeLegLength(EventDB eventDB, Id<ControlPoint> controlId1, Id<ControlPoint> controlId2, Id<Leg> legId)
{
PointF location1 = eventDB.GetControl(controlId1).location;
PointF location2 = eventDB.GetControl(controlId2).location;
SymPath path = GetLegPath(eventDB, controlId1, controlId2, legId);
return (float)((eventDB.GetEvent().mapScale * path.Length) / 1000.0);
}
示例8: CompareControlIds
// Compare control ID by kind and code.
public static int CompareControlIds(EventDB eventDB, Id<ControlPoint> controlId1, Id<ControlPoint> controlId2)
{
ControlPoint control1 = eventDB.GetControl(controlId1);
ControlPoint control2 = eventDB.GetControl(controlId2);
if (control1.kind < control2.kind)
return -1;
else if (control1.kind > control2.kind)
return 1;
int result = Util.CompareCodes(control1.code, control2.code);
if (result != 0)
return result;
return controlId1.id.CompareTo(controlId2.id);
}
示例9: 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;
}
示例10: MissingPunches
// Get missing punches.
List<MissingThing> MissingPunches(EventDB eventDB, List<Id<ControlPoint>> unusedControls)
{
List<MissingThing> missingPunches = new List<MissingThing>();
bool anyPunches = false; // Keep track if any controls have non-empty punch pattersn.
foreach (Id<ControlPoint> controlId in eventDB.AllControlPointIds) {
if (unusedControls.Contains(controlId))
continue;
ControlPoint control = eventDB.GetControl(controlId);
if (control.kind != ControlPointKind.Normal)
continue;
if (control.punches == null || control.punches.IsEmpty)
missingPunches.Add(new MissingThing(controlId, ReportText.EventAudit_MissingPunch));
else
anyPunches = true;
}
if (anyPunches) {
missingPunches.Sort((thing1, thing2) => QueryEvent.CompareControlIds(eventDB, thing1.controlId, thing2.controlId));
return missingPunches;
}
else {
// No controls had punch patterns defined. This event clearly is not using punches.
return new List<MissingThing>();
}
}
示例11: MissingDescriptionBoxes
// Get missing description boxes.
List<MissingThing> MissingDescriptionBoxes(EventDB eventDB, List<Id<ControlPoint>> unusedControls)
{
List<MissingThing> missingBoxes = new List<MissingThing>();
foreach (Id<ControlPoint> controlId in eventDB.AllControlPointIds) {
// Go through all regular or start controls that are in use.
if (unusedControls.Contains(controlId))
continue;
ControlPoint control = eventDB.GetControl(controlId);
if (control.kind != ControlPointKind.Normal && control.kind != ControlPointKind.Start)
continue;
// If a start control is completely empty, don't process it.
if (control.kind == ControlPointKind.Start) {
if (! Array.Exists(control.symbolIds, id => !string.IsNullOrEmpty(id)))
continue;
}
// Each start or normal control has 6 boxes. C==0, D==1, E==2, F==3, G==4, H==5
Debug.Assert(control.symbolIds.Length == 6);
if (string.IsNullOrEmpty(control.symbolIds[1])) {
missingBoxes.Add(new MissingThing(controlId, "D", ReportText.EventAudit_MissingD));
}
else if (! string.IsNullOrEmpty(control.symbolIds[3]) && string.IsNullOrEmpty(control.symbolIds[2])) {
missingBoxes.Add(new MissingThing(controlId, "E", ReportText.EventAudit_MissingEJunction));
}
else if (control.symbolIds[4] == "11.15" && string.IsNullOrEmpty(control.symbolIds[2])) {
missingBoxes.Add(new MissingThing(controlId, "E", ReportText.EventAudit_MissingEBetween));
}
}
missingBoxes.Sort(((thing1, thing2) => QueryEvent.CompareControlIds(eventDB, thing1.controlId, thing2.controlId)));
return missingBoxes;
}
示例12: GetControlIdsToXref
// Get all the control IDs to cross-ref, in the correct order.
private Id<ControlPoint>[] GetControlIdsToXref(EventDB eventDB)
{
// Only cross-ref regular controls. Then sort by code.
List<Id<ControlPoint>> list = new List<Id<ControlPoint>>();
foreach (Id<ControlPoint> controlId in eventDB.AllControlPointIds) {
if (eventDB.GetControl(controlId).kind == ControlPointKind.Normal)
list.Add(controlId);
}
list.Sort(delegate(Id<ControlPoint> id1, Id<ControlPoint> id2) {
ControlPoint control1 = eventDB.GetControl(id1), control2 = eventDB.GetControl(id2);
return Util.CompareCodes(control1.code, control2.code);
});
return list.ToArray();
}
示例13: FindNearbyControls
// Return a list of all controls that are nearby each other. It is sorted in order of distance.
private List<NearbyControls> FindNearbyControls(EventDB eventDB, float distanceLimit)
{
ICollection<Id<ControlPoint>> allPoints = eventDB.AllControlPointIds;
List<NearbyControls> list = new List<NearbyControls>();
// Go through every pair of normal controls. If the distance between them is less than the distance limit, add to the list.
foreach (Id<ControlPoint> controlId1 in allPoints) {
ControlPoint control1 = eventDB.GetControl(controlId1);
if (control1.kind != ControlPointKind.Normal)
continue; // only deal with normal points.
string symbol1 = SymbolOfControl(control1);
// Check all other controls with greater ids (so each pair considered only once)
foreach (Id<ControlPoint> controlId2 in allPoints) {
ControlPoint control2 = eventDB.GetControl(controlId2);
if (control2.kind != ControlPointKind.Normal || controlId2.id <= controlId1.id)
continue; // only deal with normal points with greater id.
string symbol2 = SymbolOfControl(control2);
float distance = QueryEvent.ComputeStraightLineControlDistance(eventDB, controlId1, controlId2);
if (distance < distanceLimit) {
NearbyControls nearbyControls;
nearbyControls.controlId1 = controlId1;
nearbyControls.controlId2 = controlId2;
nearbyControls.distance = distance;
nearbyControls.sameSymbol = (symbol1 != null && symbol2 != null && symbol1 == symbol2); // only same symbol if both have symbols!
list.Add(nearbyControls);
}
}
}
// Sort the list by distance.
list.Sort((x1, x2) => x1.distance.CompareTo(x2.distance));
return list;
}
示例14: CreateCrossReferenceReport
internal string CreateCrossReferenceReport(EventDB eventDB)
{
InitReport();
// Header.
WriteH1(string.Format(ReportText.CrossRef_Title, QueryEvent.GetEventTitle(eventDB, " ")));
Id<ControlPoint>[] controlsToXref = GetControlIdsToXref(eventDB);
Id<Course>[] coursesToXref = QueryEvent.SortedCourseIds(eventDB);
string[,] xref = CreateXref(eventDB, controlsToXref, coursesToXref);
string[] classes = new string[coursesToXref.Length + 1];
classes[0] = "leftalign";
for (int i = 1; i < classes.Length; ++i)
classes[i] = "rightalign";
BeginTable("", classes.Length, classes);
// Write the header row.
BeginTableRow();
WriteTableHeaderCell(ReportText.ColumnHeader_Control);
for (int i = 0; i < coursesToXref.Length; ++i)
WriteTableHeaderCell(eventDB.GetCourse(coursesToXref[i]).name);
EndTableRow();
// Write the cross-reference rows. Table rule after every 3rd line
for (int row = 0; row < controlsToXref.Length; ++row) {
bool tablerule = (row % 3 == 2);
BeginTableRow();
WriteTableCell(tablerule ? "tablerule" : "", eventDB.GetControl(controlsToXref[row]).code);
for (int col = 0; col < coursesToXref.Length; ++col)
WriteTableCell(tablerule ? "tablerule" : "", xref[row, col]);
EndTableRow();
}
EndTable();
return FinishReport();
}
示例15: CreateEventAuditReport
// Create a report showing missing things
public string CreateEventAuditReport(EventDB eventDB)
{
bool problemFound = false;
// Initialize the report
InitReport();
// Header.
WriteH1(string.Format(ReportText.EventAudit_Title, QueryEvent.GetEventTitle(eventDB, " ")));
// Courses missing things. Climb (not score course), start, finish (not score course), competitor load.
List<MissingThing> missingCourseThings = MissingCourseThings(eventDB);
if (missingCourseThings.Count > 0) {
problemFound = true;
WriteH2(ReportText.EventAudit_MissingItems);
BeginTable("", 3, "leftalign", "leftalign", "leftalign");
WriteTableHeaderRow(ReportText.ColumnHeader_Course, ReportText.ColumnHeader_Item, ReportText.ColumnHeader_Reason);
foreach (MissingThing thing in missingCourseThings) {
WriteTableRow(eventDB.GetCourse(thing.courseId).name, thing.what, thing.why);
}
EndTable();
}
// Close together controls.
float DISTANCE_LIMIT = 100.4999F; // limit of distance for close controls (100m, when rounded).
List<NearbyControls> nearbyList = FindNearbyControls(eventDB, DISTANCE_LIMIT);
if (nearbyList.Count > 0) {
problemFound = true;
// Informational text.
WriteH2(ReportText.EventAudit_CloseTogetherControls);
StartPara();
WriteText(string.Format(ReportText.EventAudit_CloseTogetherExplanation, Math.Round(DISTANCE_LIMIT)));
EndPara();
// The report.
BeginTable("", 3, "leftalign", "rightalign", "leftalign");
WriteTableHeaderRow(ReportText.ColumnHeader_ControlCodes, ReportText.ColumnHeader_Distance, ReportText.ColumnHeader_SameSymbol);
foreach (NearbyControls nearby in nearbyList) {
string code1 = eventDB.GetControl(nearby.controlId1).code;
string code2 = eventDB.GetControl(nearby.controlId2).code;
if (Util.CompareCodes(code1, code2) > 0) {
// swap code1 and code 2 so they always appear in order.
string temp = code1;
code1 = code2;
code2 = temp;
}
WriteTableRow(string.Format("{0}, {1}", code1, code2), string.Format("{0} m", Math.Round(nearby.distance)), nearby.sameSymbol ? ReportText.EventAudit_Yes : ReportText.EventAudit_No);
}
EndTable();
}
// Unused controls.
List<Id<ControlPoint>> unusedControls = SortedUnusedControls(eventDB);
if (unusedControls.Count > 0) {
problemFound = true;
WriteH2(ReportText.EventAudit_UnusedControls);
StartPara();
WriteText(ReportText.EventAudit_UnusedControlsExplanation);
EndPara();
BeginTable("", 2, "leftalign", "leftalign");
WriteTableHeaderRow(ReportText.ColumnHeader_Code, ReportText.ColumnHeader_Location);
foreach (Id<ControlPoint> controlId in unusedControls) {
ControlPoint control = eventDB.GetControl(controlId);
WriteTableRow(Util.ControlPointName(eventDB, controlId, NameStyle.Medium), string.Format("({0}, {1})", Math.Round(control.location.X), Math.Round(control.location.Y)));
}
EndTable();
}
// Missing descriptions boxes (regular controls only). Missing column D. Missing column E when between/junction/crossing used. Missing between/junction/crossing when column E is a symbol.
List<MissingThing> missingBoxes = MissingDescriptionBoxes(eventDB, unusedControls);
if (missingBoxes.Count > 0) {
problemFound = true;
WriteH2(ReportText.EventAudit_MissingBoxes);
BeginTable("", 3, "leftalign", "leftalign", "leftalign");
WriteTableHeaderRow(ReportText.ColumnHeader_Code, ReportText.ColumnHeader_Column, ReportText.ColumnHeader_Reason);
foreach (MissingThing thing in missingBoxes) {
WriteTableRow(Util.ControlPointName(eventDB, thing.controlId, NameStyle.Medium), thing.what, thing.why);
}
EndTable();
}
// Missing punches.
List<MissingThing> missingPunches = MissingPunches(eventDB, unusedControls);
if (missingPunches.Count > 0) {
problemFound = true;
WriteH2(ReportText.EventAudit_MissingPunchPatterns);
BeginTable("", 2, "leftalign", "leftalign");
WriteTableHeaderRow(ReportText.ColumnHeader_Code, ReportText.ColumnHeader_Reason);
foreach (MissingThing thing in missingPunches) {
WriteTableRow(Util.ControlPointName(eventDB, thing.controlId, NameStyle.Medium), thing.what);
}
//.........这里部分代码省略.........