Exemple #1
0
        // Left mouse button selects the object clicked on, or drag something already selected.
        public override MapViewer.DragAction LeftButtonDown(Pane pane, PointF location, float pixelSize, ref bool displayUpdateNeeded)
        {
            if (pane == Pane.Map)
            {
                CourseLayout activeCourse = controller.GetCourseLayout();
                CourseObj    clickedObject;
                PointF       handleLocation;
                Cursor       handleCursor;

                // Area we initiating a drag of a corner?
                clickedObject = HitTestHandle(location, pixelSize, out handleLocation, out handleCursor);
                if (clickedObject != null)
                {
                    // being dragging the corner
                    DragHandleMode commandMode = new DragHandleMode(controller, clickedObject, handleLocation, location);
                    controller.SetCommandMode(commandMode);
                    displayUpdateNeeded = true;
                    return(MapViewer.DragAction.ImmediateDrag);
                }

                // Are we initiating a drag of an object?
                clickedObject = HitTestDraggable(location, pixelSize);
                if (clickedObject != null)
                {
                    // Begin dragging the clicked object.
                    DragObjectMode commandMode = new DragObjectMode(controller, eventDB, selectionMgr, clickedObject, location);
                    controller.SetCommandMode(commandMode);
                    displayUpdateNeeded = true;
                    return(MapViewer.DragAction.ImmediateDrag);
                }

                return(MapViewer.DragAction.DelayedDrag);
            }
            else if (pane == Pane.Topology)
            {
                CourseObj clickedObject = HitTest(pane, location, pixelSize, (co => !(co is TopologyDropTargetCourseObj)));
                if (clickedObject is ControlNumberCourseObj || clickedObject is CrossingCourseObj ||
                    (clickedObject is StartCourseObj && (eventDB.GetControl(((StartCourseObj)clickedObject).controlId).kind == ControlPointKind.MapExchange)))
                {
                    // Can drag control numbers, crossing points, or map exchanges.
                    selectionMgr.SelectCourseObject(clickedObject);
                    displayUpdateNeeded = true;
                    return(MapViewer.DragAction.DelayedDrag);
                }
            }

            return(MapViewer.DragAction.None);
        }
Exemple #2
0
        // Left mouse button selects the object clicked on, or drag something already selected.
        public override MapViewer.DragAction LeftButtonDown(Pane pane, PointF location, float pixelSize, ref bool displayUpdateNeeded)
        {
            if (pane == Pane.Map) {
                CourseLayout activeCourse = controller.GetCourseLayout();
                CourseObj clickedObject;
                PointF handleLocation;
                Cursor handleCursor;

                // Area we initiating a drag of a corner?
                clickedObject = HitTestHandle(location, pixelSize, out handleLocation, out handleCursor);
                if (clickedObject != null) {
                    // being dragging the corner
                    DragHandleMode commandMode = new DragHandleMode(controller, clickedObject, handleLocation, location);
                    controller.SetCommandMode(commandMode);
                    displayUpdateNeeded = true;
                    return MapViewer.DragAction.ImmediateDrag;
                }

                // Are we initiating a drag of an object?
                clickedObject = HitTestDraggable(location, pixelSize);
                if (clickedObject != null) {
                    // Begin dragging the clicked object.
                    DragObjectMode commandMode = new DragObjectMode(controller, eventDB, selectionMgr, clickedObject, location);
                    controller.SetCommandMode(commandMode);
                    displayUpdateNeeded = true;
                    return MapViewer.DragAction.ImmediateDrag;
                }

                return MapViewer.DragAction.DelayedDrag;
            }
            else if (pane == Pane.Topology) {
                CourseObj clickedObject = HitTest(pane, location, pixelSize, (co => !(co is TopologyDropTargetCourseObj)));
                if (clickedObject is ControlNumberCourseObj || clickedObject is CrossingCourseObj ||
                    (clickedObject is StartCourseObj && (eventDB.GetControl(((StartCourseObj)clickedObject).controlId).kind == ControlPointKind.MapExchange)))
                {
                    // Can drag control numbers, crossing points, or map exchanges.
                    selectionMgr.SelectCourseObject(clickedObject);
                    displayUpdateNeeded = true;
                    return MapViewer.DragAction.DelayedDrag;
                }
            }

            return MapViewer.DragAction.None;
        }