INavigationOperation IDynamicViewModelPresenter.TryShowAsync(IViewModel viewModel, IDataContext context, IViewModelPresenter parentPresenter)
        {
            parentPresenter.DynamicPresenters.Remove(this);
            var operation = parentPresenter.ShowAsync(viewModel, context);

            if (ShutdownOnMainViewModelClose)
            {
                operation.ContinueWith(result =>
                {
                    Application application = Application.Current;
                    if (application != null)
                    {
                        Action action = application.Shutdown;
                        application.Dispatcher.BeginInvoke(action);
                    }
                });
            }
            if (_rootWindow != null)
            {
                var iocContainer             = MvvmApplication.Current.IocContainer;
                IWindowViewMediator mediator = new WindowViewMediator(_rootWindow, viewModel, iocContainer.Get <IThreadManager>(),
                                                                      iocContainer.Get <IViewManager>(), iocContainer.Get <IWrapperManager>(),
                                                                      iocContainer.Get <IOperationCallbackManager>());
                mediator.UpdateView(new PlatformWrapperRegistrationModule.WindowViewWrapper(_rootWindow), true, context);
                _rootWindow.Show();
            }
            return(operation);
        }
Ejemplo n.º 2
0
        public virtual void Start()
        {
            Initialize();
            var app          = MvvmApplication.Current;
            var iocContainer = app.IocContainer;
            var ctx          = new DataContext(app.Context);

            if (!ctx.Contains(NavigationConstants.IsDialog))
            {
                ctx.Add(NavigationConstants.IsDialog, false);
            }
            var viewModelType = app.GetStartViewModelType();

            NavigationWindow rootWindow = null;
            var mappingProvider         = iocContainer.Get <IViewMappingProvider>();
            IViewMappingItem mapping    = mappingProvider.FindMappingForViewModel(viewModelType, ctx.GetData(NavigationConstants.ViewName), true);

            if (typeof(Page).IsAssignableFrom(mapping.ViewType))
            {
                rootWindow = CreateNavigationWindow();
                var service = CreateNavigationService(rootWindow);
                iocContainer.BindToConstant(service);
            }
            var vm = iocContainer
                     .Get <IViewModelProvider>()
                     .GetViewModel(viewModelType, ctx);

            vm.ShowAsync((model, result) =>
            {
                model.Dispose();
                if (ShutdownOnMainViewModelClose)
                {
                    Application application = Application.Current;
                    if (application != null)
                    {
                        Action action = application.Shutdown;
                        application.Dispatcher.BeginInvoke(action);
                    }
                }
            }, context: ctx);
            if (rootWindow != null)
            {
                IWindowViewMediator mediator = new WindowViewMediator(rootWindow, vm, iocContainer.Get <IThreadManager>(),
                                                                      iocContainer.Get <IViewManager>(), iocContainer.Get <IWrapperManager>(),
                                                                      iocContainer.Get <IOperationCallbackManager>());
                mediator.UpdateView(new PlatformWrapperRegistrationModule.WindowViewWrapper(rootWindow), true, ctx);
                rootWindow.Show();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Starts the current bootstrapper.
        /// </summary>
        public virtual void Start(IDataContext context = null)
        {
            context = context.ToNonReadOnly();
            context.AddOrUpdate(NavigationConstants.IsDialog, false);
            Initialize();
            Type             viewModelType = GetMainViewModelType();
            NavigationWindow rootWindow    = null;
            var mappingProvider            = IocContainer.Get <IViewMappingProvider>();
            IViewMappingItem mapping       = mappingProvider.FindMappingForViewModel(viewModelType, context.GetData(NavigationConstants.ViewName), true);

            if (typeof(Page).IsAssignableFrom(mapping.ViewType))
            {
                rootWindow = CreateNavigationWindow();
                var service = CreateNavigationService(rootWindow);
                IocContainer.BindToConstant(service);
            }
            var vm = CreateMainViewModel(viewModelType, context);

            vm.ShowAsync((model, result) =>
            {
                model.Dispose();
                if (ShutdownOnMainViewModelClose)
                {
                    Application app = Application.Current;
                    if (app != null)
                    {
                        Action action = app.Shutdown;
                        app.Dispatcher.BeginInvoke(action);
                    }
                }
            }, context: context);
            if (rootWindow != null)
            {
                IWindowViewMediator mediator = new WindowViewMediator(rootWindow, vm, IocContainer.Get <IThreadManager>(),
                                                                      IocContainer.Get <IViewManager>(), IocContainer.Get <IOperationCallbackManager>());
                mediator.UpdateView(new ViewManagerEx.WindowView(rootWindow), true, context);
                rootWindow.Show();
            }
        }
 INavigationOperation IDynamicViewModelPresenter.TryShowAsync(IViewModel viewModel, IDataContext context, IViewModelPresenter parentPresenter)
 {
     parentPresenter.DynamicPresenters.Remove(this);
     var operation = parentPresenter.ShowAsync(viewModel, context);
     if (ShutdownOnMainViewModelClose)
     {
         operation.ContinueWith(result =>
         {
             Application application = Application.Current;
             if (application != null)
             {
                 Action action = application.Shutdown;
                 application.Dispatcher.BeginInvoke(action);
             }
         });
     }
     if (_rootWindow != null)
     {
         var iocContainer = MvvmApplication.Current.IocContainer;
         IWindowViewMediator mediator = new WindowViewMediator(_rootWindow, viewModel, iocContainer.Get<IThreadManager>(),
             iocContainer.Get<IViewManager>(), iocContainer.Get<IWrapperManager>(),
             iocContainer.Get<IOperationCallbackManager>());
         mediator.UpdateView(new PlatformWrapperRegistrationModule.WindowViewWrapper(_rootWindow), true, context);
         _rootWindow.Show();
     }
     return operation;
 }
 /// <summary>
 ///     Starts the current bootstrapper.
 /// </summary>
 public virtual void Start()
 {
     InitializationContext = new DataContext(InitializationContext);
     if (!InitializationContext.Contains(NavigationConstants.IsDialog))
         InitializationContext.Add(NavigationConstants.IsDialog, false);
     Initialize();
     Type viewModelType = GetMainViewModelType();
     NavigationWindow rootWindow = null;
     var mappingProvider = IocContainer.Get<IViewMappingProvider>();
     IViewMappingItem mapping = mappingProvider.FindMappingForViewModel(viewModelType, InitializationContext.GetData(NavigationConstants.ViewName), true);
     if (typeof(Page).IsAssignableFrom(mapping.ViewType))
     {
         rootWindow = CreateNavigationWindow();
         var service = CreateNavigationService(rootWindow);
         IocContainer.BindToConstant(service);
     }
     var vm = CreateMainViewModel(viewModelType);
     vm.ShowAsync((model, result) =>
     {
         model.Dispose();
         if (ShutdownOnMainViewModelClose)
         {
             Application app = Application.Current;
             if (app != null)
             {
                 Action action = app.Shutdown;
                 app.Dispatcher.BeginInvoke(action);
             }
         }
     }, context: new DataContext(InitializationContext));
     if (rootWindow != null)
     {
         IWindowViewMediator mediator = new WindowViewMediator(rootWindow, vm, IocContainer.Get<IThreadManager>(),
             IocContainer.Get<IViewManager>(), IocContainer.Get<IWrapperManager>(),
             IocContainer.Get<IOperationCallbackManager>());
         mediator.UpdateView(new PlatformWrapperRegistrationModule.WindowViewWrapper(rootWindow), true, new DataContext(InitializationContext));
         rootWindow.Show();
     }
 }