diff --git a/samples/RenderTest/App.config b/samples/RenderTest/App.config
index 2231c71e63..10a06d8258 100644
--- a/samples/RenderTest/App.config
+++ b/samples/RenderTest/App.config
@@ -9,6 +9,14 @@
+
+
+
+
+
+
+
+
diff --git a/samples/RenderTest/App.xaml b/samples/RenderTest/App.xaml
index d9630eef58..c119f54915 100644
--- a/samples/RenderTest/App.xaml
+++ b/samples/RenderTest/App.xaml
@@ -2,5 +2,6 @@
+
\ No newline at end of file
diff --git a/samples/RenderTest/MainWindow.xaml b/samples/RenderTest/MainWindow.xaml
index ab233fd90b..1d3001f1b1 100644
--- a/samples/RenderTest/MainWindow.xaml
+++ b/samples/RenderTest/MainWindow.xaml
@@ -1,3 +1,32 @@
+ Title="Avalonia Render Test"
+ xmlns:pages="clr-namespace:RenderTest.Pages;assembly=RenderTest">
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/RenderTest/MainWindow.xaml.cs b/samples/RenderTest/MainWindow.xaml.cs
index feb121186f..c6c0eafd25 100644
--- a/samples/RenderTest/MainWindow.xaml.cs
+++ b/samples/RenderTest/MainWindow.xaml.cs
@@ -2,15 +2,11 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
-using System.Reactive.Linq;
using Avalonia;
-using Avalonia.Animation;
using Avalonia.Controls;
-using Avalonia.Controls.Shapes;
-using Avalonia.Data;
-using Avalonia.Layout;
using Avalonia.Markup.Xaml;
-using Avalonia.Media;
+using RenderTest.ViewModels;
+using ReactiveUI;
using Avalonia.Rendering;
namespace RenderTest
@@ -20,63 +16,16 @@ namespace RenderTest
public MainWindow()
{
this.InitializeComponent();
- this.CreateAnimations();
this.AttachDevTools();
- RendererMixin.DrawFpsCounter = true;
+
+ var vm = new MainWindowViewModel();
+ vm.WhenAnyValue(x => x.DrawFps).Subscribe(x => RendererMixin.DrawFpsCounter = x);
+ this.DataContext = vm;
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
-
- 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;
- }
}
}
diff --git a/samples/RenderTest/Pages/AnimationsPage.xaml b/samples/RenderTest/Pages/AnimationsPage.xaml
new file mode 100644
index 0000000000..6eb7067245
--- /dev/null
+++ b/samples/RenderTest/Pages/AnimationsPage.xaml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/samples/RenderTest/Pages/AnimationsPage.xaml.cs b/samples/RenderTest/Pages/AnimationsPage.xaml.cs
new file mode 100644
index 0000000000..991896c3b5
--- /dev/null
+++ b/samples/RenderTest/Pages/AnimationsPage.xaml.cs
@@ -0,0 +1,90 @@
+using System.Reactive.Linq;
+using Avalonia;
+using Avalonia.Animation;
+using Avalonia.Controls;
+using Avalonia.Controls.Shapes;
+using Avalonia.Data;
+using Avalonia.Input;
+using Avalonia.Markup.Xaml;
+using Avalonia.Media;
+
+namespace RenderTest.Pages
+{
+ public class AnimationsPage : UserControl
+ {
+ public AnimationsPage()
+ {
+ this.InitializeComponent();
+ this.CreateAnimations();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+
+ private void CreateAnimations()
+ {
+ const int Count = 100;
+ var panel = new WrapPanel();
+
+ for (var i = 0; i < Count; ++i)
+ {
+ Ellipse ellipse;
+ var element = new Panel
+ {
+ Children =
+ {
+ (ellipse = new Ellipse
+ {
+ Name = $"ellipse{i}",
+ 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 = Avalonia.Layout.HorizontalAlignment.Center,
+ VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center,
+ RenderTransform = new ScaleTransform(2, 2),
+ }
+ },
+ Margin = new Thickness(4),
+ RenderTransform = new ScaleTransform(),
+ };
+
+ var start = Animate.Stopwatch.Elapsed;
+ var index = i % (Count / 2);
+ 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);
+
+ ellipse.PointerEnter += Ellipse_PointerEnter;
+ ellipse.PointerLeave += Ellipse_PointerLeave;
+
+ panel.Children.Add(element);
+ }
+
+ Content = panel;
+ }
+
+ private void Ellipse_PointerEnter(object sender, PointerEventArgs e)
+ {
+ ((Ellipse)sender).Fill = Brushes.Red;
+ }
+
+ private void Ellipse_PointerLeave(object sender, PointerEventArgs e)
+ {
+ ((Ellipse)sender).Fill = Brushes.Blue;
+ }
+ }
+}
diff --git a/samples/RenderTest/Pages/ClippingPage.xaml b/samples/RenderTest/Pages/ClippingPage.xaml
new file mode 100644
index 0000000000..47e9d51e3c
--- /dev/null
+++ b/samples/RenderTest/Pages/ClippingPage.xaml
@@ -0,0 +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
new file mode 100644
index 0000000000..b416f12943
--- /dev/null
+++ b/samples/RenderTest/Pages/ClippingPage.xaml.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Reactive.Linq;
+using Avalonia;
+using Avalonia.Animation;
+using Avalonia.Controls;
+using Avalonia.Data;
+using Avalonia.Markup.Xaml;
+using Avalonia.Media;
+
+namespace RenderTest.Pages
+{
+ public class ClippingPage : UserControl
+ {
+ private Geometry _clip;
+
+ public ClippingPage()
+ {
+ InitializeComponent();
+ CreateAnimations();
+ WireUpCheckbox();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+
+ private void CreateAnimations()
+ {
+ 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);
+ clipped.Bind(
+ Border.BackgroundProperty,
+ 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;
+ }
+ }
+}
diff --git a/samples/RenderTest/RenderTest.csproj b/samples/RenderTest/RenderTest.csproj
index f117c76342..a14114ddc8 100644
--- a/samples/RenderTest/RenderTest.csproj
+++ b/samples/RenderTest/RenderTest.csproj
@@ -45,6 +45,10 @@
..\..\packages\Serilog.1.5.14\lib\net45\Serilog.FullNetFx.dll
True
+
+ ..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll
+ True
+
@@ -79,11 +83,18 @@
App.xaml
+
+ ClippingPage.xaml
+
+
+ AnimationsPage.xaml
+
MainWindow.xaml
+
@@ -167,6 +178,10 @@
{6417e941-21bc-467b-a771-0de389353ce6}
Avalonia.Markup
+
+ {925dd807-b651-475f-9f7c-cbeb974ce43d}
+ Avalonia.Skia.Desktop
+
{3e908f67-5543-4879-a1dc-08eace79b3cd}
Avalonia.Direct2D1
@@ -181,6 +196,21 @@
Designer
+
+
+ Designer
+
+
+
+
+ Designer
+
+
+
+
+ Designer
+
+