public async Task NavigateToCurrentViewModel_Calls_VieModel_OnNavigatedTo()
        {
            await DispatcherHelper.ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());

                bool viewModelNavigatedToCalled = false;
                var viewModel = new MockPageViewModel();
                viewModel.OnNavigatedFromCommand = (a, b) => Assert.IsTrue(true);
                viewModel.OnNavigatedToCommand = (parameter, navigationMode, frameState) =>
                {
                    Assert.AreEqual(NavigationMode.New, navigationMode);
                    viewModelNavigatedToCalled = true;
                };

                // Set up the viewModel to the Page we navigated
                frame.NavigatedTo += (sender, e) =>
                {
                    var view = frame.Content as FrameworkElement;
                    view.DataContext = viewModel;
                };

                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();

                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);

                navigationService.Navigate("Mock", 1);

                Assert.IsTrue(viewModelNavigatedToCalled);
            });
        }
        public static void BuildUp(Frame frame)
        {
            Debug.WriteLine("Bootstrapping begins");

            var navigationService = new FrameNavigationService(frame);
            navigationService.RegisterView("MainPage", typeof(MainPage));
            navigationService.RegisterView("SecondPage", typeof(SecondPage));
            navigationService.RegisterView("GroupedItemsPage", typeof(GroupedItemsPage));

            var x = typeof(MainPage); // Required to force JIT of Pages.dll

            var container = new UnityContainer();

            // Services
            container.RegisterInstance<INavigationService>(navigationService);

            container.RegisterType<IDialogService, DialogService>();
            container.RegisterType<IProtectionService, DPAPIProtectionService>();
            container.RegisterType<ISettingsService, SettingsService>(new InjectionConstructor(SettingsPolicy.Roaming));
            container.RegisterType<ISocialService, FacebookService>();
            container.RegisterType<ISerializerService, XmlSerializerService>();
            container.RegisterType<IStorageService, LocalFolderStorageService>();
            container.RegisterType<IDeviceSpecificsService, DeviceSpecificsService>();

            // ViewModels
            container.RegisterType<IMainViewModel, MainViewModel>();

            // Register container for ViewModelLocator
            var containerWrapper = new UnityContainerWrapper(container);
            container.RegisterInstance<IContainer>(containerWrapper);

            new ServiceLocator(containerWrapper);

            Debug.WriteLine("Bootstrapping ends");
        }
Ejemplo n.º 3
0
        public async Task Navigate_To_Subsequent_Page_Back_Button_Visible()
        {
            await DispatcherHelper.ExecuteOnUIThread(() =>
            {
                var eventAggregator = new EventAggregator();
                var frame = new FrameFacadeAdapter(new Frame(), eventAggregator);
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);
                var deviceGestureService = new DeviceGestureService(eventAggregator);
                deviceGestureService.UseTitleBarBackButton = true;
                var navigationManager = SystemNavigationManager.GetForCurrentView();

                // Reset back button visibility before running, can't do this in TestInitialize because CoreWindow sometimes isn't ready
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;

                Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility);

                navigationService.Navigate("Mock", 1);

                Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility);

                navigationService.Navigate("Mock", 2);

                Assert.AreEqual(AppViewBackButtonVisibility.Visible, navigationManager.AppViewBackButtonVisibility);
            });
        }
        public async Task Navigate_To_Invalid_Page()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();

                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(string), sessionStateService);

                bool result = navigationService.Navigate("Mock", 1);

                Assert.IsFalse(result);
                Assert.IsNull(frame.Content);
            });
        }
        public async Task Navigate_To_Valid_Page()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);

                bool result = navigationService.Navigate("Mock", 1);

                Assert.IsTrue(result);
                Assert.IsNotNull(frame.Content);
                Assert.IsInstanceOfType(frame.Content, typeof(MockPage));
                Assert.AreEqual(1, ((MockPage)frame.Content).PageParameter);
            });
        }
Ejemplo n.º 6
0
        public async Task Navigate_To_Page_With_Null_Aggregator_Still_Works()
        {
            await DispatcherHelper.ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);
                var navigationManager = SystemNavigationManager.GetForCurrentView();

                // Reset back button visibility before running, can't do this in TestInitialize because CoreWindow sometimes isn't ready
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;

                bool result = navigationService.Navigate("Mock", 1);

                Assert.IsTrue(result);
            });
        }
Ejemplo n.º 7
0
 public static void SetFrameNavigationService(DependencyObject obj, FrameNavigationService value)
 {
     obj.SetValue(FrameNavigationServiceProperty, value);
 }
Ejemplo n.º 8
0
        public XboxShellView()
        {
            this.InitializeComponent();

            uiSettings = new Windows.UI.ViewManagement.UISettings();

            ///Set up navigation
            inlineNavigationService = WindowManager.GetNavigationManagerForCurrentView().RegisterFrameAsNavigationService(InlineFrame, FrameLevel.Two);
            NepApp.UI.SetNavigationService(inlineNavigationService);
            inlineNavigationService.Navigated        += InlineNavigationService_Navigated;
            inlineNavigationService.PreBackRequested += InlineNavigationService_PreBackRequested;
            PageTitleTextBlock.SetBinding(TextBlock.TextProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.ViewTitle)));

            nowPlayingOverlayCoordinator = new XboxShellViewModelNowPlayingOverlayCoordinator(this, inlineNavigationService);

            ///Set up dialogs
            NepApp.UI.SetOverlayParentAndSnackBarContainer(OverlayPanel, snackBarGrid);
            App.RegisterUIDialogs();
            NepApp.UI.Overlay.OverlayedDialogShown  += Overlay_DialogShown;
            NepApp.UI.Overlay.OverlayedDialogHidden += Overlay_DialogHidden;
            NepApp.UI.NoChromeStatusChanged         += UI_NoChromeStatusChanged;

            ///Set up media metadata
            NowPlayingTrackTextBlock.SetBinding(TextBlock.DataContextProperty, NepApp.CreateBinding(NepApp.SongManager, nameof(NepApp.SongManager.CurrentSong)));
            NowPlayingArtistTextBlock.SetBinding(TextBlock.DataContextProperty, NepApp.CreateBinding(NepApp.SongManager, nameof(NepApp.SongManager.CurrentSong)));
            NepApp.MediaPlayer.IsPlayingChanged += Media_IsPlayingChanged;
            //handler to allow the metadata to animate onto the screen for the first time.
            CurrentMediaMetadataPanel.SetBinding(Control.VisibilityProperty, NepApp.CreateBinding(NepApp.MediaPlayer, nameof(NepApp.MediaPlayer.IsMediaEngaged), binding =>
            {
                binding.Converter = new Crystal3.UI.Converters.BooleanToVisibilityConverter();
            }));

            ///Set up messaging
            Messenger.AddTarget(this);

            SetInlineFrameMarginPaddingForOverflowScrolling();

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
            {
                //Add acrylic.

                Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush();
                myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
                myBrush.TintColor        = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.FallbackColor    = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.Opacity          = 0.6;
                myBrush.TintOpacity      = 0.5;

                HeaderGrid.Background = myBrush;

                Windows.UI.Xaml.Media.AcrylicBrush myBrush2 = new Windows.UI.Xaml.Media.AcrylicBrush();
                myBrush2.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.Backdrop;
                myBrush2.TintColor        = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush2.FallbackColor    = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush2.Opacity          = 0.6;
                myBrush2.TintOpacity      = 0.5;

                TransportControlGrid.Background  = myBrush;
                TransportControlGrid.BorderBrush = myBrush;
            }
            else
            {
                HeaderGrid.Background            = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
                TransportControlGrid.Background  = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
                TransportControlGrid.BorderBrush = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
            }
        }
        public async Task ViewModelOnNavigatedFromCalled_WithItsOwnStateDictionary()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                var frameSessionState = new Dictionary<string, object>();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => frameSessionState;
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPageWithViewModel), sessionStateService);

                navigationService.Navigate("Page1", 1);
                Assert.AreEqual(1, frameSessionState.Count, "VM 1 state only");

                navigationService.Navigate("Page2", 2);
                Assert.AreEqual(2, frameSessionState.Count, "VM 1 and 2");

                navigationService.Navigate("Page1", 1);
                Assert.AreEqual(3, frameSessionState.Count, "VM 1, 2, and 1 again.");

                navigationService.Navigate("Page3", 3);
                Assert.AreEqual(4, frameSessionState.Count, "VM 1, 2, 1, and 3");
            });
        }
        public async Task Resuming_Calls_ViewModel_OnNavigatedTo()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);

                navigationService.Navigate("Mock", 1);

                var viewModel = new MockPageViewModel();
                viewModel.OnNavigatedToCommand = (navigationParameter, navigationMode, frameState) =>
                {
                    Assert.AreEqual(NavigationMode.Refresh, navigationMode);
                };

                var page = (MockPage)frame.Content;
                page.DataContext = viewModel;

                navigationService.RestoreSavedNavigation();
            });
        }
 /// <inheritdoc/>
 public override void NavigateToFirstPage()
 {
     FrameNavigationService.NavigateToViewModel <T>(true, null);
 }
Ejemplo n.º 12
0
        protected override UIElement CreateShell(Frame rootFrame)
        {
            rootFrame.CacheSize = 5;

            rootFrame.NavigationFailed += (_, e) =>
            {
                Debug.WriteLine("Page navigation failed!!");
                Debug.WriteLine(e.SourcePageType.AssemblyQualifiedName);
                Debug.WriteLine(e.Exception.ToString());

                _ = OutputErrorFile(e.Exception, e.SourcePageType?.AssemblyQualifiedName);
            };


            // Grid
            //   |- HohoemaInAppNotification
            //   |- PlayerWithPageContainerViewModel
            //   |    |- MenuNavigatePageBaseViewModel
            //   |         |- rootFrame

            var menuPageBase = new Views.MenuNavigatePageBase()
            {
                Content     = rootFrame,
                DataContext = Container.Resolve <ViewModels.MenuNavigatePageBaseViewModel>()
            };


            Views.PlayerWithPageContainer playerWithPageContainer = new Views.PlayerWithPageContainer()
            {
                Content     = menuPageBase,
                DataContext = Container.Resolve <ViewModels.PlayerWithPageContainerViewModel>()
            };

            playerWithPageContainer.ObserveDependencyProperty(Views.PlayerWithPageContainer.FrameProperty)
            .Where(x => x != null)
            .Take(1)
            .Subscribe(async frame =>
            {
                var frameFacade = new FrameFacadeAdapter(playerWithPageContainer.Frame, EventAggregator);

                var sessionStateService = new SessionStateService();
                var ns = new FrameNavigationService(frameFacade
                                                    , (pageToken) =>
                {
                    if (pageToken == nameof(Views.VideoPlayerPage))
                    {
                        return(typeof(Views.VideoPlayerPage));
                    }
                    else if (pageToken == nameof(Views.LivePlayerPage))
                    {
                        return(typeof(Views.LivePlayerPage));
                    }
                    else
                    {
                        return(typeof(Views.BlankPage));
                    }
                }, sessionStateService);

                var name = nameof(PlayerViewManager.PrimaryViewPlayerNavigationService);
                Container.RegisterInstance(name, ns as INavigationService);
            });



            var hohoemaInAppNotification = new Views.HohoemaInAppNotification()
            {
                VerticalAlignment = VerticalAlignment.Bottom
            };

            var grid = new Grid()
            {
                Children =
                {
                    playerWithPageContainer,
                    hohoemaInAppNotification,
                }
            };


#if DEBUG
            menuPageBase.FocusEngaged += (__, args) => Debug.WriteLine("focus engagad: " + args.OriginalSource.ToString());
#endif

            return(grid);
        }
        public async Task NavigateToCurrentViewModel_Calls_VieModel_OnNavigatedTo()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());

                bool viewModelNavigatedToCalled = false;
                var viewModel = new MockPageViewModel();
                viewModel.OnNavigatedFromCommand = (a, b) => Assert.IsTrue(true);
                viewModel.OnNavigatedToCommand = (parameter, navigationMode, frameState) =>
                {
                    Assert.AreEqual(NavigationMode.New, navigationMode);
                    Assert.AreEqual(1, frameState["someValue"]);
                    viewModelNavigatedToCalled = true;
                };

                // Set up the viewModel to the Page we navigated
                frame.Navigated += (sender, e) =>
                {
                    var view = frame.Content as FrameworkElement;
                    view.DataContext = viewModel;
                };

                var frameSessionState = new MockFrameSessionState();
                frameSessionState.GetSessionStateForFrameDelegate = (currentFrame) =>
                {
                    var toReturn = new Dictionary<string, object>();
                    toReturn.Add("someValue", 1);
                    return toReturn;
                };
                var restorableStateService = new MockSuspensionManagerState();
                var navigationService = new FrameNavigationService(frame, frameSessionState, (pageToken) => typeof(MockPage), restorableStateService);

                navigationService.Navigate("Mock", 1);

                Assert.IsTrue(viewModelNavigatedToCalled);
            });
        }
        public async Task Suspending_Calls_VieModel_OnNavigatedFrom()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var frameSessionState = new MockFrameSessionState();
                frameSessionState.GetSessionStateForFrameDelegate = (currentFrame) =>
                {
                    var toReturn = new Dictionary<string, object>();
                    toReturn.Add("someValue", 1);
                    return toReturn;
                };
                var restorableStateService = new MockSuspensionManagerState();
                var navigationService = new FrameNavigationService(frame, frameSessionState, (pageToken) => typeof(MockPage), restorableStateService);

                navigationService.Navigate("Mock", 1);

                var viewModel = new MockPageViewModel();
                viewModel.OnNavigatedFromCommand = (frameState, suspending) =>
                {
                    Assert.IsTrue(suspending);
                    Assert.AreEqual(1, frameState["someValue"]);
                };

                var page = (MockPage)frame.Content;
                page.DataContext = viewModel;

                navigationService.Suspending();
            });
        }
        public async Task NavigateFromCurrentViewModel_Calls_VieModel_OnNavigatedFrom()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                

                bool viewModelNavigatedFromCalled = false;
                var viewModel = new MockPageViewModel();
                viewModel.OnNavigatedFromCommand = (frameState, suspending) =>
                {
                    Assert.IsFalse(suspending);
                    Assert.AreEqual(1, frameState["someValue"]);
                    viewModelNavigatedFromCalled = true;
                };

                var frameSessionState = new MockFrameSessionState();
                frameSessionState.GetSessionStateForFrameDelegate = (currentFrame) =>
                {
                    var toReturn = new Dictionary<string, object>();
                    toReturn.Add("someValue", 1);
                    return toReturn;
                };

                var navigationService = new FrameNavigationService(frame, frameSessionState, (pageToken) => typeof(MockPage), null);

                // Set up the frame's content with a Page
                var view = new MockPage();
                view.DataContext = viewModel;
                frame.Content = view;

                // Navigate to fire the NavigatedToCurrentViewModel
                navigationService.Navigate("Mock", 1);

                Assert.IsTrue(viewModelNavigatedFromCalled);
            });
        }
Ejemplo n.º 16
0
        public async Task Navigate_To_Page_With_UseTitleBarBackButton_False_Does_Not_Change_Back_Button_Visibility()
        {
            await DispatcherHelper.ExecuteOnUIThread(() =>
            {
                var eventAggregator = new EventAggregator();
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);
                var deviceGestureService = new DeviceGestureService();
                deviceGestureService.EnableTitleBarBackButton(eventAggregator);
                var navigationManager = SystemNavigationManager.GetForCurrentView();

                // Reset back button visibility before running, can't do this in TestInitialize because CoreWindow sometimes isn't ready
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;

                // If it's collapsed and we navigate, it stays collapsed
                Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility);
                navigationService.Navigate("Mock", 1);
                Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility);

                // If it's visible and our back stack is emptied, it stays visible
                navigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                navigationService.ClearHistory();
                Assert.AreEqual(AppViewBackButtonVisibility.Visible, navigationManager.AppViewBackButtonVisibility);
            });
        }
Ejemplo n.º 17
0
        private async Task InitializeRootFrameAsync(IActivatedEventArgs e)
        {
            InitializeIoC();

            var 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.NavigationFailed += OnNavigationFailed;

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;

                var navManager = new NavigationManager(this);

                var navService = new FrameNavigationService(rootFrame, navManager);
                navService.NavigationLevel = FrameLevel.One;

                navManager.RootNavigationService = navService;

                InitializeNavigation(navManager);
            }

            await OnApplicationInitializedAsync();

            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //Resurrection!

                IStorageItem suspensionStateFileItem = await CrystalApplication.CrystalDataFolder.TryGetItemAsync(PreservationManager.SuspensionStateFileName);

                if (suspensionStateFileItem != null)
                {
                    StorageFile suspensionStateFile = (StorageFile)suspensionStateFileItem;

                    var eventArgs = new CrystalApplicationShouldRestoreEventArgs();
                    eventArgs.SuspensionFileDate = suspensionStateFile.DateCreated;
                    if (OnApplicationShouldRestore(eventArgs))
                    {
                        if (await PreservationManager.RestoreAsync() == true)
                        {
                            //navService.HandleTerminationReload();

                            //todo handle multiple windows in this case.

                            try
                            {
                                await suspensionStateFile.DeleteAsync();
                            }
                            catch (Exception)
                            {
                            }

                            IsRestored = true;

                            if (Restored != null)
                            {
                                Restored(this, EventArgs.Empty);
                            }
                        }
                    }
                }
            }



            // Ensure the current window is active
            //Window.Current.Activate();

            HandleBackNavigation();

            WindowManager.GetStatusManagerForCurrentView().Initialize();
        }
        public async Task Suspending_Calls_VieModel_OnNavigatedFrom()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);

                navigationService.Navigate("Mock", 1);

                var viewModel = new MockPageViewModel();
                viewModel.OnNavigatedFromCommand = (frameState, suspending) =>
                {
                    Assert.IsTrue(suspending);
                };

                var page = (MockPage)frame.Content;
                page.DataContext = viewModel;

                navigationService.Suspending();
            });
        }
Ejemplo n.º 19
0
        public AppShellView()
        {
            this.InitializeComponent();

            coreApplicationView = CoreApplication.GetCurrentView();
            //if (coreApplicationView != null)
            //    coreApplicationView.TitleBar.ExtendViewIntoTitleBar = true;

            applicationView = ApplicationView.GetForCurrentView();
            applicationView.TitleBar.BackgroundColor         = Colors.Transparent;
            applicationView.TitleBar.ButtonBackgroundColor   = Colors.Transparent;
            applicationView.TitleBar.InactiveBackgroundColor = Colors.Transparent;

            uiSettings = new Windows.UI.ViewManagement.UISettings();

            NavView.SetBinding(Microsoft.UI.Xaml.Controls.NavigationView.MenuItemsSourceProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.NavigationItems)));

            inlineNavigationService = WindowManager.GetNavigationManagerForCurrentView().RegisterFrameAsNavigationService(InlineFrame, FrameLevel.Two);
            windowService           = WindowManager.GetWindowServiceForCurrentView();
            UpdateSelectedNavigationItems();
            NepApp.UI.SetNavigationService(inlineNavigationService);
            inlineNavigationService.Navigated += InlineNavigationService_Navigated;

            NepApp.UI.SetOverlayParentAndSnackBarContainer(OverlayPanel, snackBarGrid);
            App.RegisterUIDialogs();

            nowPlayingOverlayCoordinator = new AppShellViewModelNowPlayingOverlayCoordinator(this);


            NavView.SetBinding(Microsoft.UI.Xaml.Controls.NavigationView.HeaderProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.ViewTitle)));

            NowPlayingButton.SetBinding(Button.DataContextProperty, NepApp.CreateBinding(NepApp.SongManager, nameof(NepApp.SongManager.CurrentSong)));

            NepApp.MediaPlayer.MediaEngagementChanged += MediaPlayer_MediaEngagementChanged;
            NepApp.MediaPlayer.IsPlayingChanged       += MediaPlayer_IsPlayingChanged;


            NepApp.UI.Overlay.OverlayedDialogShown  += Overlay_DialogShown;
            NepApp.UI.Overlay.OverlayedDialogHidden += Overlay_DialogHidden;

            Messenger.AddTarget(this);

            DeviceInformation.SubplatformChanged += DeviceInformation_SubplatformChanged;

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase") &&
                Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
            {
                //Add acrylic.

                Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush();
                myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
                myBrush.TintColor        = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.FallbackColor    = uiSettings.GetColorValue(UIColorType.AccentDark2);
                myBrush.Opacity          = 0.6;
                myBrush.TintOpacity      = 0.5;

                bottomAppBar.Background = myBrush;
            }
            else
            {
                bottomAppBar.Background = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent));
            }
        }
        public async Task GoBack_When_CanGoBack()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);

                bool resultFirstNavigation = navigationService.Navigate("MockPage", 1);

                Assert.IsInstanceOfType(frame.Content, typeof(MockPage));
                Assert.AreEqual(1, ((MockPage)frame.Content).PageParameter);
                Assert.IsFalse(navigationService.CanGoBack());

                bool resultSecondNavigation = navigationService.Navigate("Mock", 2);

                Assert.IsInstanceOfType(frame.Content, typeof(MockPage));
                Assert.AreEqual(2, ((MockPage)frame.Content).PageParameter);
                Assert.IsTrue(navigationService.CanGoBack());

                navigationService.GoBack();

                Assert.IsInstanceOfType(frame.Content, typeof(MockPage));
                Assert.AreEqual(1, ((MockPage)frame.Content).PageParameter);
                Assert.IsFalse(navigationService.CanGoBack());
            });
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Creates the navigation service.
 /// </summary>
 /// <param name="rootFrame">The root frame.</param>
 /// <param name="sessionStateService">The session state service.</param>
 /// <returns>The initialized navigation service.</returns>
 private INavigationService CreateNavigationService(IFrameFacade rootFrame, ISessionStateService sessionStateService)
 {
     var navigationService = new FrameNavigationService(rootFrame, GetPageType, sessionStateService);
     return navigationService;
 }
        public async Task RestoreSavedNavigation_ClearsOldForwardNavigation()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                var frameSessionState = new Dictionary<string, object>();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => frameSessionState;
                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPageWithViewModel), sessionStateService);

                navigationService.Navigate("Page1", 1);
                Assert.AreEqual(1, frameSessionState.Count, "VM 1 state only");

                navigationService.Navigate("Page2", 2);
                Assert.AreEqual(2, frameSessionState.Count, "VM 1 and 2");

                navigationService.Navigate("Page3", 3);
                Assert.AreEqual(3, frameSessionState.Count, "VM 1, 2, and 3");

                navigationService.GoBack();
                Assert.AreEqual(2, ((Dictionary<string, object>)frameSessionState["ViewModel-2"]).Count);
                Assert.AreEqual(3, frameSessionState.Count, "VM 1, 2, and 3");

                navigationService.Navigate("Page4", 4);
                Assert.AreEqual(0, ((Dictionary<string,object>)frameSessionState["ViewModel-2"]).Count);
                Assert.AreEqual(3, frameSessionState.Count, "VM 1, 2, and 4");
            });
        }
Ejemplo n.º 23
0
 private void SearchPage_BackRequested(object sender, BackRequestedEventArgs e)
 {
     FrameNavigationService.GoBack();
     e.Handled = true;
 }
        public async Task PageTokenThatCannotBeResolved_ThrowsMeaningfulException()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());
                var sessionStateService = new MockSessionStateService();
                var frameSessionState = new Dictionary<string, object>();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => frameSessionState;

                Func<string, Type> unresolvablePageTokenReturnsNull = pageToken => null;
                var navigationService = new FrameNavigationService(frame, unresolvablePageTokenReturnsNull, sessionStateService);

                Assert.ThrowsException<ArgumentException>(
                    () =>   navigationService.Navigate("anything", 1)
                    );

            });
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Creates the navigation service.
        /// </summary>
        /// <param name="rootFrame">The root frame.</param>
        /// <param name="sessionStateService">The session state service.</param>
        /// <returns>The initialized navigation service.</returns>
        private INavigationService CreateNavigationService(IFrameFacade rootFrame, ISessionStateService sessionStateService)
        {
            var navigationService = new FrameNavigationService(rootFrame, GetPageType, sessionStateService);

            return(navigationService);
        }
        public async Task NavigateFromCurrentViewModel_Calls_VieModel_OnNavigatedFrom()
        {
            await ExecuteOnUIThread(() =>
            {
                var frame = new FrameFacadeAdapter(new Frame());

                bool viewModelNavigatedFromCalled = false;
                var viewModel = new MockPageViewModel();
                viewModel.OnNavigatedFromCommand = (frameState, suspending) =>
                {
                    Assert.IsFalse(suspending);
                    viewModelNavigatedFromCalled = true;
                };

                var sessionStateService = new MockSessionStateService();
                sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>();

                var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService);

                // Initial navigatio
                navigationService.Navigate("page0", 0);

                // Set up the frame's content with a Page
                var view = new MockPage();
                view.DataContext = viewModel;
                frame.Content = view;

                // Navigate to fire the NavigatedToCurrentViewModel
                navigationService.Navigate("page1", 1);

                Assert.IsTrue(viewModelNavigatedFromCalled);
            });
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Operations on clicking back button
 /// </summary>
 public void BackButtonClicked()
 {
     FrameNavigationService.GoBack();
 }