public void AddLegGap3() { Setup("modes\\gappedlegs.coursescribe"); // Select course 1. controller.SelectTab(1); // Course 1. CheckHighlightedLines(controller, -1, -1); // Click on leg to select it. MapViewer.DragAction dragAction = controller.LeftButtonDown(Pane.Map, new PointF(20, -5), 0.3F); Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction); controller.LeftButtonClick(Pane.Map, new PointF(20, -5), 0.3F); // Begin the add gap mode. controller.BeginAddGap(); // Should have crosshair cursor ui.MouseMoved(32, -5, 0.3F); Cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(32, -5), 0.3F); Assert.AreSame(Cursors.Cross, cursor); // And the adding leg gap text. Assert.AreEqual(StatusBarText.AddingLegGap, controller.StatusText); // Check the highlights CourseObj[] highlights = (CourseObj[])controller.GetHighlights(Pane.Map); Assert.AreEqual(1, highlights.Length); Assert.AreEqual(@"Leg: control:2 course-control:2 scale:1 course-control2:3 path:N(35.72,-20.39)--N(10.18,5.49)", highlights[0].ToString()); // Click to add a gap. dragAction = controller.LeftButtonDown(Pane.Map, new PointF(30, -11), 0.3F); Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction); controller.LeftButtonClick(Pane.Map, new PointF(30, -11), 0.3F); // Check the status text ui.MouseMoved(12, -1, 0.1F); Assert.AreEqual(StatusBarText.DefaultStatus, controller.StatusText); // Check the cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(12, -1), 0.3F); Assert.AreSame(Cursors.Default, cursor); // Check the highlights highlights = (CourseObj[])controller.GetHighlights(Pane.Map); Assert.AreEqual(1, highlights.Length); Assert.AreEqual(@"Leg: control:2 course-control:2 scale:1 course-control2:3 path:N(35.72,-20.39)--N(10.18,5.49) gaps: (s:9.7,l:2)", highlights[0].ToString()); // Make sure the leg gap is added. Leg leg = eventDB.GetLeg(QueryEvent.FindLeg(eventDB, ControlId(2), ControlId(3))); Assert.AreEqual(1, leg.gaps.Length); Assert.AreEqual(12.52F, leg.gaps[0].distanceFromStart, 0.01F); Assert.AreEqual(2.0F, leg.gaps[0].length, 0.01F); }
public void RemoveControlGap() { Setup("modes\\speciallegs.ppen"); // Select course 1. controller.SelectTab(1); // Course 1. CheckHighlightedLines(controller, -1, -1); // Click on control 1 to select it. MapViewer.DragAction dragAction = controller.LeftButtonDown(Pane.Map, new PointF(38.6F, -21F), 0.3F); Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction); controller.LeftButtonClick(Pane.Map, new PointF(38.6F, -21F), 0.3F); // Begin the remove gap mode. controller.BeginRemoveGap(); // Should have crosshair cursor ui.MouseMoved(39.0F, -29F, 0.3F); Cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(39.0F, -29F), 0.3F); Assert.AreSame(Cursors.Cross, cursor); // And the adding bend text. Assert.AreEqual(StatusBarText.RemovingControlGap, controller.StatusText); // Check the highlights CourseObj[] highlights = (CourseObj[])controller.GetHighlights(Pane.Map); Assert.AreEqual(1, highlights.Length); Assert.AreEqual(@"Control: control:2 course-control:2 scale:1 location:(37.72384,-22.41992) gaps:112.5:146.25,258.75:303.75", highlights[0].ToString()); // Click to add a gap. dragAction = controller.LeftButtonDown(Pane.Map, new PointF(42.0F, -32F), 0.3F); Assert.AreEqual(MapViewer.DragAction.None, dragAction); // Check the status text ui.MouseMoved(42.0F, -32F, 0.1F); Assert.AreEqual(StatusBarText.DefaultStatus, controller.StatusText); // Check the cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(42.0F, -32F), 0.3F); Assert.AreSame(Cursors.Default, cursor); // Check the highlights highlights = (CourseObj[])controller.GetHighlights(Pane.Map); Assert.AreEqual(2, highlights.Length); Assert.AreEqual(@"Control: control:2 course-control:2 scale:1 location:(37.72384,-22.41992) gaps:112.5:146.25", highlights[0].ToString()); Assert.AreEqual(@"ControlNumber: control:2 course-control:2 scale:1 text:1 top-left:(35.72,-25.85) font-name:Roboto font-style:Regular font-height:5.57", highlights[1].ToString()); // Make sure the control has a new gap. ControlPoint control = eventDB.GetControl(ControlId(2)); CollectionAssert.AreEqual(CircleGap.ComputeCircleGaps(0xFFFFE3FF), control.gaps[10000]); }
public void AddLegGap2() { Setup("modes\\gappedlegs.coursescribe"); // Select course 1. controller.SelectTab(1); // Course 1. CheckHighlightedLines(controller, -1, -1); // Click on leg to select it. MapViewer.DragAction dragAction = controller.LeftButtonDown(Pane.Map, new PointF(71, 0), 0.3F); Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction); controller.LeftButtonClick(Pane.Map, new PointF(71, 0), 0.3F); // Begin the add gap mode. controller.BeginAddGap(); // Should have crosshair cursor ui.MouseMoved(72, 10, 0.3F); Cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(72, 10), 0.3F); Assert.AreSame(Cursors.Cross, cursor); // And the adding leg gap text. Assert.AreEqual(StatusBarText.AddingLegGap, controller.StatusText); // Check the highlights CourseObj[] highlights = (CourseObj[])controller.GetHighlights(Pane.Map); Assert.AreEqual(1, highlights.Length); Assert.AreEqual(@"Leg: control:1 course-control:1 scale:1 course-control2:2 path:N(73.43,10.02)--N(68,-22)--N(40.52,-22.36) gaps: (s:2.96,l:3.5) (s:20.96,l:9)", highlights[0].ToString()); // Click and drag add a gap. dragAction = controller.LeftButtonDown(Pane.Map, new PointF(72, 10), 0.3F); Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction); controller.LeftButtonEndDrag(Pane.Map, new PointF(50, -25), new PointF(72, 10), 0.3F); // Check the status text ui.MouseMoved(12, -1, 0.1F); Assert.AreEqual(StatusBarText.DefaultStatus, controller.StatusText); // Check the cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(12, -1), 0.3F); Assert.AreSame(Cursors.Default, cursor); // Check the highlights highlights = (CourseObj[])controller.GetHighlights(Pane.Map); Assert.AreEqual(1, highlights.Length); Assert.AreEqual(@"Leg: control:1 course-control:1 scale:1 course-control2:2 path:N(73.43,10.02)--N(68,-22)--N(40.52,-22.36) gaps: (s:0.25,l:50.26)", highlights[0].ToString()); // Make sure the leg gap is added. Leg leg = eventDB.GetLeg(QueryEvent.FindLeg(eventDB, ControlId(1), ControlId(2))); Assert.AreEqual(1, leg.gaps.Length); Assert.AreEqual(4.29F, leg.gaps[0].distanceFromStart, 0.01F); Assert.AreEqual(50.26F, leg.gaps[0].length, 0.01F); }
// Change a hightlighted rectangle from an expected rectangle to another. public void ChangeRectangle(RectangleF initialRect, RectangleF finalRect) { RectangleF currentRect = initialRect; // 1. Move the entire one to the left or right to get left edge right. float delta = finalRect.Left - initialRect.Left; PointF ptClick = new PointF((initialRect.Left + initialRect.Right) / 2, (initialRect.Top + initialRect.Bottom) / 2); // Click in center and drag to left/right. MapViewer.DragAction dragAction = controller.LeftButtonDown(Pane.Map, ptClick, 0.3F); Assert.AreEqual(MapViewer.DragAction.ImmediateDrag, dragAction); Assert.AreEqual(StatusBarText.DraggingObject, controller.StatusText); Cursor cursor = controller.GetMouseCursor(Pane.Map, ptClick, 0.3F); Assert.AreSame(Cursors.SizeAll, cursor); controller.LeftButtonEndDrag(Pane.Map, new PointF(ptClick.X + delta, ptClick.Y), ptClick, 0.3F); currentRect.Offset(delta, 0); // 2. Move the bottom edge up or down. delta = finalRect.Top - currentRect.Top; ptClick = new PointF((currentRect.Right + currentRect.Left) / 2, currentRect.Top); dragAction = controller.LeftButtonDown(Pane.Map, ptClick, 0.3F); Assert.AreEqual(MapViewer.DragAction.ImmediateDrag, dragAction); Assert.AreEqual(StatusBarText.SizingRectangle, controller.StatusText); cursor = controller.GetMouseCursor(Pane.Map, ptClick, 0.3F); Assert.AreSame(Cursors.SizeNS, cursor); controller.LeftButtonEndDrag(Pane.Map, new PointF(ptClick.X, ptClick.Y + delta), ptClick, 0.3F); currentRect.Height = currentRect.Height - delta; currentRect.Y = currentRect.Y + delta; // 3. Move the upper right corner around. float deltaX = finalRect.Right - currentRect.Right; float deltaY = finalRect.Bottom - currentRect.Bottom; ptClick = new PointF(currentRect.Right, currentRect.Bottom); dragAction = controller.LeftButtonDown(Pane.Map, ptClick, 0.3F); Assert.AreEqual(MapViewer.DragAction.ImmediateDrag, dragAction); Assert.AreEqual(StatusBarText.SizingRectangle, controller.StatusText); cursor = controller.GetMouseCursor(Pane.Map, ptClick, 0.3F); Assert.AreSame(Cursors.SizeNESW, cursor); controller.LeftButtonEndDrag(Pane.Map, new PointF(ptClick.X + deltaX, ptClick.Y + deltaY), ptClick, 0.3F); currentRect = RectangleF.FromLTRB(currentRect.Left, currentRect.Top, currentRect.Right + deltaX, currentRect.Bottom + deltaY); TestUtil.AssertEqualRect(currentRect, finalRect, 0.01, "rectangle moving algorithm"); }