예제 #1
0
        // Hit test a point to see if it is over an existing control, or will create a new control.
        Id <ControlPoint> HitTestPoint(PointF mouseLocation, float pixelSize, out PointF highlightLocation)
        {
            if (allControls)
            {
                // If all controls, always new control.
                highlightLocation = new PointF(mouseLocation.X + PIXELOFFSETX * pixelSize, mouseLocation.Y + PIXELOFFSETY * pixelSize);
                return(Id <ControlPoint> .None);
            }
            else
            {
                // Are we over a control we might add?
                CourseLayout   layout    = controller.GetCourseLayout();
                PointCourseObj courseObj = layout.HitTest(mouseLocation, pixelSize, CourseLayer.AllControls, (co => co is PointCourseObj)) as PointCourseObj;
                if (courseObj != null)
                {
                    highlightLocation = courseObj.location;
                    return(courseObj.controlId);
                }
                else
                {
                    courseObj = layout.HitTest(mouseLocation, pixelSize, CourseLayer.MainCourse, (co => co is PointCourseObj)) as PointCourseObj;
                    if (courseObj != null &&
                        courseObj.controlId.IsNotNone)
                    {
                        // Allow selecting a control in the current course for a butterfly course. But -- it must be a normal control or crossing point, and not adjacent to the control being inserted.
                        if (eventDB.GetControl(courseObj.controlId).kind == controlKind && (controlKind == ControlPointKind.Normal || controlKind == ControlPointKind.CrossingPoint))
                        {
                            Id <CourseControl> courseControl1, courseControl2;
                            CourseDesignator   courseDesignator;
                            LegInsertionLoc    legInsertionLoc;

                            GetControlInsertionPoint(courseObj.location, out courseDesignator, out courseControl1, out courseControl2, out legInsertionLoc);
                            if (eventDB.GetCourse(courseDesignator.CourseId).kind != CourseKind.Score &&
                                (exchangeAtControl ||
                                 (courseObj.courseControlId != courseControl1 && courseObj.courseControlId != courseControl2)))
                            {
                                highlightLocation = courseObj.location;
                                return(courseObj.controlId);
                            }
                        }
                    }

                    highlightLocation = new PointF(mouseLocation.X + PIXELOFFSETX * pixelSize, mouseLocation.Y + PIXELOFFSETY * pixelSize);
                    return(Id <ControlPoint> .None);
                }
            }
        }
예제 #2
0
        private CourseObj HitTest(Pane pane, PointF location, float pixelSize, Predicate <CourseObj> filter)
        {
            CourseLayout activeCourse = (pane == Pane.Map) ? controller.GetCourseLayout() : controller.GetTopologyLayout();
            CourseObj    clickedObject;

            clickedObject = activeCourse.HitTest(location, pixelSize, CourseLayer.MainCourse, filter);
            if (clickedObject == null)
            {
                clickedObject = activeCourse.HitTest(location, pixelSize, CourseLayer.Descriptions, filter);
            }
            if (clickedObject == null && pane == Pane.Topology)
            {
                clickedObject = activeCourse.HitTest(location, pixelSize, CourseLayer.AllVariations, filter);
            }

            return(clickedObject);
        }