Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TransitionAnimation.cs
1using System;
3using System.Threading;
4using System.Threading.Tasks;
5using Microsoft.Maui.Controls;
6
8{
13 {
14 private readonly IViewAnimation? enterAnimation;
15 private readonly IViewAnimation? exitAnimation;
16 private readonly IViewAnimation? overlayAnimation;
17
24 public TransitionAnimation(IViewAnimation? EnterAnimation, IViewAnimation? ExitAnimation, IViewAnimation? OverlayAnimation = null)
25 {
26 this.enterAnimation = EnterAnimation;
27 this.exitAnimation = ExitAnimation;
28 this.overlayAnimation = OverlayAnimation;
29 }
30
32 public async Task RunAsync(VisualElement? Entering, VisualElement? Exiting, IAnimationContext Context, AnimationOptions? Options, CancellationToken Token)
33 {
34 ArgumentNullException.ThrowIfNull(Context);
35 List<Task> Tasks = new List<Task>(3);
36
37 if (this.enterAnimation is not null && Entering is not null)
38 Tasks.Add(this.enterAnimation.RunAsync(Entering, Context, Options, Token));
39
40 if (this.exitAnimation is not null && Exiting is not null)
41 Tasks.Add(this.exitAnimation.RunAsync(Exiting, Context, Options, Token));
42
43 if (this.overlayAnimation is not null)
44 {
45 VisualElement Anchor = Entering ?? Exiting ?? throw new InvalidOperationException("Overlay animations require at least one visual element.");
46 Tasks.Add(this.overlayAnimation.RunAsync(Anchor, Context, Options, Token));
47 }
48
49 if (Tasks.Count == 0)
50 return;
51
52 await Task.WhenAll(Tasks);
53 }
54 }
55}
Options applied for an individual animation execution.
Represents a pair of animations used for transitions.
async Task RunAsync(VisualElement? Entering, VisualElement? Exiting, IAnimationContext Context, AnimationOptions? Options, CancellationToken Token)
Executes the transition animation for enter and exit elements. Task tracking execution.
TransitionAnimation(IViewAnimation? EnterAnimation, IViewAnimation? ExitAnimation, IViewAnimation? OverlayAnimation=null)
Initializes a new instance of the TransitionAnimation class.
Represents contextual information required when executing an animation.
Defines a transition animation executor.
Defines a view-based animation executor.