Ejemplo n.º 1
0
        // Create highlights to and from a point to course controls. If controlDrag is set (optional), it is
        // used to get the correct bends for legs.
        // Static because it is used from DragControlMode also.
        public static CourseObj[] CreateLegHighlights(EventDB eventDB, PointF newPoint, Id <ControlPoint> controlDrag, ControlPointKind controlKind, Id <CourseControl> courseControlId1, Id <CourseControl> courseControlId2, float courseObjRatio, CourseAppearance appearance)
        {
            List <CourseObj> highlights = new List <CourseObj>();

            if (courseControlId1.IsNotNone)
            {
                Id <ControlPoint> controlId1 = eventDB.GetCourseControl(courseControlId1).control;
                ControlPoint      control1   = eventDB.GetControl(controlId1);
                LegCourseObj      highlight  = CreateLegHighlight(eventDB, control1.location, control1.kind, controlId1, newPoint, controlKind, controlDrag, courseObjRatio, appearance);
                if (highlight != null)
                {
                    highlights.Add(highlight);
                }
            }

            if (courseControlId2.IsNotNone)
            {
                Id <ControlPoint> controlId2 = eventDB.GetCourseControl(courseControlId2).control;
                ControlPoint      control2   = eventDB.GetControl(controlId2);
                LegCourseObj      highlight  = CreateLegHighlight(eventDB, newPoint, controlKind, controlDrag, control2.location, control2.kind, controlId2, courseObjRatio, appearance);
                if (highlight != null)
                {
                    highlights.Add(highlight);
                }
            }

            return(highlights.ToArray());
        }
Ejemplo n.º 2
0
        public override void LeftButtonDrag(Pane pane, PointF location, PointF locationStart, float pixelSize, ref bool displayUpdateNeeded)
        {
            Debug.Assert(pane == Pane.Map);

            // Get the new set of gaps.
            LegGap[] newGaps = LegGap.AddGap(courseObjStart.path, courseObjStart.gaps, startDrag, location);

            // Put the new gaps into the highlight.
            courseObjDrag = new LegCourseObj(courseObjStart.controlId, courseObjStart.courseControlId, courseObjStart.courseControlId2,
                                             courseObjStart.courseObjRatio, courseObjStart.appearance, courseObjStart.path, newGaps);

            displayUpdateNeeded = true;
        }
Ejemplo n.º 3
0
 public AddLegGapMode(Controller controller, LegCourseObj courseObject)
 {
     this.controller     = controller;
     this.courseObjStart = courseObject;
     this.courseObjDrag  = (LegCourseObj)courseObject.Clone();
 }
Ejemplo n.º 4
0
 public void GappedLegSpecial()
 {
     CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, specialAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }),
                                           new LegGap[] { new LegGap(1.5F, 2.0F), new LegGap(6F, 1.4F), new LegGap(10F, 5F) });
     SingleObject(courseobj, "gapped_leg_special");
 }
Ejemplo n.º 5
0
        public void GetLegHandles()
        {
            CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), null);
            PointF[] handles = courseobj.GetHandles();
            PointF[] expected = { new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F) };

            Assert.AreEqual(expected.Length, handles.Length);
            for (int i = 0; i < handles.Length; ++i)
                Assert.AreEqual(expected[i], handles[i]);
        }
Ejemplo n.º 6
0
 public void MoveLineHandle()
 {
     CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), null);
     Console.WriteLine(courseobj.ToString());
     courseobj.MoveHandle(new PointF(-1, 1.5F), new PointF(3.1F, -1.3F));
     Assert.AreEqual(@"Leg:            scale:1  path:N(-3,-2)--N(3.1,-1.3)--N(2.5,1)--N(3,-2)", courseobj.ToString());
 }
Ejemplo n.º 7
0
 public void GappedLegHighlight()
 {
     CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }),
                                           new LegGap[] { new LegGap(1.5F, 2.0F), new LegGap(6F, 1.4F), new LegGap(10F, 5F) });
     SingleObjectHighlight(courseobj, "gapped_leg_highlight");
 }
Ejemplo n.º 8
0
        public void LineObjectEquals()
        {
            CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F)}), null);
            CourseObj courseobj2 = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F)}), null);
            CourseObj courseobj3 = new LegCourseObj(ControlId(1), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F)}), null);
            CourseObj courseobj4 = new LegCourseObj(ControlId(0), CourseControlId(1), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F)}), null);
            CourseObj courseobj5 = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(1), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F)}), null);
            CourseObj courseobj6 = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 0.5F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), null);
            CourseObj courseobj7 = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.6F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F)}), null);
            CourseObj courseobj8 = new FlaggedLegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F)}), null);
            CourseObj courseobj9 = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), new LegGap[] { new LegGap(2, 3) });
            CourseObj courseobj10 = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), new LegGap[] { new LegGap(2, 4) });
            CourseObj courseobj11 = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), new LegGap[] { new LegGap(2, 3) });

            Assert.AreEqual(courseobj, courseobj);
            Assert.AreEqual(courseobj, courseobj2);
            Assert.AreNotEqual(courseobj, courseobj3);
            Assert.AreNotEqual(courseobj, courseobj4);
            Assert.AreNotEqual(courseobj, courseobj5);
            Assert.AreNotEqual(courseobj, courseobj6);
            Assert.AreNotEqual(courseobj, courseobj7);
            Assert.AreNotEqual(courseobj, courseobj8);
            Assert.AreNotEqual(courseobj, courseobj9);
            Assert.AreNotEqual(courseobj, courseobj10);
            Assert.AreNotEqual(courseobj9, courseobj10);
            Assert.AreEqual(courseobj9, courseobj11);
        }
Ejemplo n.º 9
0
 public void LegSpecial()
 {
     CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, specialAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), null);
     SingleObject(courseobj, "normal_leg_special");
 }
Ejemplo n.º 10
0
 public void LegOffset()
 {
     CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[4] { new PointF(-3.0F, -2.0F), new PointF(-1.0F, 1.5F), new PointF(2.5F, 1.0F), new PointF(3.0F, -2.0F) }), null);
     SingleObjectOffset(courseobj, "normal_leg_offset");
 }
Ejemplo n.º 11
0
 public void LegDump()
 {
     CourseObj courseobj = new LegCourseObj(ControlId(17), CourseControlId(19), CourseControlId(22), 1.0F, defaultCourseAppearance, new SymPath(new PointF[3] { new PointF(3, 3), new PointF(1, 1), new PointF(4, 1) }), null);
     AssertDump(courseobj, @"Leg:            control:17  course-control:19  scale:1  course-control2:22  path:N(3,3)--N(1,1)--N(4,1)");
 }
Ejemplo n.º 12
0
 public void LegDistance()
 {
     CourseObj courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 1.0F, defaultCourseAppearance, new SymPath(new PointF[3] { new PointF(3, 3), new PointF(1, 1), new PointF(4, 1) }), null);
     Assert.AreEqual(Math.Round(1.414213 - 0.35/2.0, 3), Math.Round(courseobj.DistanceFromPoint(new PointF(1, 3)), 3));
     Assert.AreEqual(0.0, courseobj.DistanceFromPoint(new PointF(2.11F, 2.05F)));
     Assert.AreEqual(1 - 0.35 / 2.0, Math.Round(courseobj.DistanceFromPoint(new PointF(5,1)), 3));
     courseobj = new LegCourseObj(ControlId(0), CourseControlId(0), CourseControlId(0), 0.5F, defaultCourseAppearance, new SymPath(new PointF[3] { new PointF(3, 3), new PointF(1, 1), new PointF(4, 1) }), null);
     Assert.AreEqual(Math.Round(1.414213 - 0.35 / 4.0, 3), Math.Round(courseobj.DistanceFromPoint(new PointF(1, 3)), 3));
     Assert.AreEqual(0.0, courseobj.DistanceFromPoint(new PointF(2.11F, 2.08F)));
     Assert.AreEqual(Math.Round(1 - 0.35 / 4.0, 2), Math.Round(courseobj.DistanceFromPoint(new PointF(5, 1)), 2));
 }