コード例 #1
0
        public void Update(AnimatedVisualPlayer player)
        {
            if (player != _player)
            {
                player.RegisterHtmlEventHandler("lottie_state", (EventHandler)OnStateChanged);
            }

            _player = player;

            var js = new[]
            {
                "Uno.UI.Lottie.setAnimationProperties({",
                "elementId:",
                player.HtmlId.ToString(),
                ",jsonPath:\"",
                UriSource?.PathAndQuery ?? "",
                "\",autoplay:",
                player.AutoPlay ? "true" : "false",
                ",stretch:\"",
                player.Stretch.ToString(),
                "\",rate:",
                player.PlaybackRate.ToString(),
                "});"
            };

            WebAssemblyRuntime.InvokeJS(string.Concat(js));
            _isPlaying = player.AutoPlay;
        }
コード例 #2
0
        // Runs the animated splash screen as content for the current window. The
        // returned Task completes when the animation finishes.
        async Task RunAnimatedSplashScreenAsync()
        {
            // Insert splashBorder above the current window content.
            var originalWindowContent = Window.Current.Content;
            var splashBorder          = new Border();

            splashBorder.Background = (SolidColorBrush)Current.Resources["LottieBasicBrush"];

            var player = new AnimatedVisualPlayer
            {
                Stretch  = Stretch.Uniform,
                AutoPlay = false,
                Source   = new LottieLogo(),
            };

            splashBorder.Child = player;

            Window.Current.Content = splashBorder;

            // Start playing.
            await player.PlayAsync(fromProgress : 0, toProgress : 0.599, looped : false);

            // Reset window content after the splashscreen animation has completed.
            Window.Current.Content = originalWindowContent;
        }
コード例 #3
0
        async Task RunAnimatedSplashScreenAsync()
        {
            // Insert splashBorder above the current window content.
            var originalWindowContent = Window.Current.Content;

            var splashBorder = new Border();

            splashBorder.Background = (SolidColorBrush)Current.Resources["SystemControlHighlightAccentBrush"];

            // Use modified LottieLogo1 animation based on user's accent color.
            var lottieSource = new LottieLogo1_Modified();

            lottieSource.BackgroundColor = (Color)Resources["SystemAccentColor"];
            lottieSource.HighlightColor  = (Color)Resources["SystemAccentColorDark2"];

            // Instantiate Player with modified Source
            var player = new AnimatedVisualPlayer
            {
                Stretch  = Stretch.Uniform,
                AutoPlay = false,
                Source   = lottieSource,
            };

            splashBorder.Child     = player;
            Window.Current.Content = splashBorder;

            // Start playing the splashscreen animation.
            await player.PlayAsync(fromProgress : 0, toProgress : 0.599, looped : false);

            // Reset window content after the splashscreen animation has completed.
            Window.Current.Content = originalWindowContent;
        }
コード例 #4
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.player = (AnimatedVisualPlayer)GetTemplateChild("PART_Indicator");
            this.presenter = (ContentPresenter)GetTemplateChild("PART_BusyContentPresenter");
        }
コード例 #5
0
        private void UpdateStates()
        {
            AnimatedVisualPlayer player = (AnimatedVisualPlayer)Children[0];

            if (this.IsActive)
            {
                player.Opacity = 1;

                if (this.ShowPaused)
                {
                    player.Pause();
                }
                else if (this.IsIndeterminate)
                {
                    _ = player.PlayAsync(0, 1, IsLooping);
                }
                else if (!this.IsIndeterminate)
                {
                    player.SetProgress(ProgressPosition);
                }
            }
            else
            {
                player.Stop();
                player.Opacity = 0;
            }
        }
コード例 #6
0
        public void Update(AnimatedVisualPlayer player)
        {
            if (_animation == null)
            {
                _animation = new LottieAnimationView(Android.App.Application.Context);
                _animation.EnableMergePathsForKitKatAndAbove(true);
                _animation.UseHardwareAcceleration(UseHardwareAcceleration);

                //_animation.Scale = (float)Scale;
                SetProperties();

                player.AddView(_animation);
            }
            else
            {
                SetProperties();
            }

            void SetProperties()
            {
                _animation.SetAnimation(UriSource?.PathAndQuery ?? "");

                if (player.AutoPlay && !_isPlaying)
                {
                    Play(true);
                }
            }

            _player = player;
        }
コード例 #7
0
        partial void InnerUpdate()
        {
            var player = _player;

            if (_initializedPlayer != player)
            {
                player.RegisterHtmlCustomEventHandler("lottie_state", OnStateChanged, isDetailJson: false);
                _initializedPlayer = player;
            }

            var js = new[]
            {
                "Uno.UI.Lottie.setAnimationProperties({",
                "elementId:",
                player.HtmlId.ToString(),
                ",jsonPath:\"",
                UriSource?.PathAndQuery ?? "",
                "\",autoplay:",
                player.AutoPlay ? "true" : "false",
                ",stretch:\"",
                player.Stretch.ToString(),
                "\",rate:",
                player.PlaybackRate.ToString(),
                "});"
            };

            WebAssemblyRuntime.InvokeJS(string.Concat(js));
            _isPlaying = player.AutoPlay;
        }
コード例 #8
0
        // Updates the highlighting border around the given player.
        private void UpdatePlayerHighlights(AnimatedVisualPlayer player, bool highlighted)
        {
            var border = player == PlayerA ? PlayerABorder : PlayerBBorder;

            border.BorderBrush = highlighted
                ? (Brush)Resources["SystemControlHighlightAccentBrush"]
                : (Brush)Resources["SystemControlDisabledBaseMediumLowBrush"];
        }
コード例 #9
0
        public void Update(AnimatedVisualPlayer player)
        {
            if (_animation == null)
            {
                _animation = new LOTAnimationView();
                SetProperties();
#if __IOS__
                player.Add(_animation);
#else
                player.AddSubview(_animation);
#endif
            }
            else
            {
                SetProperties();
            }

            void SetProperties()
            {
                var path = UriSource?.PathAndQuery ?? "";

                if (_lastPath != path)
                {
                    _animation.SetAnimationNamed(path);
                    _lastPath = path;
                }

                switch (player.Stretch)
                {
                case Windows.UI.Xaml.Media.Stretch.None:
                    _animation.ContentMode = _ViewContentMode.Center;
                    break;

                case Windows.UI.Xaml.Media.Stretch.Uniform:
                    _animation.ContentMode = _ViewContentMode.ScaleAspectFit;
                    break;

                case Windows.UI.Xaml.Media.Stretch.Fill:
                    _animation.ContentMode = _ViewContentMode.ScaleToFill;
                    break;

                case Windows.UI.Xaml.Media.Stretch.UniformToFill:
                    _animation.ContentMode = _ViewContentMode.ScaleAspectFill;
                    break;
                }

                _animation.AnimationSpeed = (nfloat)player.PlaybackRate;

                if (player.AutoPlay && !_isPlaying)
                {
                    Play(true);
                }
            }

            _player = player;
        }
コード例 #10
0
        private async void TogglePaneButton_Click(object sender, RoutedEventArgs e)
        {
            panelIsOpen = !panelIsOpen;
            //var window = (Style)Application.Current.Resources["MyNavigationViewStyle"];
            //var template = (ControlTemplate)window.Setters[3].GetValue(); // "MyNavigationViewControlTemplate"
            //var a = this.Resources[""]; // MyNavigationViewControlTemplate.GetValue(ContentProperty);
            //MyNavigationViewControlTemplate.GetValue(ContentControl)
            //MyNavigationViewControlTemplate.
            //MyNavigationViewControlTemplate
            //Button button = sender as Button;
            //Grid grid = (Grid)button.Parent;
            //grid.
            //AnimatedVisualPlayer animatedVisualPlayer = button.Content as AnimatedVisualPlayer;
            //animatedVisualPlayer.AutoPlay = true;

            if (player == null)
            {
                Button button = sender as Button;
                Grid   grid   = (Grid)button.Parent;

                player = grid.Children[2] as AnimatedVisualPlayer;
            }

            if (player.IsPlaying)
            {
                if (panelIsOpen)
                {
                    player.PlaybackRate = -3.5;


                    // await player.PlayAsync(player.currentState, 0.8, false);
                    await player.PlayAsync(0, 0.8, false);
                }
                else
                {
                    player.PlaybackRate = 2;
                    await player.PlayAsync(0, 1, false);
                }
            }
            else
            {
                if (panelIsOpen)
                {
                    player.PlaybackRate = -3.5;
                    await player.PlayAsync(0, 0.8, false);
                }
                else
                {
                    player.PlaybackRate = 2;
                    await player.PlayAsync(0, 1, false);
                }
            }
        }
コード例 #11
0
        private void UpdateStates()
        {
            AnimatedVisualPlayer player = (AnimatedVisualPlayer)Children[0];

            if (this.IsAnimating)
            {
                _ = player.PlayAsync(0, 1, IsLooping);
            }
            else
            {
                player.Stop();
            }
        }
コード例 #12
0
 // Plays the segment on the given player.
 public async Task PlayAsync(AnimatedVisualPlayer player)
 => await player.PlayAsync(FromProgress, ToProgress, Looping);
コード例 #13
0
        public void Update(AnimatedVisualPlayer player)
        {
            if (_animation == null)
            {
                _animation = new LottieAnimationView(Android.App.Application.Context);
                _animation.EnableMergePathsForKitKatAndAbove(true);
                _animation.UseHardwareAcceleration(UseHardwareAcceleration);

                //_animation.Scale = (float)Scale;
                SetProperties();

                player.AddView(_animation);
            }
            else
            {
                SetProperties();
            }

            void SetProperties()
            {
                var path = UriSource?.PathAndQuery ?? "";

                if (path.StartsWith("/"))
                {
                    path = path.Substring(1);
                }
                if (_lastPath != path)
                {
                    _animation.SetAnimation(path);
                    _lastPath = path;
                }

                switch (player.Stretch)
                {
                case Windows.UI.Xaml.Media.Stretch.None:
                    _animation.SetScaleType(ImageView.ScaleType.Center);
                    break;

                case Windows.UI.Xaml.Media.Stretch.Uniform:
                    _animation.SetScaleType(ImageView.ScaleType.CenterInside);
                    break;

                case Windows.UI.Xaml.Media.Stretch.Fill:
                    _animation.SetScaleType(ImageView.ScaleType.FitXy);
                    break;

                case Windows.UI.Xaml.Media.Stretch.UniformToFill:
                    _animation.SetScaleType(ImageView.ScaleType.CenterCrop);
                    break;
                }

                _animation.Speed = (float)player.PlaybackRate;

                if (player.AutoPlay && !_isPlaying)
                {
                    Play(true);
                }
            }

            _player = player;
        }
コード例 #14
0
        private void UpdateProgressPosition(double progressPosition)
        {
            AnimatedVisualPlayer player = (AnimatedVisualPlayer)Children[0];

            player.SetProgress(progressPosition);
        }
コード例 #15
0
        private void UpdateSource(DependencyPropertyChangedEventArgs e)
        {
            AnimatedVisualPlayer player = (AnimatedVisualPlayer)Children[0];

            player.Source = e.NewValue as IAnimatedVisualSource;
        }
コード例 #16
0
        public AnimatedProgressUI()
        {
            AnimatedVisualPlayer player = new AnimatedVisualPlayer();

            Children.Add(player);
        }
コード例 #17
0
 public void Update(AnimatedVisualPlayer player)
 {
 }
コード例 #18
0
        public void RunAnimation(double start, double end, bool loop)
        {
            AnimatedVisualPlayer player = (AnimatedVisualPlayer)Children[0];

            _ = player.PlayAsync(start, end, loop);
        }