Esempio n. 1
0
        void WriteSingleCourseVariation(CourseDesignator courseDesignator, string courseName, int courseNumber, string[] classNames, bool isScore, int variationNumber, VariationInfo variationInfo)
        {
            float distanceThisLeg = 0;
            int   sequenceNumber  = 1;  // score courses need sequence #'s, even though there is no sequence.

            CourseView courseView = CourseView.CreateViewingCourseView(eventDB, courseDesignator);

            WriteCourseStart(courseView, courseName, courseNumber, classNames, isScore, variationNumber, variationInfo);

            // Go through the control views.
            int controlViewIndex = 0;

            while (controlViewIndex >= 0 && controlViewIndex < courseView.ControlViews.Count)
            {
                CourseView.ControlView controlView = courseView.ControlViews[controlViewIndex];
                ControlPointKind       kind        = eventDB.GetControl(controlView.controlId).kind;

                WriteCourseControl(kind, controlView, isScore, ref sequenceNumber, ref distanceThisLeg);

                if (controlView.legLength != null)
                {
                    distanceThisLeg += controlView.legLength[0];
                }

                if (isScore)
                {
                    ++controlViewIndex;
                }
                else
                {
                    controlViewIndex = courseView.GetNextControl(controlViewIndex);
                }
            }

            WriteCourseEnd();
        }
Esempio n. 2
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;
        }