Inheritance: IMapViewerHighlight, ICloneable
        public override void LeftButtonCancelDrag(Pane pane, ref bool displayUpdateNeeded)
        {
            Debug.Assert(pane == Pane.Topology);

            // Drag was cancelled. Go back to normal mode.
            dropTargetHighlight = null;
            displayUpdateNeeded = true;

            controller.DefaultCommandMode();
        }
 public TopologyDragControlMode(Controller controller, EventDB eventDB, SelectionMgr selectionMgr, CourseObj courseObject, PointF startDrag, PointF currentLocation)
 {
     this.controller = controller;
     this.eventDB = eventDB;
     this.selectionMgr = selectionMgr;
     this.courseObjectStart = courseObject;
     this.courseObjectDrag = (CourseObj)(courseObject.Clone());
     this.startDrag = startDrag;
     this.currentLocation = currentLocation;
     this.dropTargetHighlight = null;
 }
Example #3
0
 // Select a course object in the current displayed course.
 public void SelectCourseObject(CourseObj courseObject)
 {
     if (courseObject is ControlCourseObj || courseObject is StartCourseObj || courseObject is FinishCourseObj ||
         (courseObject is CrossingCourseObj && courseObject.specialId.IsNone) || courseObject is CodeCourseObj || courseObject is ControlNumberCourseObj)
     {
         SetSelection(SelectionKind.Control, courseObject.courseControlId, Id<CourseControl>.None, courseObject.controlId, Id<Special>.None, null, DescriptionLine.TextLineKind.None);
     }
     else if (courseObject.specialId.IsNotNone) {
         SetSelection(SelectionKind.Special, Id<CourseControl>.None, Id<CourseControl>.None, Id<ControlPoint>.None, courseObject.specialId, null, DescriptionLine.TextLineKind.None);
     }
     else if (courseObject is LegCourseObj || courseObject is FlaggedLegCourseObj || courseObject is TopologyLegCourseObj) {
         SetSelection(SelectionKind.Leg, courseObject.courseControlId, ((LineCourseObj) courseObject).courseControlId2, courseObject.controlId, Id<Special>.None, null, DescriptionLine.TextLineKind.None);
     }
 }
 // Describe a course object, and return an array of TextParts for display in the UI. Return null if nothing useful
 // can be said.
 public static TextPart[] DescribeCourseObject(SymbolDB symbolDB, EventDB eventDB, CourseObj courseObj, float scaleRatio)
 {
     if (courseObj is LineCourseObj && courseObj.courseControlId.IsNotNone && ((LineCourseObj)courseObj).courseControlId2.IsNotNone) {
         return DescribeLeg(eventDB, courseObj.courseControlId, ((LineCourseObj)courseObj).courseControlId2, DescKind.Tooltip);
     }
     else if (courseObj.controlId.IsNotNone) {
         return DescribeControlPoint(symbolDB, eventDB, courseObj.controlId, DescKind.Tooltip);
     }
     else if (courseObj.specialId.IsNotNone) {
         return DescribeSpecial(eventDB, courseObj.specialId, scaleRatio, DescKind.Tooltip);
     }
     else {
         return null;
     }
 }
Example #5
0
 public override IMapViewerHighlight[] GetHighlights(Pane pane)
 {
     if (pane == Pane.Map) {
         if (highlight != null) {
             if (additionalHighlights != null && additionalHighlights.Length > 0) {
                 CourseObj[] highlights = new CourseObj[additionalHighlights.Length + 1];
                 highlights[0] = highlight;
                 Array.Copy(additionalHighlights, 0, highlights, 1, additionalHighlights.Length);
                 return highlights;
             }
             else {
                 return new CourseObj[] { highlight };
             }
         }
         else
             return null;
     }
     else {
         return null;
     }
 }
Example #6
0
 // Update currentObj to reflect dragging to the given location.
 void DragTo(PointF location)
 {
     currentObj = (RectCourseObj)startingObj.Clone();
     currentObj.MoveHandle(handleDragging, location);
 }
Example #7
0
        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 image.
            startLocation = location;
            startingObj = createCourseObj(new RectangleF(location.X, location.Y, 0.001F, 0.001F * aspectRatio));
            handleDragging = location;
            DragTo(location);
            displayUpdateNeeded = true;
            return MapViewer.DragAction.DelayedDrag;  // Also allow a click.
        }
        public override void LeftButtonDrag(Pane pane, PointF location, PointF locationStart, float pixelSize, ref bool displayUpdateNeeded)
        {
            Debug.Assert(pane == Pane.Topology);

            currentLocation = location;

            // Update the highlight.
            courseObjectDrag = ((CourseObj)courseObjectStart.Clone());
            courseObjectDrag.Offset(location.X - startDrag.X, location.Y - startDrag.Y);

            dropTargetHighlight = FindNearbyDropTarget(location);

            displayUpdateNeeded = true;
        }
        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, false);
            }

            dropTargetHighlight = null;
            displayUpdateNeeded = true;
            controller.DefaultCommandMode();
        }
Example #10
0
        // Create the objects associated with the leg from controlView1 to controlView2. Could be multiple because
        // a leg may be partly flagged, and so forth. Gaps do not create separate course objects.
        private static CourseObj[] CreateLeg(EventDB eventDB, float scaleRatio, CourseAppearance appearance, Id<CourseControl> courseControlId1, CourseView.ControlView controlView1, CourseView.ControlView controlView2, Id<Leg> legId)
        {
            ControlPoint control1 = eventDB.GetControl(controlView1.controlId);
            ControlPoint control2 = eventDB.GetControl(controlView2.controlId);
            Leg leg = (legId.IsNotNone) ? eventDB.GetLeg(legId) : null;
            List<SymPath> paths = new List<SymPath>();     // paths for each segment of the leg.
            List<LegGap[]> gapsList = new List<LegGap[]>();     // gaps for each segment of the leg.
            List<bool> isFlagged = new List<bool>();             // indicates if each segment is flagged or not.

            LegGap[] gaps;                // What kind of gaps are present? Null array if none

            // Get the path of the line, and the gaps.
            SymPath legPath = GetLegPath(eventDB,
                                         control1.location, controlView1.hiddenControl ? ControlPointKind.None : control1.kind, controlView1.controlId,
                                         control2.location, controlView2.hiddenControl ? ControlPointKind.None : control2.kind, controlView2.controlId,
                                         scaleRatio, appearance, out gaps);
            if (legPath == null)
                return null;

            // What kind of flagging does this leg have (none/full/begin/end)?
            FlaggingKind flagging = QueryEvent.GetLegFlagging(eventDB, controlView1.controlId, controlView2.controlId, legId);

            // Based on flagging kind, set up the paths/isFlagged lists. Add in gaps as part of it.
            if (flagging == FlaggingKind.Begin || flagging == FlaggingKind.End) {
                // Flagging is partial. We need to split the path into two.
                SymPath beginPath, endPath;
                legPath.Split(leg.flagStartStop, out beginPath, out endPath);

                paths.Add(beginPath);
                gapsList.Add(gaps);
                isFlagged.Add(flagging == FlaggingKind.Begin);

                // Update gaps for the end part.
                if (gaps != null) {
                    gaps = (LegGap[]) gaps.Clone();
                    for (int i = 0; i < gaps.Length; ++i)
                        gaps[i].distanceFromStart -= beginPath.Length;
                }

                paths.Add(endPath);
                gapsList.Add(gaps);
                isFlagged.Add(flagging == FlaggingKind.End);
            }
            else {
                // flagging is not partial. A single path is OK.
                paths.Add(legPath);
                gapsList.Add(gaps);
                isFlagged.Add(flagging == FlaggingKind.All);
            }

            // Create course objects for this leg from the paths/isFlagged lists.
            CourseObj[] objs = new CourseObj[paths.Count];
            for (int i = 0; i < paths.Count; ++i) {
                if (isFlagged[i])
                    objs[i] = new FlaggedLegCourseObj(controlView1.controlId, courseControlId1, controlView2.courseControlIds[0], scaleRatio, appearance, paths[i], gapsList[i]);
                else
                    objs[i] = new LegCourseObj(controlView1.controlId, courseControlId1, controlView2.courseControlIds[0], scaleRatio, appearance, paths[i], gapsList[i]);
            }

            return objs;
        }
Example #11
0
 public DeleteCornerMode(Controller controller, CourseObj courseObject)
 {
     this.controller = controller;
     this.courseObject = courseObject;
 }
Example #12
0
        public override IMapViewerHighlight[] GetHighlights(Pane pane)
        {
            if (pane != Pane.Map)
                return null;

            if (additionalHighlights != null && additionalHighlights.Length > 0) {
                CourseObj[] highlights = new CourseObj[additionalHighlights.Length + 1];
                highlights[0] = courseObjectDrag;
                Array.Copy(additionalHighlights, 0, highlights, 1, additionalHighlights.Length);
                return highlights;
            }
            else {
                return new CourseObj[] { courseObjectDrag };
            }
        }
Example #13
0
 public DragObjectMode(Controller controller, EventDB eventDB, SelectionMgr selectionMgr, CourseObj courseObject, PointF startDrag)
 {
     this.controller = controller;
     this.eventDB = eventDB;
     this.selectionMgr = selectionMgr;
     this.courseObjectStart = courseObject;
     this.courseObjectDrag = (CourseObj) (courseObject.Clone());
     this.startDrag = this.currentLocation = startDrag;
 }
Example #14
0
 public DragHandleMode(Controller controller, CourseObj courseObject, PointF handleLocation, PointF startDrag)
 {
     this.controller = controller;
     this.courseObjectStart = courseObject;
     this.courseObjectDrag = (CourseObj) (courseObject.Clone());
     this.handleLocation = handleLocation;
     this.handleCursor = courseObject.GetHandleCursor(handleLocation);
     this.startDrag = this.currentLocation = startDrag;
 }
Example #15
0
 // Is this course object selectable?
 bool SelectableObject(CourseObj courseObject)
 {
     // All course objects are selectable.
     return courseObject != null;
 }
Example #16
0
        // Is this course object draggable?
        bool DraggableObject(CourseObj courseObject)
        {
            // Legs are not draggable.
            if (courseObject == null || (courseObject is LegCourseObj) || (courseObject is FlaggedLegCourseObj))
                return false;

            // Everything else is draggable.
            return true;
        }