CrossingCourseObj courseObj; // object to modify. #endregion Fields #region Constructors public RotateMode(Controller controller, CrossingCourseObj courseObj) { this.controller = controller; this.courseObj = (CrossingCourseObj) courseObj.Clone(); }
// Change the orientation of the crossing point course object to the given angle in degrees. private void RotateToAngle(PointF point) { double angleInRadians = Math.Atan2(point.Y - courseObj.location.Y, point.X - courseObj.location.X); float angleInDegrees = (float) Geometry.RadiansToDegrees(angleInRadians); courseObj = (CrossingCourseObj) courseObj.Clone(); courseObj.ChangeOrientation(angleInDegrees); }
// Create the course objects associated with this special. Assign the given layer to it. static CourseObj CreateSpecial(EventDB eventDB, CourseView courseView, float scaleRatio, CourseAppearance appearance, Id<Special> specialId, CourseLayer normalLayer) { Special special = eventDB.GetSpecial(specialId); CourseObj courseObj = null; switch (special.kind) { case SpecialKind.FirstAid: courseObj = new FirstAidCourseObj(specialId, scaleRatio, appearance, special.locations[0]); break; case SpecialKind.Water: courseObj = new WaterCourseObj(specialId, scaleRatio, appearance, special.locations[0]); break; case SpecialKind.OptCrossing: courseObj = new CrossingCourseObj(Id<ControlPoint>.None, Id<CourseControl>.None, specialId, scaleRatio, appearance, special.orientation, special.locations[0]); break; case SpecialKind.Forbidden: courseObj = new ForbiddenCourseObj(specialId, scaleRatio, appearance, special.locations[0]); break; case SpecialKind.RegMark: courseObj = new RegMarkCourseObj(specialId, scaleRatio, appearance, special.locations[0]); break; case SpecialKind.Boundary: courseObj = new BoundaryCourseObj(specialId, scaleRatio, appearance, new SymPath(special.locations)); break; case SpecialKind.Rectangle: courseObj = new RectSpecialCourseObj(specialId, appearance, special.color, special.lineKind, special.lineWidth, special.cornerRadius, special.gapSize, special.dashSize, Geometry.RectFromPoints(special.locations[0], special.locations[1])); break; case SpecialKind.Line: courseObj = new LineSpecialCourseObj(specialId, appearance, special.color, special.lineKind, special.lineWidth, special.gapSize, special.dashSize, new SymPath(special.locations)); break; case SpecialKind.OOB: courseObj = new OOBCourseObj(specialId, scaleRatio, appearance, special.locations); break; case SpecialKind.Dangerous: courseObj = new DangerousCourseObj(specialId, scaleRatio, appearance, special.locations); break; case SpecialKind.WhiteOut: courseObj = new WhiteOutCourseObj(specialId, scaleRatio, appearance, special.locations); break; case SpecialKind.Image: Special imageSpecial = eventDB.GetSpecial(specialId); courseObj = new ImageCourseObj(specialId, scaleRatio, appearance, special.locations, imageSpecial.text, imageSpecial.imageBitmap); break; case SpecialKind.Text: string text = ExpandText(eventDB, courseView, special.text); FontStyle fontStyle = Util.GetFontStyle(special.fontBold, special.fontItalic); RectangleF boundingRect = RectangleF.FromLTRB((float)Math.Min(special.locations[0].X, special.locations[1].X), (float)Math.Min(special.locations[0].Y, special.locations[1].Y), (float)Math.Max(special.locations[0].X, special.locations[1].X), (float)Math.Max(special.locations[0].Y, special.locations[1].Y)); courseObj = new BasicTextCourseObj(specialId, text, boundingRect, special.fontName, fontStyle, special.color); break; case SpecialKind.Descriptions: Debug.Fail("description specials should not be passed to this function"); return null; default: Debug.Fail("bad special kind"); return null; } courseObj.layer = normalLayer; return courseObj; }
private void CreateControlNumber(CourseView.ControlView controlView, ControlPosition controlPosition) { Id<ControlPoint> controlId = controlView.controlId; Id<CourseControl> courseControlId = controlView.courseControlIds[0]; ControlPoint control = eventDB.GetControl(controlId); PointF location = LocationFromAbstractPosition(controlPosition.x, controlPosition.y); CourseLayer layer; if (ControlViewInSpecificVariation(controlView)) layer = courseLayerSpecificVariation; else layer = courseLayerAllVariationsAndParts; CourseObj courseObj; switch (control.kind) { case ControlPointKind.Start: case ControlPointKind.MapExchange: // Triangle looks best if we displace it down a bit (0.8 looks right). courseObj = new StartCourseObj(controlId, courseControlId, scaleRatio * 0.75F, appearance, 0, new PointF(location.X, location.Y - 0.8F), CrossHairOptions.NoCrossHair); break; case ControlPointKind.Finish: courseObj = new FinishCourseObj(controlId, courseControlId, scaleRatio * 0.75F, appearance, null, location, CrossHairOptions.NoCrossHair); break; case ControlPointKind.Normal: courseObj = new ControlNumberCourseObj(controlId, courseControlId, scaleRatio, appearance, control.code, location); break; case ControlPointKind.CrossingPoint: courseObj = new CrossingCourseObj(controlId, courseControlId, Id<Special>.None, scaleRatio * 1.5F, appearance, 0, location); break; default: Debug.Fail("bad control kind"); return; } courseObj.layer = layer; courseLayout.AddCourseObject(courseObj); }
static CourseObj CreateCourseObject(EventDB eventDB, float scaleRatio, CourseAppearance appearance, float printScale, Id<ControlPoint> controlId, Id<CourseControl> courseControlId, double angleOut) { ControlPoint control = eventDB.GetControl(controlId); CircleGap[] gaps = QueryEvent.GetControlGaps(eventDB, controlId, printScale); CourseObj courseObj = null; switch (control.kind) { case ControlPointKind.Start: case ControlPointKind.MapExchange: courseObj = new StartCourseObj(controlId, courseControlId, scaleRatio, appearance, double.IsNaN(angleOut) ? 0 : (float)Geometry.RadiansToDegrees(angleOut), control.location, CrossHairOptions.HighlightCrossHair); break; case ControlPointKind.Finish: courseObj = new FinishCourseObj(controlId, courseControlId, scaleRatio, appearance, gaps, control.location, CrossHairOptions.HighlightCrossHair); break; case ControlPointKind.Normal: courseObj = new ControlCourseObj(controlId, courseControlId, scaleRatio, appearance, gaps, control.location); break; case ControlPointKind.CrossingPoint: courseObj = new CrossingCourseObj(controlId, courseControlId, Id<Special>.None, scaleRatio, appearance, control.orientation, control.location); break; default: Debug.Fail("bad control kind"); return null; } return courseObj; }