Пример #1
0
        CourseObj[] additionalHighlights;  // additional highlights to show also, for legs to/from control.

        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;
        }
 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;
 }
        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;
        }
Пример #4
0
 // Update currentObj to reflect dragging to the given location.
 void DragTo(PointF location)
 {
     currentObj = (RectCourseObj)startingObj.Clone();
     currentObj.MoveHandle(handleDragging, location);
 }
Пример #5
0
        public override void LeftButtonDrag(Pane pane, PointF location, PointF locationStart, float pixelSize, ref bool displayUpdateNeeded)
        {
            Debug.Assert(pane == Pane.Map);

            currentLocation = location;

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

            // If we're dragging a control in a course (not all controls) then add additional highlights for the leg(s) to/from the control.
            if (AreDraggingControlPoint() && courseObjectStart.courseControlId.IsNotNone)
            {
                ControlPoint control    = eventDB.GetControl(courseObjectStart.controlId);
                CourseView   courseView = selectionMgr.ActiveCourseView;

                // Find index of this course control in the course view.
                int index;
                for (index = 0; index < courseView.ControlViews.Count; ++index)
                {
                    if (courseView.ControlViews[index].courseControlIds.Contains(courseObjectStart.courseControlId))
                    {
                        break;
                    }
                }

                if (index < courseView.ControlViews.Count)
                {
                    // Get previous and next controls.
                    int prevIndex = courseView.GetPrevControl(index), nextIndex = courseView.GetNextControl(index);
                    Id <CourseControl> prevCourseControl = (prevIndex >= 0) ? courseView.ControlViews[prevIndex].courseControlIds[0] : Id <CourseControl> .None;
                    Id <CourseControl> nextCourseControl = (nextIndex >= 0) ? courseView.ControlViews[nextIndex].courseControlIds[0] : Id <CourseControl> .None;

                    // Get additional highlights to and from those controls.
                    additionalHighlights = AddControlMode.CreateLegHighlights(eventDB, ((PointCourseObj)courseObjectDrag).location, courseObjectDrag.controlId, control.kind, prevCourseControl, nextCourseControl,
                                                                              courseView.CourseObjRatio(courseObjectStart.appearance), courseObjectStart.appearance);

                    // If we're dragging the start, update the angle of the start appropriately.
                    if ((control.kind == ControlPointKind.Start || control.kind == ControlPointKind.MapExchange || control.kind == ControlPointKind.MapIssue) &&
                        additionalHighlights.Length > 0 &&
                        (courseView.Kind == CourseView.CourseViewKind.Normal || courseView.Kind == CourseView.CourseViewKind.AllVariations))
                    {
                        SymPath  pathFromStart = ((LineCourseObj)additionalHighlights[additionalHighlights.Length - 1]).path;
                        PointF[] pts           = pathFromStart.FlattenedPoints;
                        double   angleOut      = Math.Atan2(pts[1].Y - pts[0].Y, pts[1].X - pts[0].X);
                        if (!double.IsNaN(angleOut))
                        {
                            float angleInDegrees = (float)Geometry.RadiansToDegrees(angleOut);
                            if (control.kind == ControlPointKind.MapIssue)
                            {
                                ((MapIssueCourseObj)courseObjectDrag).orientation = angleInDegrees;
                            }
                            else
                            {
                                ((StartCourseObj)courseObjectDrag).orientation = angleInDegrees;
                            }
                        }
                    }
                }
            }

            displayUpdateNeeded = true;
        }
Пример #6
0
        // Render to a bitmap and check against the saved version.
        internal void CheckOffsetBitmap(CourseObj courseobj, string basename, Color backColor)
        {
            CourseObj offset = (CourseObj) (courseobj.Clone());
            offset.Offset(-1F, -0.5F);

            Bitmap bmNew = RenderToBitmap(courseobj, backColor);
            Matrix matrix = GetTransform(bmNew.Size);

            using (Graphics g = Graphics.FromImage(bmNew)) {
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
                offset.DrawHighlight(g, matrix);
            }
            TestUtil.CheckBitmapsBase(bmNew, "coursesymbols\\" + basename);
        }