public async Task Invalidating_In_Handler_Causes_Layout_To_Be_Rerun_Before_LayoutUpdated_Raised() { await RunOnUIThread.Execute(async() => { var root = CreateRoot(); var target = new TestCanvas(); var raised = 0; var layoutUpdatedRaised = 0; root.LayoutUpdated += (s, e) => { Assert.Equal(2, target.MeasureCount); Assert.Equal(2, target.ArrangeCount); ++layoutUpdatedRaised; }; target.EffectiveViewportChanged += (s, e) => { target.InvalidateMeasure(); ++raised; }; root.Child = target; await ExecuteInitialLayoutPass(root); Assert.Equal(1, raised); Assert.Equal(1, layoutUpdatedRaised); }); }
public PixelOffsetTransforms() { HorizontalContentAlignment = HorizontalAlignment.Stretch; Spacing = 5; var canvas = new TestCanvas(); var offsetMode = new EnumDropDown<PixelOffsetMode>(); offsetMode.SelectedValueBinding.Bind(canvas, c => c.PixelOffsetMode); var testDropDown = new DropDown(); testDropDown.ItemTextBinding = Binding.Property((TestInfo t) => t.Name); testDropDown.SelectedValueBinding.Cast<TestInfo>().Bind(canvas, c => c.Test); testDropDown.DataStore = tests; testDropDown.SelectedIndex = 0; var options = new StackLayout { Orientation = Orientation.Horizontal, VerticalContentAlignment = VerticalAlignment.Center, Spacing = 5, Padding = new Padding(10), Items = { "PixelOffsetMode", offsetMode, "Test", testDropDown } }; Items.Add(options); Items.Add(new StackLayoutItem(canvas, true)); }
public void Draw_WithEllipse_ShouldWriteDrawingInfo() { var center = new Point(5, 5); double horizontalRadius = 6; double verticalRadius = 2; var color = Color.Green; var ellipse = new Ellipse(center, horizontalRadius, verticalRadius, color); var sw = new StringWriter(); var canvas = new TestCanvas(sw); ellipse.Draw(canvas); var expectedString = $"Green ellipse with center: {center}; width: {horizontalRadius * 2}; height: {verticalRadius * 2}\r\n"; Assert.AreEqual(expectedString, sw.ToString()); }
public void Draw_WithTriangle_ShouldWriteDrawingInfo() { var vertex1 = new Point(-2, 3); var vertex2 = new Point(4, 3); var vertex3 = new Point(2, 5); var color = Color.Green; var triangle = new Triangle(vertex1, vertex2, vertex3, color); var sw = new StringWriter(); var canvas = new TestCanvas(sw); triangle.Draw(canvas); var expectedString = $"Green line from {vertex1}, to {vertex2}\r\nGreen line from {vertex2}, to {vertex3}\r\nGreen line from {vertex3}, to {vertex1}\r\n"; Assert.AreEqual(expectedString, sw.ToString()); }
public void CanDrawTriangle() { var v1 = new Point(1, 2); var v2 = new Point(4, 5); var v3 = new Point(0, 5); var color = Color.Red; var triangle = new Triangle(v1, v2, v3, color); TestCanvas canvas = new TestCanvas(); canvas.ExpectedData.Add($"{v1} {v2}"); canvas.ExpectedData.Add($"{v2} {v3}"); canvas.ExpectedData.Add($"{v3} {v1}"); triangle.Draw(canvas); }
public void Draw_WithRegularPolygon_ShouldWriteDrawingInfo() { var center = new Point(100, 100); double radius = 30; int vertexCount = 3; var color = Color.Green; var regularPolygon = new RegularPolygon(center, radius, vertexCount, color); var sw = new StringWriter(); var canvas = new TestCanvas(sw); regularPolygon.Draw(canvas); var expectedString = "Green line from (130, 100), to (85, 125,98076211353316)\r\n" + "Green line from (85, 125,98076211353316), to (84,99999999999999, 74,01923788646684)\r\n" + "Green line from (84,99999999999999, 74,01923788646684), to (130, 99,99999999999999)\r\n"; Assert.AreEqual(expectedString, sw.ToString()); }
public void Draw_WithRectangle_ShouldWriteDrawingInfo() { var leftTop = new Point(3, 5); var rightBottom = new Point(10, 3); var color = Color.Green; var rectangle = new Rectangle(leftTop, rightBottom, color); var sw = new StringWriter(); var canvas = new TestCanvas(sw); rectangle.Draw(canvas); var expectedString = "Green line from (3, 5), to (10, 5)\r\n" + "Green line from (10, 5), to (10, 3)\r\n" + "Green line from (10, 3), to (3, 3)\r\n" + "Green line from (3, 3), to (3, 5)\r\n"; Assert.AreEqual(expectedString, sw.ToString()); }
public void CanDrawRectangle() { var leftTop = new Point(0, 6); var rightBottom = new Point(2, 0); var color = Color.Red; var rectangle = new Rectangle(leftTop, rightBottom, color); TestCanvas canvas = new TestCanvas(); var rightTop = new Point(rightBottom.X, leftTop.Y); var leftBottom = new Point(leftTop.X, rightBottom.Y); canvas.ExpectedData.Add($"{leftTop} {rightTop}"); canvas.ExpectedData.Add($"{rightTop} {rightBottom}"); canvas.ExpectedData.Add($"{rightBottom} {leftBottom}"); canvas.ExpectedData.Add($"{leftBottom} {leftTop}"); rectangle.Draw(canvas); }
public void CanDrawRegularPolygon() { var vertexCount = 3; var center = new Point(4, 4); var radius = 3; var color = Color.Red; var regularPolygon = new RegularPolygon(vertexCount, center, radius, color); TestCanvas canvas = new TestCanvas(); var angle = 360f / vertexCount; var vertex1 = GetVertexByAngle(angle * 0); for (var i = 1; i < vertexCount; ++i) { var vertex2 = GetVertexByAngle(angle * i); canvas.ExpectedData.Add($"{vertex1} {vertex2}"); vertex1 = vertex2; } regularPolygon.Draw(canvas); }
public PixelOffsetTransforms() { HorizontalContentAlignment = HorizontalAlignment.Stretch; Spacing = 5; var canvas = new TestCanvas(); var offsetMode = new EnumDropDown <PixelOffsetMode>(); offsetMode.SelectedValueBinding.Bind(canvas, c => c.PixelOffsetMode); var testDropDown = new DropDown(); testDropDown.ItemTextBinding = Binding.Property((TestInfo t) => t.Name); testDropDown.SelectedValueBinding.Cast <TestInfo>().Bind(canvas, c => c.Test); testDropDown.DataStore = tests; testDropDown.SelectedIndex = 0; var options = new StackLayout { Orientation = Orientation.Horizontal, VerticalContentAlignment = VerticalAlignment.Center, Spacing = 5, Padding = new Padding(10), Items = { "PixelOffsetMode", offsetMode, "Test", testDropDown } }; Items.Add(options); Items.Add(new StackLayoutItem(canvas, true)); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TestCanvas obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TestCanvas obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }