public void UpdateAction(ChatAction action)
        {
            var type = GetAnimationType(action);

            if (type == _action)
            {
                return;
            }

            if (_previous != null)
            {
                _previous.Dispose();
                _previous = null;
            }

            if (_props != null)
            {
                _props.Dispose();
                _props = null;
            }

            var color  = Fill?.Color ?? Colors.Black;
            var visual = GetVisual(type, Window.Current.Compositor, color, out _props);

            _action   = type;
            _previous = visual;

            ElementCompositionPreview.SetElementChildVisual(this, visual?.RootVisual);
            InvalidateArrange();
        }
        public DownloadsIndicator()
        {
            DefaultStyleKey = typeof(DownloadsIndicator);

            var compositor = Window.Current.Compositor;
            var source     = new Downloading();

            var visual = source.TryCreateAnimatedVisual(compositor, out _);

            if (visual == null)
            {
                return;
            }

            _visual = visual;
            _visual.RootVisual.Scale = new System.Numerics.Vector3(0.1f, 0.1f, 1);
            _visualSource            = source;

            ThemeChanged();

            var linearEasing = compositor.CreateLinearEasingFunction();

            _animation          = compositor.CreateScalarKeyFrameAnimation();
            _animation.Duration = visual.Duration;
            _animation.InsertKeyFrame(1, 60f / 90f, linearEasing);
            //animation.IterationBehavior = AnimationIterationBehavior.Forever;

            _properties = compositor.CreatePropertySet();
            _properties.InsertScalar("Progress", 30f / 90f);

            var progressAnimation = compositor.CreateExpressionAnimation("_.Progress");

            progressAnimation.SetReferenceParameter("_", _properties);
            visual.RootVisual.Properties.InsertScalar("Progress", 0.0F);
            visual.RootVisual.Properties.StartAnimation("Progress", progressAnimation);

            ActualThemeChanged += OnActualThemeChanged;
        }
 public SimplePlayer(Compositor c)
 {
     _compositor     = c;
     targetAnimation = new T();
     _animatedVisual = targetAnimation.TryCreateAnimatedVisual(_compositor, out diagnostics);
 }