示例#1
0
        /// <summary>
        /// Fade out opacity of the window, let the progress ring disappear and set to visible the NoMouvieFound label when movies are loaded
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">EventArgs</param>
        private void OnMoviesLoaded(object sender, NumberOfLoadedMoviesEventArgs e)
        {
            // We have to deal with the DispatcherHelper, otherwise we're having the classic cross-thread access exception
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                // We exclude exceptions like TaskCancelled when getting back results
                if ((e.NumberOfMovies == 0 && !e.IsExceptionThrown) || (e.NumberOfMovies != 0 && !e.IsExceptionThrown))
                {
                    ProgressRing.IsActive = false;

                    #region Fade out opacity
                    DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
                    opacityAnimation.Duration               = new Duration(TimeSpan.FromSeconds(0.5));
                    PowerEase opacityEasingFunction         = new PowerEase();
                    opacityEasingFunction.EasingMode        = EasingMode.EaseInOut;
                    EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(0.2, KeyTime.FromPercent(0));
                    EasingDoubleKeyFrame endOpacityEasing   = new EasingDoubleKeyFrame(1, KeyTime.FromPercent(1.0),
                                                                                       opacityEasingFunction);
                    opacityAnimation.KeyFrames.Add(startOpacityEasing);
                    opacityAnimation.KeyFrames.Add(endOpacityEasing);
                    ItemsList.BeginAnimation(OpacityProperty, opacityAnimation);
                    #endregion
                }

                var vm = DataContext as MoviesViewModel;
                if (vm != null)
                {
                    // If we searched movies and there's no result, display the NoMovieFound label (we exclude exceptions like TaskCancelled when getting back results)
                    if (!vm.Movies.Any() && e.NumberOfMovies == 0 && !e.IsExceptionThrown)
                    {
                        NoMouvieFound.Visibility = Visibility.Visible;
                    }
                }
            });
        }
示例#2
0
        /// <summary>
        /// Fade in opacity of the window, let the progress ring appear and collapse the NoMouvieFound label when loading movies
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">EventArgs</param>
        private void OnMoviesLoading(object sender, EventArgs e)
        {
            // We have to deal with the DispatcherHelper, otherwise we're having the classic cross-thread access exception
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                ProgressRing.IsActive = true;

                #region Fade in opacity
                DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
                opacityAnimation.Duration               = new Duration(TimeSpan.FromSeconds(0.5));
                PowerEase opacityEasingFunction         = new PowerEase();
                opacityEasingFunction.EasingMode        = EasingMode.EaseInOut;
                EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(1, KeyTime.FromPercent(0));
                EasingDoubleKeyFrame endOpacityEasing   = new EasingDoubleKeyFrame(0.2, KeyTime.FromPercent(1.0),
                                                                                   opacityEasingFunction);
                opacityAnimation.KeyFrames.Add(startOpacityEasing);
                opacityAnimation.KeyFrames.Add(endOpacityEasing);
                ItemsList.BeginAnimation(OpacityProperty, opacityAnimation);
                #endregion

                if (NoMouvieFound.Visibility == Visibility.Visible)
                {
                    NoMouvieFound.Visibility = Visibility.Collapsed;
                }
            });
        }