private void InitializeAnimation() { // Load Barlox Animation StreamResourceInfo animData = Application.GetResourceStream(new Uri("Assets/chibi-small.ibxa", UriKind.Relative)); animation = new BarloxAnimation(animData.Stream); animation.FrameChanged += (@s, e) => { AnimationImage.Source = e.NewFrame.Source; }; animation.IsEnabled = true; // Attach interactivity AnimationImage.Tap += (@s, e) => animation.TriggerEvent("poke"); AnimationImage.DoubleTap += (@s, e) => animation.TriggerEvent("knock"); }
public PostView() { // Create ViewModel viewModel = new PostViewModel(this); DataContext = viewModel; viewModel.ChangeState += (@s, e) => { if (e.State == PostViewModel.NoCommentState) { NoCommentTextBlock.Visibility = Visibility.Visible; } if (e.State == PostViewModel.BrowserNavigateState) { PostBrowser.NavigateToString(viewModel.PostTemplate); } if (e.State == PostViewModel.FavoriteChangedState) { ReloadFavButton(); } VisualStateManager.GoToState(this, e.State, e.Transition); }; viewModel.Post = NavigationHelper.NavigationArgument as Post; // Initialize UI InitializeComponent(); ApplicationBar.IsVisible = false; // Load Barlox Animation StreamResourceInfo animData = Application.GetResourceStream(new Uri("Assets/chibi-small.ibxa", UriKind.Relative)); animation = new BarloxAnimation(animData.Stream); animation.FrameChanged += (@s, e) => { LoadingAnimationImage.Source = e.NewFrame.Source; }; animation.IsEnabled = true; LoadingAnimationImage.Tap += (@s, e) => animation.TriggerEvent("poke"); // Attach Loaded Handler Loaded += (@s, e) => PageLoaded(); PivotRoot.SelectionChanged += (@s, e) => { ApplicationBar.IsVisible = PivotRoot.SelectedIndex == 0; }; // Attach Post Browser Handlers PostBrowser.LoadCompleted += (@s, e) => { VisualStateManager.GoToState(this, "LoadedState", true); animation.IsEnabled = false; PivotRoot.IsLocked = false; ApplicationBar.IsVisible = true; ReloadFavButton(); }; PostBrowser.NavigationFailed += (@s, e) => { // Should never fire. Logging.D("ViewPost: Navigation Failed"); Debugger.Break(); }; PostBrowser.ScriptNotify += (@s, e) => { MessageBox.Show( "It seems like this image cannot be loaded at this time. Maybe you should try again later.", "We've got some problems", MessageBoxButton.OK); NavigationService.GoBack(); }; }