// Update currentObj to reflect dragging to the given location. void DragTo(PointF location) { currentObj = (BasicTextCourseObj) startingObj.Clone(); currentObj.MoveHandle(handleDragging, location); }
// 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; }
public override MapViewer.DragAction LeftButtonDown(Pane pane, PointF location, float pixelSize, ref bool displayUpdateNeeded) { if (pane != Pane.Map) return MapViewer.DragAction.None; // Begin dragging out the description block. startLocation = location; startingObj = new BasicTextCourseObj(Id<Special>.None, displayText, new RectangleF(location, new SizeF(0.001F, 0.001F)), fontName, Util.GetFontStyle(fontBold, fontItalic), fontColor); handleDragging = location; DragTo(location); displayUpdateNeeded = true; return MapViewer.DragAction.DelayedDrag; // Also allow a click. }