Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TimedViewAnimation.cs
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4using Microsoft.Maui.Controls;
5
7{
11 public abstract class TimedViewAnimation : IViewAnimation
12 {
18 protected TimedViewAnimation(TimeSpan Duration, Easing Easing)
19 {
20 if (Duration < TimeSpan.Zero)
21 throw new ArgumentOutOfRangeException(nameof(Duration), "Duration cannot be negative.");
22 this.BaseDuration = Duration;
23 this.Easing = Easing ?? throw new ArgumentNullException(nameof(Easing));
24 }
25
29 protected TimeSpan BaseDuration { get; }
30
34 protected Easing Easing { get; }
35
37 public abstract Task RunAsync(VisualElement Target, IAnimationContext Context, AnimationOptions? Options, CancellationToken Token);
38
45 protected TimeSpan ResolveDuration(IAnimationContext Context, AnimationOptions? Options)
46 {
47 if (Options?.DurationOverride is TimeSpan Override)
48 return Override;
49
50 double Scale = Context.DurationScale <= 0 ? 1 : Context.DurationScale;
51 double Milliseconds = this.BaseDuration.TotalMilliseconds * Scale;
52 if (Milliseconds < 0)
53 Milliseconds = 0;
54 return TimeSpan.FromMilliseconds(Milliseconds);
55 }
56
64 {
65 TimeSpan Duration = this.ResolveDuration(Context, Options);
66 double Milliseconds = Math.Round(Duration.TotalMilliseconds);
67 if (Milliseconds < 0)
68 Milliseconds = 0;
69 return (uint)Milliseconds;
70 }
71 }
72}
Options applied for an individual animation execution.
Base class providing timing helpers for view animations.
TimedViewAnimation(TimeSpan Duration, Easing Easing)
Initializes a new instance of the TimedViewAnimation class.
uint ResolveDurationMilliseconds(IAnimationContext Context, AnimationOptions? Options)
Resolves the duration expressed in milliseconds.
TimeSpan BaseDuration
Gets the base duration.
abstract Task RunAsync(VisualElement Target, IAnimationContext Context, AnimationOptions? Options, CancellationToken Token)
Executes the animation against the specified target. Task tracking execution.
TimeSpan ResolveDuration(IAnimationContext Context, AnimationOptions? Options)
Resolves the effective duration, respecting overrides and duration scale.
Represents contextual information required when executing an animation.
double DurationScale
Gets the multiplier applied to animation durations.
Defines a view-based animation executor.