private TopologyDropTargetCourseObj FindNearbyDropTarget(PointF location) { const float MAXDISTANCE = 9F; const float MINDRAGDIST = 5F; CourseLayout layout = selectionMgr.TopologyLayout; TopologyDropTargetCourseObj nearest = null; Id <CourseControl> courseControlDrag = courseObjectDrag.courseControlId; float nearestDistance = float.MaxValue; // Find nearest drop target that is within MAXDISTANCE of location, and not adjacent to the // course control we are dragging. foreach (CourseObj obj in layout) { TopologyDropTargetCourseObj dropTarget = obj as TopologyDropTargetCourseObj; if (dropTarget != null && ((dropTarget.courseControlId != courseControlDrag && dropTarget.courseControlId2 != courseControlDrag) || courseObjectStart.DistanceFromPoint(dropTarget.location) > MINDRAGDIST)) { float distance = Geometry.DistanceF(location, dropTarget.location); if (distance < nearestDistance && distance < MAXDISTANCE) { nearestDistance = distance; nearest = dropTarget; } } } return(nearest); }
private void CreateLegBetweenControls(CourseView.ControlView controlView1, ControlPosition controlPosition1, CourseView.ControlView controlView2, ControlPosition controlPosition2, int splitLegIndex, ForkPosition forkStart) { List <DropTarget> dropTargets; SymPath path = PathBetweenControls(controlPosition1, controlPosition2, forkStart, out dropTargets); CourseObj courseObj = new TopologyLegCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0], courseObjRatio, appearance, path); CourseLayer layer; if (LegInSpecificVariation(controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0])) { layer = courseLayerSpecificVariation; } else { layer = courseLayerAllVariationsAndParts; } courseObj.layer = layer; courseLayout.AddCourseObject(courseObj); // No drop targets between map issue and start. if (!(eventDB.GetControl(controlView1.controlId).kind == ControlPointKind.MapIssue && eventDB.GetControl(controlView2.controlId).kind == ControlPointKind.Start)) { // Add the drop targets foreach (DropTarget dropTarget in dropTargets) { courseObj = new TopologyDropTargetCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0], courseObjRatio, appearance, LocationFromAbstractPosition(dropTarget.abstractX, dropTarget.abstractY), dropTarget.insertionLoc); // Along the selected leg, show the drop targets in light gray. Along other legs, drop targets are invisible. if (controlView1.courseControlIds[splitLegIndex] == courseControlIdSelection1 && controlView2.courseControlIds.Contains(courseControlIdSelection2)) { courseObj.layer = CourseLayer.AllVariations; } else { courseObj.layer = CourseLayer.InvisibleObjects; } courseLayout.AddCourseObject(courseObj); } } if (forkStart != null && forkStart.variationCode != '\0') { // There is a variation fork. courseObj = CreateVariationCode(controlView1, controlPosition1, splitLegIndex, forkStart); courseLayout.AddCourseObject(courseObj); } }
public override void LeftButtonEndDrag(Pane pane, PointF location, PointF locationStart, float pixelSize, ref bool displayUpdateNeeded) { Debug.Assert(pane == Pane.Topology); TopologyDropTargetCourseObj dropAt = FindNearbyDropTarget(location); if (dropTargetHighlight != null) { Id <CourseControl> courseControlToMove = courseObjectStart.courseControlId; Id <CourseControl> courseControlDest1 = dropAt.courseControlId; Id <CourseControl> courseControlDest2 = dropAt.courseControlId2; controller.RearrangeControl(courseControlToMove, courseControlDest1, courseControlDest2, dropAt.InsertionLoc); } dropTargetHighlight = null; displayUpdateNeeded = true; controller.DefaultCommandMode(); }
public void DropTargetOffset() { CourseObj courseobj = new TopologyDropTargetCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new PointF(0, 0)); SingleObjectOffset(courseobj, "droptarget_offset"); }