Beispiel #1
0
        /// <summary>
        ///     Method responsible for initializing shell
        /// </summary>
        protected virtual void InitialiseShell()
        {
            PublishSystemMessage("Going to init shell window");
            log.Debug("about initializing shell");

            PublishSystemMessage("post initialization has been completed");
            var regionManager = Container.Resolve <IRegionManager>();

            PublishSystemMessage("Going to setup regions on shell window");
            if (Container.IsTypeRegistered <ICommandsViewModel>())
            {
                log.Info("registering CommandRegion in shell");
                regionManager.RegisterViewWithRegion(ShellRegionNames.CommandRegion,
                                                     Container.Resolve <ICommandsViewModel>);
            }

            if (Container.IsTypeRegistered <IStatusViewModel>())
            {
                log.Info("registering StatusRegion in shell");
                regionManager.RegisterViewWithRegion(ShellRegionNames.StatusRegion, Container.Resolve <IStatusViewModel>);
            }


            PublishSystemMessage("regions has been registerd");
            Bootstrapper.RegisterShell(Container);

            PublishSystemMessage("Going to register shell window");
            Container.RegisterTypeIfMissing <IShellWindow, ShellWindow>(LifetimeScope.Singleton);

            shellWindow = Container.Resolve <IShellWindow>();

            PublishSystemMessage("Going to configure shell window");
            Bootstrapper.ConfigureShell(Container, shellWindow);

            PublishSystemMessage("Going to post init application");
            Bootstrapper.PostConfiguration(Container, Messanger);

            var shell = shellWindow as Window;

            if (shell != null)
            {
                log.Info("going to register shell view to shell window");
                shell.DataContext = Container.Resolve <IShellViewModel>();
                var regionCfg = Container.Resolve <IRegionConfigurator>();
                log.Info("going to configure and register regions");
                regionCfg.ConfigureRegions();
                regionCfg.InitializeShell(shell, regionManager);

                Container.RegisterTypeIfMissing <INavigationManager, NavigationManager>(LifetimeScope.Singleton);
                if (Container.IsTypeRegistered <INavigationManager>())
                {
                    var navManager = Container.Resolve <INavigationManager>();
                }
                shell.Closing += (s, e) => { };

                if (Application.Current != null)
                {
                    PublishSystemMessage("Going to register main window");
                    Application.Current.MainWindow = shell;
                }
            }
            PublishSystemMessage("Going to show shell");
            shellWindow.Show();
            if (shell != null)
            {
                shell.Activate();
            }
        }