From 468f9654e0c533e9f8ec15b4cb1ac7aecdfd7fd2 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 9 Feb 2017 19:51:55 +0100 Subject: [PATCH] Test turning geometry clipping on and off. Seems to work! --- samples/RenderTest/Pages/ClippingPage.xaml | 8 +++++--- samples/RenderTest/Pages/ClippingPage.xaml.cs | 14 +++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/samples/RenderTest/Pages/ClippingPage.xaml b/samples/RenderTest/Pages/ClippingPage.xaml index 0e352c4bec..47e9d51e3c 100644 --- a/samples/RenderTest/Pages/ClippingPage.xaml +++ b/samples/RenderTest/Pages/ClippingPage.xaml @@ -1,13 +1,15 @@ - - + - + + Apply Geometry Clip \ No newline at end of file diff --git a/samples/RenderTest/Pages/ClippingPage.xaml.cs b/samples/RenderTest/Pages/ClippingPage.xaml.cs index 6c419f245c..b416f12943 100644 --- a/samples/RenderTest/Pages/ClippingPage.xaml.cs +++ b/samples/RenderTest/Pages/ClippingPage.xaml.cs @@ -1,3 +1,4 @@ +using System; using System.Reactive.Linq; using Avalonia; using Avalonia.Animation; @@ -10,10 +11,13 @@ namespace RenderTest.Pages { public class ClippingPage : UserControl { + private Geometry _clip; + public ClippingPage() { InitializeComponent(); CreateAnimations(); + WireUpCheckbox(); } private void InitializeComponent() @@ -23,7 +27,7 @@ namespace RenderTest.Pages private void CreateAnimations() { - var clipped = this.FindControl("geometryClipped"); + var clipped = this.FindControl("clipChild"); var degrees = Animate.Timer.Select(x => x.TotalMilliseconds / 5); clipped.RenderTransform = new RotateTransform(); clipped.RenderTransform.Bind(RotateTransform.AngleProperty, degrees, BindingPriority.Animation); @@ -32,5 +36,13 @@ namespace RenderTest.Pages clipped.GetObservable(Control.IsPointerOverProperty) .Select(x => x ? Brushes.Crimson : AvaloniaProperty.UnsetValue)); } + + private void WireUpCheckbox() + { + var useMask = this.FindControl("useMask"); + var clipped = this.FindControl("clipped"); + _clip = clipped.Clip; + useMask.Click += (s, e) => clipped.Clip = clipped.Clip == null ? _clip : null; + } } }