public void HitTest_Should_Not_Hit_Controls_Next_Pixel() { using (var s = new CompositorServices(new Size(200, 200))) { Border targetRectangle; var stackPanel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Left, Children = { new Border { Width = 10, Height = 10, Background = Brushes.Red }, { targetRectangle = new Border { Width = 10, Height = 10, Background = Brushes.Green } } } }; s.TopLevel.Content = stackPanel; s.AssertHitTest(new Point(5, 10), null, targetRectangle); } }
public void HitTest_Should_Respect_Geometry_Clip() { using (var s = new CompositorServices(new Size(400, 400))) { Canvas canvas; Border border = new Border { Background = Brushes.Red, Clip = StreamGeometry.Parse("M100,0 L0,100 100,100"), Width = 200, Height = 200, Child = canvas = new Canvas { Background = Brushes.Yellow, Margin = new Thickness(10), } }; s.TopLevel.Content = border; s.RunJobs(); Assert.Equal(new Rect(100, 100, 200, 200), border.Bounds); s.AssertHitTest(new Point(200, 200), null, canvas, border); s.AssertHitTest(new Point(110, 110), null); } }
public void HitTest_Should_Return_Top_Controls_First() { using (var s = new CompositorServices(new Size(200, 200))) { Panel container = new Panel { Width = 200, Height = 200, Children = { new Border { Width = 100, Height = 100, Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }, new Border { Width = 50, Height = 50, Background = Brushes.Blue, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center } } }; s.TopLevel.Content = container; s.AssertHitTest(new Point(100, 100), null, container.Children[1], container.Children[0]); } }
public void HitTest_Should_Not_Find_Control_Outside_Point() { using (var s = new CompositorServices(new Size(200, 200))) { var border = new Border { Width = 100, Height = 100, Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; s.TopLevel.Content = border; s.AssertHitTest(new Point(10, 10), null); } }
public void HitTest_Should_Not_Find_Path_When_Outside_Fill() { using (var s = new CompositorServices(new Size(200, 200))) { Path path = new Path { Width = 200, Height = 200, Fill = Brushes.Red, Data = StreamGeometry.Parse("M100,0 L0,100 100,100") }; s.TopLevel.Content = path; s.AssertHitTest(new Point(100, 100), null, path); s.AssertHitTest(new Point(10, 10), null); } }
public void HitTest_Should_Accommodate_ICustomHitTest() { using (var s = new CompositorServices(new Size(300, 200))) { Border border = new CustomHitTestBorder { ClipToBounds = false, Width = 100, Height = 100, Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; s.TopLevel.Content = border; s.AssertHitTest(75, 100, null, border); s.AssertHitTest(125, 100, null, border); s.AssertHitTest(175, 100, null); } }
public void HitTest_Should_Find_Control_Translated_Outside_Parent_Bounds() { using (var s = new CompositorServices(new Size(200, 200))) { Border target; Panel container = new Panel { Width = 200, Height = 200, Background = Brushes.Red, ClipToBounds = false, Children = { new Border { Width = 100, Height = 100, ZIndex = 1, Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Child = target = new Border { Width = 50, Height = 50, Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, RenderTransform = new TranslateTransform(110, 110), } }, } }; s.TopLevel.Content = container; s.AssertHitTest(new Point(120, 120), null, target, container); } }
public void HitTest_Should_Not_Find_Control_Outside_Parent_Bounds_When_Clipped() { using (var s = new CompositorServices(new Size(200, 200))) { Border target; Panel container = new Panel { Width = 100, Height = 200, Background = Brushes.Red, Children = { new Panel() { Width = 100, Height = 100, Background = Brushes.Red, Margin = new Thickness(0, 100, 0, 0), ClipToBounds = true, Children = { (target = new Border() { Width = 100, Height = 100, Background = Brushes.Red, Margin = new Thickness(0,-100, 0, 0) }) } } } }; s.TopLevel.Content = container; s.AssertHitTest(new Point(50, 50), null, container); } }
public void HitTest_Should_Not_Find_Invisible_Controls_At_Point() { using (var s = new CompositorServices(new Size(200, 200))) { Border visible, border; s.TopLevel.Content = border = new Border { Width = 100, Height = 100, Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, IsVisible = false, Child = visible = new Border { Background = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, } }; s.AssertHitTest(new Point(100, 100), null); } }
public void HitTest_Should_Not_Find_Control_Outside_Scroll_Viewport() { using (var s = new CompositorServices(new Size(100, 200))) { Border target; Border item1; Border item2; ScrollContentPresenter scroll; Panel container = new Panel { Width = 100, Height = 200, Background = Brushes.Red, Children = { (target = new Border() { Name = "b1", Width = 100, Height = 100, Background = Brushes.Red, }), new Border() { Name = "b2", Width = 100, Height = 100, Background = Brushes.Red, Margin = new Thickness(0, 100, 0, 0), Child = scroll = new ScrollContentPresenter() { CanHorizontallyScroll = true, CanVerticallyScroll = true, Content = new StackPanel() { Children = { (item1 = new Border() { Name = "b3", Width = 100, Height = 100, Background = Brushes.Red, }), (item2 = new Border() { Name = "b4", Width = 100, Height = 100, Background = Brushes.Red, }), } } } } } }; s.TopLevel.Content = container; scroll.UpdateChild(); s.AssertHitTestFirst(new Point(50, 150), null, item1); s.AssertHitTestFirst(new Point(50, 50), null, target); scroll.Offset = new Vector(0, 100); s.AssertHitTestFirst(new Point(50, 150), null, item2); s.AssertHitTestFirst(new Point(50, 50), null, target); } }