public void Should_Track_Bounds() { var target = new BoundsTracker(); var control = default(Rectangle); var tree = new Decorator { Padding = new Thickness(10), Content = new Decorator { Padding = new Thickness(5), Content = (control = new Rectangle { Width = 15, Height = 15, }), } }; tree.Measure(Size.Infinity); tree.Arrange(new Rect(0, 0, 100, 100)); var track = target.Track(control, tree); var results = new List<TransformedBounds>(); track.Subscribe(results.Add); Assert.Equal(new Rect(15, 15, 15, 15), results.Last().Bounds); tree.Padding = new Thickness(15); tree.Measure(Size.Infinity); tree.Arrange(new Rect(0, 0, 100, 100), true); Assert.Equal(new Rect(20, 20, 15, 15), results.Last().Bounds); }
public void Negative_Margin_Larger_Than_Constraint_Should_Request_Height_0() { Control target; var outer = new Decorator { Width = 100, Height = 100, Child = target = new Control { Margin = new Thickness(0, -100, 0, 0), } }; outer.Measure(Size.Infinity); Assert.Equal(0, target.DesiredSize.Height); }
public void InputHitTest_Should_Not_Find_Control_Outside_Point() { var container = new Decorator { Width = 200, Height = 200, Child = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center } }; container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var result = container.InputHitTest(new Point(10, 10)); Assert.Equal(container, result); }