private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     _position = new Computed<TimeSpan>(() =>
         ForView.Unwrap<MyCommuteViewModel, TimeSpan>(DataContext,
             vm => vm.Position))
         .Subscribe(SetMediaElementPosition);
 }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     ForView.Unwrap<OnboardingViewModel>(DataContext, vm =>
     {
         _lastException = new Computed<string>(() => vm.LastException);
         _subscription = _lastException.Subscribe(v => { if (v != null) { ShowError.Begin(); } });
     });
 }
 public MediaCacheService(
     CommuterApplication application,
     Func<Queue, MediaDownloader> createMediaDownloader)
 {
     var mediaDownloaders = new ComputedList<MediaDownloader>(() =>
         application.Root?.QueuedEpisodes.Select(e =>
             createMediaDownloader(e))
             .ToImmutableList() ?? ImmutableList<MediaDownloader>.Empty);
     var dowloadersToStart = new Computed<ImmutableList<MediaDownloader>>(() =>
         mediaDownloaders.Where(d => d.ShouldStart).ToImmutableList());
     _subscribeToStart = dowloadersToStart.Subscribe(StartDownloaders);
 }
 private void Page_Unloaded(object sender, RoutedEventArgs e)
 {
     if (_subscription != null)
     {
         _subscription.Unsubscribe();
         _subscription = null;
     }
     if (_lastException != null)
     {
         _lastException.Dispose();
         _lastException = null;
     }
 }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     ForView.Unwrap<SubscriptionViewModel>(DataContext, vm =>
     {
         _state = new Computed<string>(() => vm.HasSelectedSubscription
             ? "ShowDetail"
             : "ShowMaster");
         _stateSubscription = _state.Subscribe(s =>
         {
             VisualStateManager.GoToState(this, s, _isInitialized);
             _isInitialized = true;
         });
     });
 }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ForView.Unwrap<SearchViewModel>(DataContext, vm =>
            {
                _state = new Computed<string>(() => vm.HasSelectedSearchResult
                    ? "ShowDetail"
                    : "ShowMaster");
                _stateSubscription = _state.Subscribe(s =>
                {
                    VisualStateManager.GoToState(this, s, _isInitialized);
                    _isInitialized = true;
                });

                _lastException = new Computed<string>(() => vm.LastException);
                _subscription = _lastException.Subscribe(v => { if (v != null) { ShowError.Begin(); } });
            });
        }
Exemple #7
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            #if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
            #endif

            _rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (_rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                _rootFrame = new Frame();
                _rootFrame.ContentTransitions = new TransitionCollection();
                _rootFrame.ContentTransitions.Add(new NavigationThemeTransition()
                {
                    DefaultNavigationTransitionInfo = new DrillInNavigationTransitionInfo()
                });

                _rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = _rootFrame;
            }
            // Ensure the current window is active
            Window.Current.Activate();

            _pageStackSubscription = _pageStack.Subscribe(NavigatePageStack);

            ForView.Initialize();
        }