예제 #1
0
        public void MouseLeave()
        {
            if (ME == null)
            {
                return;
            }
            DoubleAnimation animation = new DoubleAnimation();

            animation.From     = ME.Opacity;
            animation.To       = 1;
            animation.Duration = TimeSpan.FromSeconds(0.3);
            ME.BeginAnimation(FrameworkElement.OpacityProperty, animation);
        }
예제 #2
0
        public void StartMusic()
        {
            musicPlayer.Play();

            DoubleAnimation newAnimation = new DoubleAnimation();

            newAnimation.From        = musicPlayer.Volume;
            newAnimation.To          = 0.5;
            newAnimation.Duration    = new System.Windows.Duration(TimeSpan.FromSeconds(2));
            newAnimation.AutoReverse = false;

            musicPlayer.BeginAnimation(MediaElement.VolumeProperty, newAnimation, HandoffBehavior.SnapshotAndReplace);
        }
예제 #3
0
        private RoutedEventHandler CurrentControlOnMediaOpened(MediaElement lastControl)
        {
            return(delegate(object j, RoutedEventArgs y)
            {
                this.CurrentControl.Visibility = Visibility.Visible;

                DoubleAnimation animation = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromMilliseconds(1300.0)));

                DoubleAnimation animation2 = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromMilliseconds(1300.0)));

                animation.AutoReverse = false;

                animation2.AutoReverse = false;

                animation2.Completed += delegate(object f, EventArgs k)
                {
                    lastControl.Stop();

                    lastControl.Visibility = Visibility.Hidden;
                };

                animation.Completed += delegate(object f, EventArgs k)
                {
                    lastControl.Stop();

                    lastControl.Visibility = Visibility.Hidden;
                };

                lastControl.BeginAnimation(UIElement.OpacityProperty, animation2);

                this.CurrentControl.BeginAnimation(UIElement.OpacityProperty, animation);
            });
        }
예제 #4
0
        private void fadeGif(bool fadeIn)
        {
            int             to = fadeIn ? 1 : 0;
            DoubleAnimation myDoubleAnimation = new DoubleAnimation(to, TimeSpan.FromMilliseconds(1500));

            myDoubleAnimation.AutoReverse = false;
            gifPlayer.BeginAnimation(MediaElement.OpacityProperty, myDoubleAnimation);
        }
예제 #5
0
        /// <summary>
        /// Плавно изменяет громкость медиаэлемента
        /// </summary>
        /// <param name="Media">Медиаэлемент</param>
        /// <param name="volume">Конечный уровень громкости</param>
        /// <param name="timeInSec">Время за которое должна измениться громкость</param>
        /// <param name="AnimationCompleted">Обработчик события окончания анимации типа EventHandler </param>
        public static void SlowDifferVolume(MediaElement Media, double volume, double timeInSec, EventHandler AnimationCompleted)
        {
            DoubleAnimation A = new DoubleAnimation();

            A.From       = Media.Volume;
            A.To         = volume;
            A.Duration   = TimeSpan.FromSeconds(timeInSec);
            A.Completed += AnimationCompleted;
            Media.BeginAnimation(MediaElement.VolumeProperty, A);
        }
예제 #6
0
        void ClipChanged(Clip newClip)
        {
            if (inTransition)
            {
                waitingClip = newClip;
                return;
            }

            MediaElement oldMedia = currentMediaElement;

            currentMediaElement = new MediaElement()
            {
                Source = new Uri(newClip.FilePath), LoadedBehavior = MediaState.Manual, Volume = 0
            };

            if (firstTime)
            {
                currentBorder.Child        = currentMediaElement;
                currentMediaElement.Volume = 1;
                //currentMediaElement.Play();
                firstTime = false;
                return;
            }

            inTransition = true;

            Duration animationDuration = new Duration(CrossfadeTime - TimeSpan.FromSeconds(0.2));

            DoubleAnimation animation = new DoubleAnimation(0, 1, animationDuration);

            animation.Completed += new EventHandler(animation_Completed);
            nextBorder.BeginAnimation(MediaElement.OpacityProperty, animation);

            currentMediaElement.BeginAnimation(MediaElement.VolumeProperty, new DoubleAnimation(0, 1, animationDuration));
            oldMedia.BeginAnimation(MediaElement.VolumeProperty, new DoubleAnimation(1, 0, animationDuration));

            nextBorder.Child = currentMediaElement;
            currentMediaElement.Play();
            IsPlaying = true;

            Border temp = currentBorder;

            currentBorder = nextBorder;
            nextBorder    = temp;
        }