public T GetPage <T>(NavPageType pageType, string title = null, Subject subject = null) { try { Page page; if (pageType != NavPageType.SubjectPage && pageType != NavPageType.DefinitionsPage && pageType != NavPageType.FormulasPage && pageType != NavPageType.SolverPage && pageType != NavPageType.SearchPage) { page = GetMainPage(pageType); } else { page = GetPageForSubject(pageType, subject); } if (!string.IsNullOrWhiteSpace(title) && page.Title != title) { page.Title = title; } if (page != null) { return((T)(object)page); } } catch (Exception e) { Debug.WriteLine(e); } return(default(T)); }
private async void NavigateTo(NavPageType pageType, string title = null, bool inner = true, Subject subject = null) { var newPage = GetPage <Page>(pageType, title, subject); if (newPage != null) { _isOnMain = pageType == NavPageType.MainPage || pageType == NavPageType.AboutPage; _lastType = pageType; if (inner) { await NavPage.PushAsync(newPage); } else { NavPage = new NavigationPage(newPage) { Title = newPage.Title, BarBackgroundColor = _topBarColor, BarTextColor = _topBarTextColor, BackgroundColor = _mainBgColor }; _mdp.Detail = NavPage; } _mdp.IsPresented = false; } }
public override void NavigateToSearchPage(NavPageType callingPage, Subject subject) { var title = "Wyszukaj " + (callingPage == NavPageType.DefinitionsPage ? "Definicje" : "Wzory"); SearchPage.SearchFilter = callingPage; NavigateTo(NavPageType.SearchPage, title, true, subject); }
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); }
/*private T GetPageForSubject<T>(NavPageType pageType, Subject subject) * { * var page = GetPageForSubject(pageType, subject); * if (page != null) * { * return (T)Convert.ChangeType(page, typeof(T)); * } * return default(T); * }*/ private Page GetPageForSubject(NavPageType pageType, Subject subject) { if (!SubjectPages.ContainsKey(subject.Base.SubjectType) || !SubjectPages[subject.Base.SubjectType].ContainsKey(pageType)) { CreatePage(pageType, subject); } var page = SubjectPages[subject.Base.SubjectType][pageType]; return(page); }
public abstract void NavigateToSearchPage(NavPageType callingPage, Subject subject);
public abstract void NavigateToMain(NavPageType pageType, string title);
private Page GetMainPage(NavPageType pageType) { return(!MainPages.ContainsKey(pageType) ? CreatePage(pageType) : MainPages[pageType]); }
public override void NavigateToMain(NavPageType pageType, string title) { NavigateTo(pageType, "AiRTech", false); }