本文整理匯總了C#中PurplePen.EventDB.ReplaceCourse方法的典型用法代碼示例。如果您正苦於以下問題:C# EventDB.ReplaceCourse方法的具體用法?C# EventDB.ReplaceCourse怎麽用?C# EventDB.ReplaceCourse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PurplePen.EventDB
的用法示例。
在下文中一共展示了EventDB.ReplaceCourse方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: ChangePrintArea
// Change the course print area. If "removeParts" is true, and the course is an all parts,
// then remove print descriptions for each part.
public static void ChangePrintArea(EventDB eventDB, CourseDesignator courseDesignator, bool removeParts, PrintArea printArea)
{
printArea = (PrintArea) printArea.Clone();
if (courseDesignator.IsAllControls) {
Event e = eventDB.GetEvent();
e = (Event) e.Clone();
e.printArea = printArea;
eventDB.ChangeEvent(e);
}
else {
Course course = eventDB.GetCourse(courseDesignator.CourseId);
course = (Course) course.Clone();
if (courseDesignator.AllParts) {
course.printArea = printArea;
if (removeParts)
course.partPrintAreas = new Dictionary<int, PrintArea>();
}
else {
course.partPrintAreas[courseDesignator.Part] = printArea;
}
eventDB.ReplaceCourse(courseDesignator.CourseId, course);
}
}
示例3: ChangePartOptions
public static void ChangePartOptions(EventDB eventDB, CourseDesignator courseDesignator, PartOptions partOptions)
{
Debug.Assert(courseDesignator.IsNotAllControls);
Course course = eventDB.GetCourse(courseDesignator.CourseId);
course = (Course)course.Clone();
course.partOptions[courseDesignator.Part] = partOptions.Clone();
eventDB.ReplaceCourse(courseDesignator.CourseId, course);
}
示例4: ChangeCourseSortOrder
// Change the sort order of a course.
public static void ChangeCourseSortOrder(EventDB eventDB, Id<Course> courseId, int newSortOrder)
{
if (newSortOrder <= 0)
throw new ApplicationException("Bad sort order");
Course course = eventDB.GetCourse(courseId);
course = (Course) course.Clone();
course.sortOrder = newSortOrder;
eventDB.ReplaceCourse(courseId, course);
}
示例5: ChangeCourseSecondaryTitle
// Change the course secondary title. Use "" or null to remove the secondary title.
public static void ChangeCourseSecondaryTitle(EventDB eventDB, Id<Course> courseId, string newTitle)
{
if (newTitle == "")
newTitle = null;
Course course = eventDB.GetCourse(courseId);
course = (Course)course.Clone();
course.secondaryTitle = newTitle;
eventDB.ReplaceCourse(courseId, course);
}
示例6: ChangeCourseOverrideLength
// Change the course override length.
public static void ChangeCourseOverrideLength(EventDB eventDB, Id<Course> courseId, float? length)
{
Course course = eventDB.GetCourse(courseId);
course = (Course)course.Clone();
course.overrideCourseLength = length;
eventDB.ReplaceCourse(courseId, course);
}
示例7: ChangeCourseProperties
// Change the attributes of a course.
public static void ChangeCourseProperties(EventDB eventDB, Id<Course> courseId, CourseKind courseKind, string courseName, ControlLabelKind labelKind, int scoreColumn, string secondaryTitle, float printScale, float climb, float? length, DescriptionKind descriptionKind, int firstControlOrdinal)
{
Course course = eventDB.GetCourse(courseId);
course = (Course) course.Clone();
course.kind = courseKind;
course.labelKind = labelKind;
course.scoreColumn = scoreColumn;
course.name = courseName;
course.secondaryTitle = secondaryTitle;
course.printScale = printScale;
course.climb = climb;
course.overrideCourseLength = length;
course.descKind = descriptionKind;
course.firstControlOrdinal = firstControlOrdinal;
eventDB.ReplaceCourse(courseId, course);
}
示例8: ChangeCourseLoad
// Change the load of a course.
public static void ChangeCourseLoad(EventDB eventDB, Id<Course> courseId, int newLoad)
{
Course course = eventDB.GetCourse(courseId);
course = (Course) course.Clone();
course.load = newLoad;
eventDB.ReplaceCourse(courseId, course);
}
示例9: ChangeCourseName
// Change the course name.
public static void ChangeCourseName(EventDB eventDB, Id<Course> courseId, string newName)
{
Course course = eventDB.GetCourse(courseId);
course = (Course)course.Clone();
course.name = newName;
eventDB.ReplaceCourse(courseId, course);
}
示例10: ChangeCourseClimb
// Change the course climb.
public static void ChangeCourseClimb(EventDB eventDB, Id<Course> courseId, float newClimb)
{
Course course = eventDB.GetCourse(courseId);
course = (Course)course.Clone();
course.climb = newClimb;
eventDB.ReplaceCourse(courseId, course);
}
示例11: AddStartToCourse
// Add a start control to a given course. If the course already has a start control as the first control, replace it.
// Otherwise add it as the new start control. The returned CourseControl may be new, or may be the first control with
// a different control point.
// If addToOtherCourses is true, the new start control is also added to all courses without an existing start control.
public static Id<CourseControl> AddStartToCourse(EventDB eventDB, Id<ControlPoint> controlId, Id<Course> courseId, bool addToOtherCourses)
{
Course course = eventDB.GetCourse(courseId);
Id<CourseControl> firstId = course.firstCourseControl;
Id<CourseControl> newCourseControlId;
if (firstId.IsNotNone && eventDB.GetControl(eventDB.GetCourseControl(firstId).control).kind == ControlPointKind.Start) {
// First control exists and is a start control. Replace it.
CourseControl first = (CourseControl) eventDB.GetCourseControl(firstId).Clone();
first.control = controlId;
eventDB.ReplaceCourseControl(firstId, first);
newCourseControlId = firstId;
}
else {
// Add the control as a new start control.
newCourseControlId = eventDB.AddCourseControl(new CourseControl(controlId, firstId));
course = (Course) course.Clone();
course.firstCourseControl = newCourseControlId;
eventDB.ReplaceCourse(courseId, course);
}
if (addToOtherCourses) {
List<Id<Course>> courseModificationList = new List<Id<Course>>();
// Check all courses to see if we should add the start to that course too.
foreach (Id<Course> courseSearchId in eventDB.AllCourseIds) {
if (!QueryEvent.HasStartControl(eventDB, courseSearchId)) {
// This course does not have a start control.
courseModificationList.Add(courseSearchId);
}
}
// Add the start control to each of those courses.
foreach (Id<Course> modifyCourseId in courseModificationList)
AddStartToCourse(eventDB, controlId, modifyCourseId, false);
}
return newCourseControlId;
}
示例12: SetRelayParameters
public static void SetRelayParameters(EventDB eventDB, Id<Course> courseId, int numberTeams, int numberLegs)
{
Course course = eventDB.GetCourse(courseId);
course = (Course)course.Clone();
course.relayTeams = numberTeams;
course.relayLegs = numberLegs;
eventDB.ReplaceCourse(courseId, course);
}
示例13: RemoveCourseControl
// Remove a control from a course. Caller must ensure the current is actually in this course.
// Returns a list of all control points that were deleted. This will include the one asked to remove,
// but might also remove others if it starts a fork or loop.
public static ICollection<Id<ControlPoint>> RemoveCourseControl(EventDB eventDB, Id<Course> courseId, Id<CourseControl> courseControlIdRemove)
{
Course course = eventDB.GetCourse(courseId);
List<Id<CourseControl>> allCourseControls = QueryEvent.EnumCourseControlIds(eventDB, new CourseDesignator(courseId)).ToList();
// This the course control to change to. Could be None.
CourseControl courseControlRemove = eventDB.GetCourseControl(courseControlIdRemove);
Id<CourseControl> afterRemove = courseControlRemove.nextCourseControl;
if (courseControlRemove.split && !courseControlRemove.loop) {
// Change next to another one of the split controls.
if (courseControlRemove.splitCourseControls[0] == courseControlIdRemove)
afterRemove = courseControlRemove.splitCourseControls[1];
else
afterRemove = courseControlRemove.splitCourseControls[0];
}
// For each course control, go throught and change referecnes to the subsequent control.
foreach (Id<CourseControl> courseControlId in allCourseControls) {
bool changed = false;
CourseControl courseControl = eventDB.GetCourseControl(courseControlId);
CourseControl clone = (CourseControl)courseControl.Clone();
if (courseControl.nextCourseControl == courseControlIdRemove) {
changed = true;
clone.nextCourseControl = afterRemove;
}
if (courseControl.split && courseControl.splitEnd == courseControlIdRemove) {
changed = true;
clone.splitEnd = afterRemove;
if (afterRemove.IsNone) {
clone.split = false; // No join control means we remove the split entirely.
clone.splitCourseControls = null;
}
}
if (clone.split && clone.splitCourseControls.Contains(courseControlIdRemove)) {
changed = true;
clone.splitCourseControls = clone.splitCourseControls.Where(id => id != courseControlIdRemove).ToArray();
if (clone.splitCourseControls.Length < 2) {
clone.split = false;
clone.loop = false;
clone.splitCourseControls = null;
clone.splitEnd = Id<CourseControl>.None;
}
}
if (changed) {
eventDB.ReplaceCourseControl(courseControlId, clone);
}
}
if (course.firstCourseControl == courseControlIdRemove) {
// Special case -- remove the first course control.
course = (Course) course.Clone();
course.firstCourseControl = afterRemove;
eventDB.ReplaceCourse(courseId, course);
}
// Remove a split could orphan more than one control. Go through and find orphaned ones.
HashSet<Id<CourseControl>> newCourseControls = new HashSet<Id<CourseControl>>(QueryEvent.EnumCourseControlIds(eventDB, new CourseDesignator(courseId)));
List<Id<CourseControl>> removedCourseControls = new List<Id<CourseControl>>();
HashSet<Id<ControlPoint>> removedControls = new HashSet<Id<ControlPoint>>();
foreach (Id<CourseControl> courseControlId in allCourseControls) {
if (!newCourseControls.Contains(courseControlId)) {
removedControls.Add(eventDB.GetCourseControl(courseControlId).control);
removedCourseControls.Add(courseControlId);
eventDB.RemoveCourseControl(courseControlId);
}
}
if (! removedCourseControls.Contains(courseControlIdRemove)) {
Debug.Fail("Did not remove the course control we were removing.");
}
return removedControls;
}
示例14: AddFinishToCourse
// Add a finish control to a given course. If the course already has a finish control as the last control, replace it.
// Otherwise add it as the new finish control. The returned CourseControl may be new, or may be the last control with
// a different control point.
// If addToOtherCourses is true, the new finish control is also added to all courses without an existing finish control.
public static Id<CourseControl> AddFinishToCourse(EventDB eventDB, Id<ControlPoint> controlId, Id<Course> courseId, bool addToOtherCourses)
{
Course course = eventDB.GetCourse(courseId);
Id<CourseControl> lastId = QueryEvent.LastCourseControl(eventDB, courseId, false);
Id<CourseControl> newCourseControlId;
if (lastId.IsNone) {
// No controls in the course. add this as the only control in the course.
newCourseControlId = eventDB.AddCourseControl(new CourseControl(controlId, Id<CourseControl>.None));
course = (Course) course.Clone();
course.firstCourseControl = newCourseControlId;
eventDB.ReplaceCourse(courseId, course);
}
else if (eventDB.GetControl(eventDB.GetCourseControl(lastId).control).kind == ControlPointKind.Finish) {
// Last control exists and is a finish control. Replace it.
CourseControl last = (CourseControl) eventDB.GetCourseControl(lastId).Clone();
last.control = controlId;
eventDB.ReplaceCourseControl(lastId, last);
newCourseControlId = lastId;
}
else {
// Last control exist but is not a finish. Add the finish onto it.
newCourseControlId = eventDB.AddCourseControl(new CourseControl(controlId, Id<CourseControl>.None));
CourseControl last = (CourseControl) eventDB.GetCourseControl(lastId).Clone();
last.nextCourseControl = newCourseControlId;
eventDB.ReplaceCourseControl(lastId, last);
}
if (addToOtherCourses) {
List<Id<Course>> courseModificationList = new List<Id<Course>>();
// Check all courses to see if we should add the finish to that course too.
foreach (Id<Course> courseSearchId in eventDB.AllCourseIds) {
if (!QueryEvent.HasFinishControl(eventDB, courseSearchId)) {
// This course does not have a finish control.
courseModificationList.Add(courseSearchId);
}
}
// Add the finish control to each of those courses.
foreach (Id<Course> modifyCourseId in courseModificationList)
AddFinishToCourse(eventDB, controlId, modifyCourseId, false);
}
return newCourseControlId;
}