ClippingPage.xaml.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Reactive.Linq;
  2. using Avalonia;
  3. using Avalonia.Animation;
  4. using Avalonia.Controls;
  5. using Avalonia.Data;
  6. using Avalonia.Markup.Xaml;
  7. using Avalonia.Media;
  8. namespace RenderTest.Pages
  9. {
  10. public class ClippingPage : UserControl
  11. {
  12. public ClippingPage()
  13. {
  14. InitializeComponent();
  15. CreateAnimations();
  16. }
  17. private void InitializeComponent()
  18. {
  19. AvaloniaXamlLoader.Load(this);
  20. }
  21. private void CreateAnimations()
  22. {
  23. var clipped = this.FindControl<Border>("geometryClipped");
  24. var degrees = Animate.Timer.Select(x => x.TotalMilliseconds / 5);
  25. clipped.RenderTransform = new RotateTransform();
  26. clipped.RenderTransform.Bind(RotateTransform.AngleProperty, degrees, BindingPriority.Animation);
  27. clipped.Bind(
  28. Border.BackgroundProperty,
  29. clipped.GetObservable(Control.IsPointerOverProperty)
  30. .Select(x => x ? Brushes.Crimson : AvaloniaProperty.UnsetValue));
  31. }
  32. }
  33. }