public void TestSurroudingAnchor() { var stackSize = new Vector3(100, 200, 300); var stackPanel = new PanelTests { Size = stackSize }; stackPanel.Arrange(Vector3.Zero, false); Assert.Equal(new Vector2(0, 100), stackPanel.GetSurroudingAnchorDistances(Orientation.Horizontal, -1f)); Assert.Equal(new Vector2(0, 100), stackPanel.GetSurroudingAnchorDistances(Orientation.Horizontal, 0)); Assert.Equal(new Vector2(-20, 80), stackPanel.GetSurroudingAnchorDistances(Orientation.Horizontal, 20)); Assert.Equal(new Vector2(-100, 0), stackPanel.GetSurroudingAnchorDistances(Orientation.Horizontal, 100)); Assert.Equal(new Vector2(-100, 0), stackPanel.GetSurroudingAnchorDistances(Orientation.Horizontal, 150)); Assert.Equal(new Vector2(0, 200), stackPanel.GetSurroudingAnchorDistances(Orientation.Vertical, -1f)); Assert.Equal(new Vector2(0, 200), stackPanel.GetSurroudingAnchorDistances(Orientation.Vertical, 0)); Assert.Equal(new Vector2(-100, 100), stackPanel.GetSurroudingAnchorDistances(Orientation.Vertical, 100)); Assert.Equal(new Vector2(-200, 0), stackPanel.GetSurroudingAnchorDistances(Orientation.Vertical, 200)); Assert.Equal(new Vector2(-200, 0), stackPanel.GetSurroudingAnchorDistances(Orientation.Vertical, 220)); Assert.Equal(new Vector2(0, 300), stackPanel.GetSurroudingAnchorDistances(Orientation.InDepth, -1f)); Assert.Equal(new Vector2(0, 300), stackPanel.GetSurroudingAnchorDistances(Orientation.InDepth, 0)); Assert.Equal(new Vector2(-200, 100), stackPanel.GetSurroudingAnchorDistances(Orientation.InDepth, 200)); Assert.Equal(new Vector2(-300, 0), stackPanel.GetSurroudingAnchorDistances(Orientation.InDepth, 300)); Assert.Equal(new Vector2(-300, 0), stackPanel.GetSurroudingAnchorDistances(Orientation.InDepth, 330)); }
public void TestUpdateWorldMatrix() { ResetState(); DepthAlignment = DepthAlignment.Stretch; // set the panel size to 1 Arrange(Vector3.One, false); // test that the world matrix of the panel is correctly updated. var localMatrix = Matrix.Scaling(0.1f, 0.5f, 1f); var worldMatrix = Matrix.Scaling(1f, 0.8f, 0.4f); LocalMatrix = localMatrix; UpdateWorldMatrix(ref worldMatrix, true); Assert.Equal(new Matrix(0.1f, 0, 0, 0, 0, 0.4f, 0, 0, 0, 0, 0.4f, 0, 0.5f, 0.4f, 0.2f, 1), WorldMatrix); // add a child and set its local matrix var child = new PanelTests { DepthAlignment = DepthAlignment.Stretch }; var childArrangementMatrix = Matrix.Translation(10, 20, 30); var childLocalMatrix = new Matrix(0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); child.LocalMatrix = childLocalMatrix; Children.Add(child); // set the child's panel arrangement matrix child.DependencyProperties.Set(PanelArrangeMatrixPropertyKey, childArrangementMatrix); // arrange the child (set its size to 1) child.Arrange(Vector3.One, false); // check that the value of the world matrix of the child is correctly updated too UpdateWorldMatrix(ref worldMatrix, true); Assert.Equal(new Matrix(0, -0.4f, 0, 0, 0.1f, 0, 0, 0, 0, 0, 0.4f, 0, 1.55f, 8.6f, 12.4f, 1), child.WorldMatrix); }