Example #1
0
        private void InitWindow(bool skipWindowCreation)
        {
            var builder = new ContainerBuilder();

            rootPage = Window.Current.Content as NavigationRoot;
            bool initApp = rootPage == null && !skipWindowCreation;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (initApp)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootPage = new NavigationRoot();

                FrameAdapter adapter = new FrameAdapter(rootPage.AppFrame);

                builder.RegisterInstance(adapter)
                .AsImplementedInterfaces();

                builder.RegisterType <HomeViewModel>();

                // The feed details view model needs to be a singleton in order to better accomodate Connected Animation
                builder.RegisterType <FeedDetailsViewModel>()
                .SingleInstance();
                builder.RegisterType <EpisodeDetailsViewModel>();
                builder.RegisterType <PlayerViewModel>();
                builder.RegisterType <InkNoteViewModel>();
                builder.RegisterType <FavoritesViewModel>();
                builder.RegisterType <NotesViewModel>();
                builder.RegisterType <DownloadsViewModel>();
                builder.RegisterType <SettingsViewModel>();

                builder.RegisterType <NavigationService>()
                .AsImplementedInterfaces()
                .SingleInstance();

                builder.RegisterType <RemotePlayService>()
                .AsImplementedInterfaces();

                builder.RegisterInstance(PlayerService.Current)
                .AsImplementedInterfaces()
                .SingleInstance();

                _container = builder.Build();
                rootPage.InitializeNavigationService(_container.Resolve <INavigationService>());

                adapter.NavigationFailed += OnNavigationFailed;

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

                Window.Current.Activate();
            }
        }
        private void InitWindow(bool skipWindowCreation)
        {
            var builder = new ContainerBuilder();

            _rootPage = Window.Current.Content as NavigationRoot;
            bool initApp = _rootPage == null && !skipWindowCreation;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (initApp)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                _rootPage = new NavigationRoot();

                FrameAdapter adapter = new FrameAdapter(_rootPage.AppFrame);

                builder.RegisterInstance(adapter)
                .AsImplementedInterfaces();

                // Register the view models to the builder
                builder.RegisterType <CompaniesViewModel>();
                builder.RegisterType <CompanyDetailsViewModel>().SingleInstance();
                builder.RegisterType <EditCompanyDetailsViewModel>();
                builder.RegisterType <AddCompanyViewModel>().SingleInstance();
                builder.RegisterType <AccountViewModel>();
                builder.RegisterType <SettingsViewModel>();
                builder.RegisterType <OwnerAccountViewModel>();
                builder.RegisterType <NavigationService>()
                .AsImplementedInterfaces()
                .SingleInstance();

                _container = builder.Build();
                _rootPage.InitializeNavigationService(_container.Resolve <INavigationService>());
                _rootPage.NavigateToStartPage();
                adapter.NavigationFailed += OnNavigationFailed;

                // Place the frame in the current Window
                Window.Current.Content = _rootPage;
                Window.Current.Activate();
            }
        }
Example #3
0
        private async void InitWindow(SplashScreen splash, bool skipWindowCreation = false)
        {
            _rootPage = Window.Current.Content as NavigationRoot;
            var shouldInit = _rootPage == null && !skipWindowCreation;

            if (shouldInit)
            {
                var extSplash = new ExtendedSplash(splash);
                Window.Current.Content = extSplash;
                Window.Current.Activate();

                _rootPage = new NavigationRoot();
                var adapter = new FrameAdapter(_rootPage.AppFrame);
                adapter.NavigationFailed += OnNavigationFailed;

                var builder = new ContainerBuilder();
                builder.RegisterInstance(adapter).AsImplementedInterfaces();

                builder.RegisterType <DashboardViewModel>();
                builder.RegisterType <DesktopViewModel>();
                builder.RegisterType <NavigationService>().AsImplementedInterfaces().SingleInstance();

                _container = builder.Build();

                var navService = _container.Resolve <INavigationService>();
                navService.RegisterPageViewModel <Dashboard, DashboardViewModel>();
                navService.RegisterPageViewModel <Desktop, DesktopViewModel>();
                _rootPage.InitializeNavigationService(navService);

                await navService.NavigateToDashboard(new FrameNavigationOptions());

                await extSplash.RunAsync().ConfigureAwait(true);

                Window.Current.Content = _rootPage;
                Window.Current.Activate();
            }
        }