private void UpdateNextItem()
        {
            var sb = new Windows.UI.Xaml.Media.Animation.Storyboard();

            if (_translate != null)
            {
                var anim = new Windows.UI.Xaml.Media.Animation.DoubleAnimation();
                anim.Duration = new Duration(TimeSpan.FromMilliseconds(500));
                anim.From     = 0;
                if (Direction == LiveTile.SlideDirection.Up)
                {
                    anim.To = -this.ActualHeight;
                }
                else if (Direction == LiveTile.SlideDirection.Left)
                {
                    anim.To = -this.ActualWidth;
                }

                anim.FillBehavior   = Windows.UI.Xaml.Media.Animation.FillBehavior.HoldEnd;
                anim.EasingFunction = new Windows.UI.Xaml.Media.Animation.CubicEase()
                {
                    EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseOut
                };
                Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(anim, _translate);
                if (Direction == LiveTile.SlideDirection.Up
                    // || this.SlideDirection == SlideView.SlideDirection.Down
                    )
                {
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "Y");
                }
                else
                {
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "X");
                }
                sb.Children.Add(anim);
            }
            sb.Completed += (a, b) =>
            {
                //Reset back and swap images, getting the next image ready
                if (_currentElement != null)
                {
                    _currentElement.DataContext = GetCurrent();
                }
                DispatcherTimer timer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromMilliseconds(250)
                };                                                                                                           //Give the next panel a little time to load
                timer.Tick += (s, e) =>
                {
                    timer.Stop();
                    sb.Stop();                     //Also resets transform
                    if (_nextElement != null)
                    {
                        _nextElement.DataContext = GetNext();
                    }
                };
                timer.Start();
            };
            sb.Begin();
        }
예제 #2
0
        private void mediaElement_Tapped(object sender, TappedRoutedEventArgs e)
        {
            MediaPlayerElement loc = sender as MediaPlayerElement;

            if (loc != null)
            {
                if (bMin == true)
                {
                    Windows.UI.Xaml.Media.Animation.Storyboard lmax = loc.Resources["MyStoryboardMax"] as Windows.UI.Xaml.Media.Animation.Storyboard;
                    if (lmax != null)
                    {
                        foreach (var a in lmax.Children)
                        {
                            Windows.UI.Xaml.Media.Animation.DoubleAnimation da = a as Windows.UI.Xaml.Media.Animation.DoubleAnimation;
                            if (da != null)
                            {
                                double w = Window.Current.Bounds.Width;
                                da.To = w / 320;
                            }
                        }
                        lmax.Begin();
                    }
                }
                else
                {
                    Windows.UI.Xaml.Media.Animation.Storyboard lmin = loc.Resources["MyStoryboardMin"] as Windows.UI.Xaml.Media.Animation.Storyboard;
                    lmin.Begin();
                }
            }
            bMin = !bMin;
        }
예제 #3
0
 private void Image_ImageOpened(object sender, RoutedEventArgs e)
 {
     Windows.UI.Xaml.Media.Animation.DoubleAnimation opacityanimation = new Windows.UI.Xaml.Media.Animation.DoubleAnimation();
     opacityanimation.Duration = new TimeSpan(0, 0, 0, 0, 500);
     opacityanimation.From     = 0;
     opacityanimation.To       = 1;
     Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(opacityanimation, (DependencyObject)sender);
     Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(opacityanimation, "Opacity");
     Windows.UI.Xaml.Media.Animation.Storyboard storyboard = new Windows.UI.Xaml.Media.Animation.Storyboard();
     storyboard.Children.Add(opacityanimation);
     storyboard.Begin();
 }
예제 #4
0
        private void UpdateNextItem()
        {
            //Check if there's more than one item. if not, don't start animation
            bool hasTwoOrMoreItems = false;

            if (ItemsSource is IEnumerable)
            {
                var enumerator = (ItemsSource as IEnumerable).GetEnumerator();
                int count      = 0;
                while (enumerator.MoveNext())
                {
                    count++;
                    if (count > 1)
                    {
                        hasTwoOrMoreItems = true;
                        break;
                    }
                }
            }
            if (!hasTwoOrMoreItems)
            {
                return;
            }
            var sb = new Windows.UI.Xaml.Media.Animation.Storyboard();

            if (_translate != null)
            {
                var anim = new Windows.UI.Xaml.Media.Animation.DoubleAnimation();
                anim.Duration = new Duration(TimeSpan.FromMilliseconds(500));
                anim.From     = 0;
                if (Direction == LiveTile.SlideDirection.Up)
                {
                    anim.To = -this.ActualHeight;
                }
                else if (Direction == LiveTile.SlideDirection.Left)
                {
                    anim.To = -this.ActualWidth;
                }

                anim.FillBehavior   = Windows.UI.Xaml.Media.Animation.FillBehavior.HoldEnd;
                anim.EasingFunction = new Windows.UI.Xaml.Media.Animation.CubicEase()
                {
                    EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseOut
                };
                Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(anim, _translate);
                if (Direction == LiveTile.SlideDirection.Up
                    // || this.SlideDirection == SlideView.SlideDirection.Down
                    )
                {
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "Y");
                }
                else
                {
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "X");
                }
                sb.Children.Add(anim);
            }
            sb.Completed += (a, b) =>
            {
                //Reset back and swap images, getting the next image ready
                sb.Stop();
                if (_translate != null)
                {
                    _translate.X = _translate.Y = 0;
                }
                if (_currentElement != null)
                {
                    _currentElement.DataContext = GetCurrent();
                }
                if (_nextElement != null)
                {
                    _nextElement.DataContext = GetNext();
                }
            };
            sb.Begin();
        }
예제 #5
0
        private void UpdateNextItem()
        {
            //Check if there's more than one item. if not, don't start animation
            bool hasTwoOrMoreItems = false;
            if (ItemsSource is IEnumerable)
            {
                var enumerator = (ItemsSource as IEnumerable).GetEnumerator();
                int count = 0;
                while(enumerator.MoveNext())
                {
                    count++;
                    if (count > 1)
                    {
                        hasTwoOrMoreItems = true;
                        break;
                    }
                }
            }
            if (!hasTwoOrMoreItems)
                return;
            var sb = new Windows.UI.Xaml.Media.Animation.Storyboard();
            if (_translate != null)
            {
                var anim = new Windows.UI.Xaml.Media.Animation.DoubleAnimation();
                anim.Duration = new Duration(TimeSpan.FromMilliseconds(500));
                anim.From = 0;
                if(Direction == LiveTile.SlideDirection.Up)
                    anim.To = -this.ActualHeight;
                else if (Direction == LiveTile.SlideDirection.Left)
                    anim.To = -this.ActualWidth;

                anim.FillBehavior = Windows.UI.Xaml.Media.Animation.FillBehavior.HoldEnd;
                anim.EasingFunction = new Windows.UI.Xaml.Media.Animation.CubicEase() { EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseOut };
                Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(anim, _translate);
                if(Direction == LiveTile.SlideDirection.Up
                    // || this.SlideDirection == SlideView.SlideDirection.Down
                    )
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "Y");
                else
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "X");
                sb.Children.Add(anim);
            }
            sb.Completed += (a, b) =>
            {
                //Reset back and swap images, getting the next image ready
                sb.Stop();
                if (_translate != null)
                {
                    _translate.X = _translate.Y = 0;
                }
                if(_currentElement != null)
                    _currentElement.DataContext = GetCurrent();
                if(_nextElement != null)
                    _nextElement.DataContext = GetNext();
            };
            sb.Begin();
        }
예제 #6
0
        private void UpdateNextItem()
        {
            var sb = new Windows.UI.Xaml.Media.Animation.Storyboard();
            if (_translate != null)
            {
                var anim = new Windows.UI.Xaml.Media.Animation.DoubleAnimation();
                anim.Duration = new Duration(TimeSpan.FromMilliseconds(500));
                anim.From = 0;
                if(Direction == LiveTile.SlideDirection.Up)
                    anim.To = -this.ActualHeight;
                else if (Direction == LiveTile.SlideDirection.Left)
                    anim.To = -this.ActualWidth;

                anim.FillBehavior = Windows.UI.Xaml.Media.Animation.FillBehavior.HoldEnd;
                anim.EasingFunction = new Windows.UI.Xaml.Media.Animation.CubicEase() { EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseOut };
                Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(anim, _translate);
                if(Direction == LiveTile.SlideDirection.Up
                    // || this.SlideDirection == SlideView.SlideDirection.Down
                    )
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "Y");
                else
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(anim, "X");
                sb.Children.Add(anim);
            }
            sb.Completed += (a, b) =>
            {
                //Reset back and swap images, getting the next image ready
                sb.Stop();
                if (_translate != null)
                {
                    _translate.X = _translate.Y = 0;
                }
                if(_currentElement != null)
                    _currentElement.DataContext = GetCurrent();
                if(_nextElement != null)
                    _nextElement.DataContext = GetNext();
            };
            sb.Begin();
        }