private Page CreatePage(NavPageType pageType, Subject subject = null) { Page page; Type type; switch (pageType) { case NavPageType.MainPage: type = typeof(MainPage); break; case NavPageType.AboutPage: type = typeof(AboutPage); break; case NavPageType.SubjectsPage: type = typeof(SubjectsPage); break; case NavPageType.SubjectPage: type = typeof(SubjectPage); break; case NavPageType.DefinitionsPage: type = typeof(DefinitionsPage); break; case NavPageType.FormulasPage: type = typeof(FormulasPage); break; case NavPageType.SolverPage: type = typeof(SolverPage); break; case NavPageType.SearchPage: type = typeof(SearchPage); break; default: throw new ArgumentOutOfRangeException(nameof(pageType), pageType, null); } if (subject == null) { page = Activator.CreateInstance(type) as Page; MainPages.Add(pageType, page); } else { page = Activator.CreateInstance(type, subject) as Page; var subjectType = subject.Base.SubjectType; SubjectPages[subjectType].Add(pageType, page); } return(page); }
public void NavigateToMainPage(MainPages page) { switch (page) { case MainPages.AppShell: Application.Current.MainPage = new AppShell(); break; case MainPages.AuthenticationPage: Application.Current.MainPage = new AuthenticationPage(); break; } }
public async Task SwitchPage(MainPages page, bool animate = true) { var target = pages[page]; var ipage = (IMainPage)target; if (ipage != null) { lbMainPageTitle.Text = ipage.Title; if (page == MainPages.Home) btnBack.Visible = false; else btnBack.Visible = true; } else { btnBack.Visible = false; lbMainPageTitle.Text = ""; } await switchPanel1.SwitchContent(target, animate ? SwitchPanel.AnimType.SlideLeft : (SwitchPanel.AnimType?)null); if (ipage != null && lastBgImage != ipage.MainWindowBgImage) { lastBgImage = ipage.MainWindowBgImage; BackgroundImage = null; panelRight.BackgroundImage = null; } }
private Page GetMainPage(NavPageType pageType) { return(!MainPages.ContainsKey(pageType) ? CreatePage(pageType) : MainPages[pageType]); }