Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
IMotionSettings.cs
1using System;
2
4{
8 public interface IMotionSettings
9 {
13 event EventHandler? MotionSettingsChanged;
14
18 bool ReduceMotion { get; }
19
23 double DurationScale { get; }
24
30 void Update(bool ReduceMotion, double DurationScale);
31 }
32
36 public sealed class MotionSettings : IMotionSettings
37 {
38 private bool reduceMotion;
39 private double durationScale = 1.0;
40
42 public event EventHandler? MotionSettingsChanged;
43
45 public bool ReduceMotion => this.reduceMotion;
46
48 public double DurationScale => this.durationScale;
49
51 public void Update(bool ReduceMotion, double DurationScale)
52 {
53 if (DurationScale <= 0)
54 throw new ArgumentOutOfRangeException(nameof(DurationScale), "Duration scale must be greater than zero.");
55
56 bool ReduceMotionChanged = this.reduceMotion != ReduceMotion;
57 bool DurationChanged = Math.Abs(this.durationScale - DurationScale) > double.Epsilon;
58
59 if (!ReduceMotionChanged && !DurationChanged)
60 return;
61
62 this.reduceMotion = ReduceMotion;
63 this.durationScale = DurationScale;
64
65 this.MotionSettingsChanged?.Invoke(this, EventArgs.Empty);
66 }
67 }
68}
Default implementation of IMotionSettings.
double DurationScale
Gets the multiplier applied to animation durations.
void Update(bool ReduceMotion, double DurationScale)
Updates the motion settings.
bool ReduceMotion
Gets a value indicating whether reduce-motion is enabled.
Represents motion preferences that affect animation execution.
void Update(bool ReduceMotion, double DurationScale)
Updates the motion settings.
EventHandler? MotionSettingsChanged
Event raised when settings change.
bool ReduceMotion
Gets a value indicating whether reduce-motion is enabled.
double DurationScale
Gets the multiplier applied to animation durations.