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

            rootPage = Window.Current.Content as MainNavigation;

            if (rootPage == null && !skipWindowCreation)
            {
                rootPage = new MainNavigation();

                FrameAdapter adapter = new FrameAdapter(rootPage.AppFrame);

                builder.RegisterInstance(adapter).AsImplementedInterfaces();

                builder.RegisterType <HomeViewModel>();

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

                _container = builder.Build();

                rootPage.InitializeNavigationService(_container.Resolve <INavigationService>());

                adapter.NavigationFailed += OnNavigationFailed;

                Window.Current.Content = rootPage;
                Window.Current.Activate();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数

                    rootFrame.Navigate(typeof(MainPage), e.Arguments);

                    var          mainPage = rootFrame.Content as MainPage;
                    var          builder  = new ContainerBuilder();
                    FrameAdapter adapter  = new FrameAdapter(mainPage.RootFrame);

                    builder.RegisterInstance(adapter)
                    .AsImplementedInterfaces();

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

                    builder.RegisterInstance(mainPage).As <INavigationRoot>();

                    Container = builder.Build();
                    mainPage.InitializeNavigationService(Container.Resolve <INavigationService>());
                    adapter.NavigationFailed += OnNavigationFailed;

                    RootTheme = LoadThemeFromSettingsAsync();
                    SetupTitlebar();
                    //ApplicationView.PreferredLaunchViewSize = new Size(1257, 893);
                    //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
                    //rootFrame.Height = 893;
                    //rootFrame.Width = 1257;
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
            }
        }
Beispiel #3
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();
            }
        }
        public INavigationService Register(Frame frame, string frameName = null, bool overrideRegistration = false)
        {
            var navigationService = new FrameAdapter(frame);

            if (string.IsNullOrWhiteSpace(frameName))
            {
                frameName = frame.Name;
            }

            return(Register(frameName, navigationService, overrideRegistration));
        }
        /// <summary>
        /// Registers the Caliburn.Micro navigation service with the container.
        /// </summary>
        /// <param name="rootFrame">The application root frame.</param>
        /// <param name="key">Key to store the frame.</param>
        /// <param name="treatViewAsLoaded">if set to <c>true</c> [treat view as loaded].</param>
        /// <param name="cacheViewModels">if set to <c>true</c> then navigation service cache view models for resuse.</param>
        public INavigationService RegisterNavigationService(Frame frame, string key, bool treatViewAsLoaded = false, bool cacheViewModels = false)
        {
            if (HasHandler(typeof(INavigationService), key))
            {
                return(this.GetInstance <INavigationService>(key));
            }

            if (frame == null)
            {
                throw new ArgumentNullException("Frame [" + key + "] is null");
            }

            var frameAdapter = new FrameAdapter(frame, treatViewAsLoaded);

            RegisterInstance(typeof(INavigationService), key, frameAdapter);

            return(frameAdapter);
        }
Beispiel #6
0
        /// <summary>
        /// Registers the Caliburn.Micro navigation service with the container.
        /// </summary>
        /// <param name="rootFrame">The application root frame.</param>
        /// <param name="treatViewAsLoaded">if set to <c>true</c> [treat view as loaded].</param>
        public INavigationService RegisterNavigationService(Frame rootFrame, bool treatViewAsLoaded = false)
        {
            if (GetBindings(typeof(INavigationService)).Any())
            {
                return(this.Get <INavigationService>());
            }

            if (rootFrame == null)
            {
                throw new ArgumentNullException("rootFrame");
            }

            var frameAdapter = new FrameAdapter(rootFrame, treatViewAsLoaded);

            Bind <INavigationService>().ToConstant(frameAdapter).InSingletonScope();

            return(frameAdapter);
        }
            public override void Load()
            {
                var phoneService      = new PhoneApplicationServiceAdapter(this.rootFrame);
                var navigationService = new FrameAdapter(this.rootFrame, false);

                this.Bind <Frame>().ToConstant(this.rootFrame);
                this.Bind <IPhoneContainer>().ToConstant(this.phoneContainer);
                this.Bind <INavigationService>().ToConstant(navigationService);
                this.Bind <IPhoneService>().ToConstant(phoneService);
                this.Bind <IEventAggregator>().To <EventAggregator>().InSingletonScope();
                this.Bind <IWindowManager>().To <WindowManager>().InSingletonScope();
                this.Bind <IVibrateController>().To <SystemVibrateController>().InSingletonScope();
                this.Bind <ISoundEffectPlayer>().To <XnaSoundEffectPlayer>().InSingletonScope();
                this.Bind <StorageCoordinator>().To <StorageCoordinator>().InSingletonScope();
                this.Bind <TaskController>().To <TaskController>().InSingletonScope();

                this.Bind <IStorageMechanism>().To <PhoneStateStorageMechanism>().InSingletonScope();
                this.Bind <IStorageMechanism>().To <AppSettingsStorageMechanism>().InSingletonScope();
            }
        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();
            }
        }
Beispiel #9
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();
            }
        }
Beispiel #10
0
 public TempHttp2FrameListener(FrameAdapter frameAdapter, IHttp2FrameListener listener, CountdownEvent latch)
 {
     this.frameAdapter = frameAdapter;
     this.listener     = listener;
     this.latch        = latch;
 }
 public void InitializeShellNavigationService(Frame frame)
 {
     ShellNavigationService = new FrameAdapter(frame);
 }