public void OnDirectionChanged(Direction oldDirection, Direction newDirection) { if (Bookshelf == null || Book3D == null) { throw new ArgumentException("bookshelf and book3d arguments cannot be null"); } if (newDirection == Direction.Center) { LastNextBook3D = NextBook3D; NextBook3D = Book3D; SwipeMode = SwipeMode.Book; } else { if (NextBook3D != null && NextBook3D.Model != null) { NextBook3D.Visibility = true; } NextBookIndex = Bookshelf.Books3D.Items.IndexOf(Book3D); if (newDirection == Direction.Left) { NextBookIndex--; } if (newDirection == Direction.Right) { NextBookIndex++; } if (NextBookIndex > 0 && NextBookIndex < Bookshelf.Books3D.Items.Count && Bookshelf.Books3D.Items.ElementAt(NextBookIndex).Model != null) { SwipeMode = SwipeMode.Book; NextBook3D = (Book3DViewModel)Bookshelf.Books3D.Items.ElementAt(NextBookIndex); } else { SwipeMode = SwipeMode.Shelf; } } if (SwipeMode == SwipeMode.Book) { var book = HBS.CreateBook(NextBook3D); openBookTransition = new OpenBookTransition(NextBook3D, book); //only left or right would actually open a new book if (newDirection != Direction.Center) { openBookTransition.OnTransitionStarting(); } activeTransition = openBookTransition; } if (SwipeMode == SwipeMode.Shelf) { activeTransition = new ShelfSwipeTransition(HBS.ViewModel.ShelfViewModel); HBS.ViewModel.BookFlyout3dVM.Visibility = false; } }
public void HandleIntent(Intent intent) { if (HBS.ViewModel.Opened.BookVM.Book == null && !HBS.IsAnimating) { var Book3D = intent.GetExtra <Book3DViewModel>("book3D"); var book = HBS.CreateBook(Book3D); Transition.Animate(new OpenBookTransition(Book3D, book), 1, HBS.AnimationSeconds, HBS.AnimationEaseInOut); } }