private void rotate()
 {
     foreach (Image item in Display.Children)
     {
         double angle = (double)item.Tag;
         angle   -= speed;
         item.Tag = angle;
         point.X  = Math.Cos(angle) * radius.X;
         point.Y  = Math.Sin(angle) * radius.Y;
         Canvas.SetLeft(item, point.X - (item.Width - perspective));
         Canvas.SetTop(item, point.Y);
         if (radius.X >= 0)
         {
             distance = 1 * (1 - (point.X / perspective));
             Canvas.SetZIndex(item, -(int)(point.X));
         }
         else
         {
             distance = 1 / (1 - (point.X / perspective));
             Canvas.SetZIndex(item, (int)(point.X));
         }
         item.Opacity = ((ScaleTransform)item.RenderTransform).ScaleX =
             ((ScaleTransform)item.RenderTransform).ScaleY = distance;
     }
     animation.Begin();
 }
        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();
        }
Example #3
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;
        }
Example #4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected async override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            pageTitle.Text = "Articles tagged \"" + App.page_title + "\"";
            navParam       = navigationParameter.ToString();
            ViewCommentsButton.Visibility = Visibility.Collapsed;
            progressRing.Visibility       = Visibility.Visible;
            Windows.UI.Xaml.Media.Animation.Storyboard sb =
                this.FindName("PopInStoryBoard") as Windows.UI.Xaml.Media.Animation.Storyboard;
            if (sb != null)
            {
                sb.Begin();
            }

            // TODO: Assign a bindable group to this.DefaultViewModel["Group"]
            // TODO: Assign a collection of bindable items to this.DefaultViewModel["Items"]
            FeedDataSource feedDataSource = (FeedDataSource)App.Current.Resources["feedDataSource"];

            if (feedDataSource != null)
            {
                await feedDataSource.GetFeedsAsync("tag", navigationParameter.ToString());
            }
            RootObject feedData = FeedDataSource.GetFeed();

            if (feedData != null)
            {
                this.DefaultViewModel["Feed"]  = feedData;
                this.DefaultViewModel["Items"] = feedData.posts;
            }

            if (pageState == null)
            {
                // When this is a new page, select the first item automatically unless logical page
                // navigation is being used (see the logical page navigation #region below.)
                if (!this.UsingLogicalPageNavigation() && this.itemsViewSource.View != null)
                {
                    this.itemsViewSource.View.MoveCurrentToFirst();
                }
                else
                {
                    //this.itemsViewSource.View.MoveCurrentToPosition(-1);
                }
            }
            else
            {
                // Restore the previously saved state associated with this page
                if (pageState.ContainsKey("SelectedItem") && this.itemsViewSource.View != null)
                {
                    // TODO: Invoke this.itemsViewSource.View.MoveCurrentTo() with the selected
                    //       item as specified by the value of pageState["SelectedItem"]
                    string itemTitle    = (string)pageState["SelectedItem"];
                    Post   selectedItem = FeedDataSource.GetItem(itemTitle);
                    this.itemsViewSource.View.MoveCurrentTo(selectedItem);
                }
            }
            ViewCommentsButton.Visibility = Visibility.Visible;
            progressRing.Visibility       = Visibility.Collapsed;
        }
Example #5
0
        private void LoadStoryBoardSwitch()
        {
            //ToGridView
            _sbDetailOFF = new Windows.UI.Xaml.Media.Animation.Storyboard();
            _sbDetailOFF.Children.Add(WinAppLibrary.Utilities.AnimationHelper.CreateTranslateXAnimation(detailPanelTrans, Window.Current.Bounds.Width, ANIMATION_SPEED));
            _sbDetailOFF.Begin();

            _sbDetailON = new Windows.UI.Xaml.Media.Animation.Storyboard();
            _sbDetailON.Children.Add(WinAppLibrary.Utilities.AnimationHelper.CreateScaleYAnimation(detailPanelScale, 1, 0));
            _sbDetailON.Children.Add(WinAppLibrary.Utilities.AnimationHelper.CreateTranslateXAnimation(detailPanelTrans, 0, ANIMATION_SPEED));
        }
 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();
 }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Run the PopInThemeAnimation
            Windows.UI.Xaml.Media.Animation.Storyboard sb =
                this.FindName("PopInStoryboard") as Windows.UI.Xaml.Media.Animation.Storyboard;
            if (sb != null)
            {
                sb.Begin();
            }

            // TODO: Assign a bindable group to this.DefaultViewModel["Group"]
            // TODO: Assign a collection of bindable items to this.DefaultViewModel["Items"]
            string   feedTitle = (string)navigationParameter;
            FeedData feedData  = FeedDataSource.GetFeed(feedTitle);

            if (feedData != null)
            {
                this.DefaultViewModel["Feed"]  = feedData;
                this.DefaultViewModel["Items"] = feedData.Items;
            }

            if (pageState == null)
            {
                // When this is a new page, select the first item automatically unless logical page
                // navigation is being used (see the logical page navigation #region below.)
                if (!this.UsingLogicalPageNavigation() && this.itemsViewSource.View != null)
                {
                    this.itemsViewSource.View.MoveCurrentToFirst();
                }
                else
                {
                    this.itemsViewSource.View.MoveCurrentToPosition(-1);
                }
            }
            else
            {
                // Restore the previously saved state associated with this page
                if (pageState.ContainsKey("SelectedItem") && this.itemsViewSource.View != null)
                {
                    // TODO: Invoke this.itemsViewSource.View.MoveCurrentTo() with the selected
                    //       item as specified by the value of pageState["SelectedItem"]
                    string   itemTitle    = (string)pageState["SelectedItem"];
                    FeedItem selectedItem = FeedDataSource.GetItem(itemTitle);
                    this.itemsViewSource.View.MoveCurrentTo(selectedItem);
                }
            }
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Run the PopInThemeAnimation
            Windows.UI.Xaml.Media.Animation.Storyboard sb =
                this.FindName("PopInStoryboard") as Windows.UI.Xaml.Media.Animation.Storyboard;
            if (sb != null)
            {
                sb.Begin();
            }

            // Add this code to navigate the web view to the selected blog post.
            string   itemTitle = (string)navigationParameter;
            FeedItem feedItem  = FeedDataSource.GetItem(itemTitle);

            if (feedItem != null)
            {
                this.contentView.Navigate(feedItem.Link);
                this.DataContext = feedItem;
            }
        }
Example #9
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();
        }
Example #10
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();
        }
Example #11
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();
        }