Exemplo n.º 1
0
        public async Task SetMainPageAsync(string page, Dictionary <string, object> parameters)
        {
            if (string.IsNullOrEmpty(page))
            {
                throw new ArgumentException("You must pass a page to set the main page.");
            }

            if (PageNavigation.Navigation != null)
            {
                HandleDeInitializations(GetCurrentViewModel(), parameters);
            }

            var createdPage = PageFactory.CreatePage(page, false);

            switch (createdPage)
            {
            case MasterDetailPage masterDetailPage:
                await SetMasterDetailPage(parameters, masterDetailPage);

                break;

            case TabbedPage tabbedPage:
                await SetTabbedPage(parameters, tabbedPage);

                break;

            default:
                var navPage = PageFactory.GetNavigationPage(createdPage);
                Application.Current.MainPage = navPage;
                await HandleInitializations(createdPage.BindingContext, parameters);

                break;
            }
        }
Exemplo n.º 2
0
        public MainPage()
        {
            _pageFactory = AutofacContainer.Container.Resolve <IPageFactory>();

            Master = new NavigationPage(_pageFactory.CreatePage <MenuPage, MenuViewModel>(init: vm => { vm.MasterNavigation = this; }))
            {
                Title = "Menu"
            };
            Detail = new NavigationPage(_pageFactory.CreatePage <SightingsPage, SightingsViewModel>(init: vm => { vm.Title = "Obsar"; }));
        }
Exemplo n.º 3
0
        public Task PushAsync <TPage, TViewModel>(Action <TViewModel> init = null, Action <TViewModel> done = null, Action <TViewModel> cancel = null)
            where TPage : Page, IPage <TViewModel>, new()
            where TViewModel : class, IViewModel
        {
            if (cancel == null)
            {
                cancel = async vm =>
                {
                    await vm.Navigation.PopAsync();
                };
            }
            var page = _pageFactory.CreatePage <TPage, TViewModel>(init, done, cancel);

            return(_navigation.PushAsync(page));
        }
 protected override Page CreatePage(string segment)
 {
     if (Type.GetType(segment) != null) //in this case it should get the fully qualified assembly name
     {
         var type = Type.GetType(segment);
         var page = _pageFactory.CreatePage(type);
         return(page);
     }
     else
     {
         return(base.CreatePage(segment));
     }
 }
Exemplo n.º 5
0
        public MainWindowViewModel(IPageFactory itemsPageFactory, IPageFactory infoPageFactory)
        {
            /* Creazione delle due pagine sfruttando le factory. */
            _itemsPageViewModel = itemsPageFactory.CreatePage();
            _infoPageViewModel  = infoPageFactory.CreatePage();

            /* Istruzione richiamata quando viene premuto il corrispondente pulsante. */
            SelectItemsPageViewModel = new RelayCommand(_ =>
            {
                CurrentPageViewModel = _itemsPageViewModel;
            });

            /* Istruzione richiamata quando viene premuto il corrispondente pulsante. */
            SelectInfoPageViewModel = new RelayCommand(_ =>
            {
                CurrentPageViewModel = _infoPageViewModel;
            });



            ClearAll = new RelayCommand(_ =>
            {
                bool res = _itemsPageViewModel.checkIfListIsNull();
                if (res)
                {
                    MessageBox.Show("Worklist is already empty");
                    return;
                }
                MessageBoxResult result = MessageBox.Show("Do you really want to clear ListItem?",
                                                          "ListItemUI ", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    res = _itemsPageViewModel.clearElements();
                    if (!res)
                    {
                        MessageBox.Show("Problem has occured");
                    }
                }
                else
                {
                    //do nothing
                };
            });


            /* Aggiornamento della pagina corrente che viene mostrata. */
            CurrentPageViewModel = _itemsPageViewModel;
        }
Exemplo n.º 6
0
        public void SetDetail <TPage, TViewModel>(Action <TViewModel> init = null, Action <TViewModel> done = null, Action <TViewModel> cancel = null)
            where TPage : Page, IPage <TViewModel>, new()
            where TViewModel : class, IViewModel
        {
            var page = _pageFactory.CreatePage <TPage, TViewModel>(init, done, cancel);

            if (page is NavigationPage)
            {
                Detail = page;
            }
            else
            {
                Detail = new NavigationPage(page);
            }
            IsPresented = false;
        }
Exemplo n.º 7
0
        // TODO: refactor the page creation logic out of here
        protected override async void OnStart()
        {
            base.OnStart();

            await _databaseInitializationService.InitializeDatabaseAsync();

            await _resourceInitializationService.InitializeResourcesAsync();

            var mainPage   = _masterDetailPageProvider.GetMasterDetailPage();
            var masterPage = _pageFactory.CreatePage <MasterPage>();

            mainPage.Master = masterPage;
            await masterPage.InitializeViewmodelAsync(null);

            MainPage = mainPage;
            _logger.LogInformation("Application has successfully started!");
        }
Exemplo n.º 8
0
        public async Task Invoke(HttpContext context)
        {
            var relativePath = context.Request.Path.Value.TrimStart(_separator);

            if (relativePath == string.Empty)
            {
                relativePath = _defaultPage;
            }

            if (relativePath.Contains("."))
            {
                if (relativePath.EndsWith(Page.Extension))
                {
                    var extensionIndex = relativePath.LastIndexOf(Page.Extension);
                    relativePath = relativePath.Remove(extensionIndex);
                }
                else
                {
                    await _next(context);
                }
            }

            var pageContext = _pageContextFactory.Create(context);
            var pageType    = _pageLoader.Load(relativePath);

            if (pageType == null)
            {
                context.Response.StatusCode = 404;
                return;
            }

            pageContext.PageDescriptor = new PageDescriptor
            {
                RelativePath = relativePath,
                PageType     = pageType
            };

            var page = _pageFactory.CreatePage(pageContext);
            await page.ExecuteAsync();
        }
Exemplo n.º 9
0
        public async Task PushAsync(Type viewModelType, object parameter)
        {
            if (viewModelType == null)
            {
                throw new ArgumentNullException(nameof(viewModelType));
            }

            var pageType = _registry.GetPageType(viewModelType);

            Debug.Assert(pageType != null);

            var page = _pageFactory.CreatePage(pageType);

            Debug.Assert(page != null);

            var initializationTask = page.InitializeViewmodelAsync(parameter);
            var navigationTask     = InternalPushAsync(page);

            await Task.WhenAll(initializationTask, navigationTask);

            _logger.LogDebug($"Successfully pushed a page of type {pageType.Name}!");
        }
Exemplo n.º 10
0
 private Page CreateRegisterPage()
 {
     return(pageFactory.CreatePage <RegisterPage, RegisterPageViewModel>(registerPageViewModel));
 }
Exemplo n.º 11
0
        public Xamarin.Forms.NavigationPage CreateRootPage(Type pageType)
        {
            var page = _pageFactory.CreatePage(pageType);

            return(page != null ? new MaterialNavigationPage(page) : null);
        }
Exemplo n.º 12
0
 private Page CreateQuestionsPage()
 {
     return(pageFactory.CreatePage <QuestionPage, QuestionPageViewModel>(questionPageViewModel));
 }
 private Page CreateThankYouPage()
 {
     return(pageFactory.CreatePage <ThankYouPage, ThankYouPageViewModel>(thankYouPageViewModel));
 }
Exemplo n.º 14
0
 private Page CreateReviewPage()
 {
     return(pageFactory.CreatePage <ReviewPage, IReviewPageViewModel>(reviewPageViewModel));
 }
Exemplo n.º 15
0
 public static Page CreatePage <T>(this IPageFactory pageFactory) where T : Page
 {
     return(pageFactory.CreatePage(typeof(T)));
 }