private void CreateAnimations() { const int Count = 100; var panel = new WrapPanel(); for (var i = 0; i < Count; ++i) { var element = new Panel { Children = { new Ellipse { Width = 100, Height = 100, Fill = Brushes.Blue, }, new Path { Data = StreamGeometry.Parse( "F1 M 16.6309,18.6563C 17.1309,8.15625 29.8809,14.1563 29.8809,14.1563C 30.8809,11.1563 34.1308,11.4063 34.1308,11.4063C 33.5,12 34.6309,13.1563 34.6309,13.1563C 32.1309,13.1562 31.1309,14.9062 31.1309,14.9062C 41.1309,23.9062 32.6309,27.9063 32.6309,27.9062C 24.6309,24.9063 21.1309,22.1562 16.6309,18.6563 Z M 16.6309,19.9063C 21.6309,24.1563 25.1309,26.1562 31.6309,28.6562C 31.6309,28.6562 26.3809,39.1562 18.3809,36.1563C 18.3809,36.1563 18,38 16.3809,36.9063C 15,36 16.3809,34.9063 16.3809,34.9063C 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"), Fill = Brushes.Green, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, RenderTransform = new ScaleTransform(2, 2), } }, Margin = new Thickness(4), RenderTransform = new ScaleTransform(), }; var start = Animate.Stopwatch.Elapsed; var index = i; var degrees = Animate.Timer .Select(x => (x - start).TotalSeconds) .Where(x => (x % Count) >= index && (x % Count) < index + 1) .Select(x => (x % 1) / 1); element.RenderTransform.Bind( ScaleTransform.ScaleXProperty, degrees, BindingPriority.Animation); panel.Children.Add(element); } Content = panel; }
public void GetVisualsAt_Should_Not_Find_Control_Outside_Scroll_Viewport() { using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) { Border target; Border item1; Border item2; ScrollContentPresenter scroll; var container = new Panel { Width = 100, Height = 200, Children = new Controls.Controls { (target = new Border() { Width = 100, Height = 100 }), new Border() { Width = 100, Height = 100, Margin = new Thickness(0, 100, 0, 0), Child = scroll = new ScrollContentPresenter() { Content = new StackPanel() { Children = new Controls.Controls { (item1 = new Border() { Width = 100, Height = 100, }), (item2 = new Border() { Width = 100, Height = 100, }), } } } } } }; scroll.UpdateChild(); container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); context.Render(container); var result = container.GetVisualsAt(new Point(50, 150)).First(); Assert.Equal(item1, result); result = container.GetVisualsAt(new Point(50, 50)).First(); Assert.Equal(target, result); scroll.Offset = new Vector(0, 100); //we don't have setup LayoutManager so we will make it manually scroll.Parent.InvalidateArrange(); container.InvalidateArrange(); container.Arrange(new Rect(container.DesiredSize)); context.Render(container); result = container.GetVisualsAt(new Point(50, 150)).First(); Assert.Equal(item2, result); result = container.GetVisualsAt(new Point(50, 50)).First(); Assert.NotEqual(item1, result); Assert.Equal(target, result); } }
public void GetVisualsAt_Should_Not_Find_Control_Outside_Parent_Bounds_When_Clipped() { using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) { Border target; var container = new Panel { Width = 100, Height = 200, Children = new Controls.Controls { new Panel() { Width = 100, Height = 100, Margin = new Thickness(0, 100, 0, 0), ClipToBounds = true, Children = new Controls.Controls { (target = new Border() { Width = 100, Height = 100, Margin = new Thickness(0, -100, 0, 0) }) } } } }; container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); context.Render(container); var result = container.GetVisualsAt(new Point(50, 50)); Assert.Equal(new[] { container }, result); } }
public void GetVisualsAt_Should_Find_Control_Translated_Outside_Parent_Bounds() { using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) { Border target; var container = new Panel { Width = 200, Height = 200, ClipToBounds = false, Children = new Controls.Controls { new Border { Width = 100, Height = 100, ZIndex = 1, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Child = target = new Border { Width = 50, Height = 50, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, RenderTransform = new TranslateTransform(110, 110), } }, } }; container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); context.Render(container); var result = container.GetVisualsAt(new Point(120, 120)); Assert.Equal(new IVisual[] { target, container }, result); } }
public void GetVisualsAt_Should_Return_Top_Controls_First_With_ZIndex() { using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) { var container = new Panel { Width = 200, Height = 200, Children = new Controls.Controls { new Border { Width = 100, Height = 100, ZIndex = 1, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }, new Border { Width = 50, Height = 50, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }, new Border { Width = 75, Height = 75, ZIndex = 2, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center } } }; container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); context.Render(container); var result = container.GetVisualsAt(new Point(100, 100)); Assert.Equal(new[] { container.Children[2], container.Children[0], container.Children[1], container }, result); } }
internal ItemContainerGenerator GetItemContainerGeneratorForPanel(Panel panel) { // FIXME: Double check this, but i think it's right return panel == Panel ? this : null; }
ItemContainerGenerator IItemContainerGenerator.GetItemContainerGeneratorForPanel(Panel panel) { return this.GetItemContainerGeneratorForPanel(panel); }
public void InputHitTest_Should_Find_Top_Control_At_Point() { using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) { var container = new Panel { Width = 200, Height = 200, Children = new Controls.Controls { new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }, new Border { Width = 50, Height = 50, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center } } }; container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); context.Render(container); var result = container.InputHitTest(new Point(100, 100)); Assert.Equal(container.Children[1], result); } }