Ejemplo n.º 1
0
        private TViewModel FindOrCreateViewModel <TViewModel>(NavigateParameters navigateParameters)
            where TViewModel : IMdiWindowViewModel, INavigateAware
        {
            TViewModel viewModel;

            if (navigateParameters != null && navigateParameters.GuidWindows != Guid.Empty)
            {
                viewModel = _windowManager.FindWindow <TViewModel>(navigateParameters.GuidWindows);
                if (viewModel == null)
                {
                    throw new ArgumentNullException(nameof(viewModel));
                }
            }
            else
            {
                viewModel = _windowsFactory.CreateWindow <TViewModel>();
                Guid containerGuid = navigateParameters == null ? Guid.Empty : navigateParameters.GuidContainer;
                viewModel = _windowManager.AppendWindowWithoutInit(viewModel, containerGuid, false);
            }
            return(viewModel);
        }
Ejemplo n.º 2
0
        private IList <IMdiContainerViewModel> InitMdiContainers(ResumeStoreContext resumeContext)
        {
            List <IMdiContainerViewModel> loadedContainers = new List <IMdiContainerViewModel>();

            foreach (ContainersStoreContext containerContext in resumeContext.ContainerContextCollection)
            {
                var container = (MdiContainerViewModelBase)_windowsFactory.CreateContainer(containerContext.ViewModelType);

                container.LoadFromStoreContext(containerContext);

                foreach (var windowContext in containerContext.WindowsContextCollection)
                {
                    var window = (IMdiWindowViewModel)_windowsFactory.CreateWindow(windowContext.ViewModelType);
                    window.Container = container;
                    container.WindowsCollection.Add(window);
                    (window as IStorable <WindowsStoreContext>).LoadFromStoreContext(windowContext);
                }
                loadedContainers.Add(container);
            }

            return(loadedContainers);
        }