/// <summary> /// Returns module and chapter number of string, i.e. takes "4.1.6a" and returns "4_1" /// </summary> /// <param name="data"></param> /// <returns></returns> private string ChapterNameString(CourseData.ChapterTitleData data) { //Takes module and chapter number, .e.g 4.1.6a ---> {4, 1} var currentChapter = data.Number.Split('.').ToList().Take(2); return(string.Join("_", currentChapter)); }
private string ChapterStackName(CourseData.ChapterTitleData data) { if (data.Title.Contains("Quiz")) { return(string.Format("Quiz_{0}", ChapterNameString(data))); } else { return(string.Format("ChapterStack{0}", ChapterNameString(data))); } }
private Button ChapterSectionBtn(CourseData.ChapterTitleData data) { Grid buttonContent = new Grid { Style = TryFindResource("ChapterSectionGrid") as Style }; buttonContent.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); buttonContent.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Star) }); var numberText = new TextBlock { Style = TryFindResource("ChapterSectionNumber") as Style, Text = data.Number }; var titleText = new TextBlock { Style = TryFindResource("ChapterSectionText") as Style, Text = data.Title }; buttonContent.Children.Add(numberText); buttonContent.Children.Add(titleText); Grid.SetColumn(numberText, 0); Grid.SetColumn(titleText, 1); Button sectionButton = new Button { Style = TryFindResource("SectionBtnStyle") as Style, Content = new Frame { Style = TryFindResource("MenuTitleStyle") as Style, Content = buttonContent }, //page components are named in the form "Section1_1_1" Tag = data// string.Format("Section{0}", data.Number.Replace('.', '_')) }; sectionButton.Click += SectionButton_Click; return(sectionButton); }
private Button ChapterTitleBtn(CourseData.ChapterTitleData data) { Button chapterBtn = new Button { Style = TryFindResource("ChapterBtnStyle") as Style, Content = new Frame { Style = TryFindResource("MenuSectionStyle") as Style, Content = new TextBlock { Text = string.Format("{0}", data.Title), Style = TryFindResource("MenuSectionStyleText") as Style, } }, Tag = ChapterStackName(data), }; chapterBtn.Click += AnimateChapterButtonsStack; return(chapterBtn); }
private void SectionButton_Click(object sender, RoutedEventArgs e) { CourseData.ChapterTitleData data = (sender as Button).Tag as CourseData.ChapterTitleData; string[] pageData = data.Number.Split('.'); //data.Number is of the form "1.1.3a" ---> "module.chapter.section" string pageGridToFind = string.Format("Mod{0}Chapter{1}Grid", pageData[0], pageData[1]); //Mod{0}Chapter{1}Grid is based on x:Name value given to each module page. var findPage = ViewingPage.FindName(pageGridToFind); if (findPage == null) //Navigate to correct chapter page { string chapterIdentifier = string.Join(".", pageData.Take(2)); ViewingPage = chapterIdentifier switch { "1.1" => new Course.Modules.Mod1Part1(data.SectionID, NavigateTo), "1.2" => new Course.Modules.Mod1Part2(data.SectionID, NavigateTo), "1.3" => new Course.Modules.Mod1Part3(data.SectionID, NavigateTo), "2.1" => new Course.Modules.Mod2Part1(data.SectionID, NavigateTo), "2.2" => new Course.Modules.Mod2Part2(data.SectionID, NavigateTo), "3.1" => new Course.Modules.Mod3Part1(data.SectionID, NavigateTo), "3.2" => new Course.Modules.Mod3Part2(data.SectionID, NavigateTo), "3.3" => new Course.Modules.Mod3Part3(data.SectionID, NavigateTo), "3.4" => new Course.Modules.Mod3Part4(data.SectionID, NavigateTo), "4.1" => new Course.Modules.Mod4Part1(data.SectionID, NavigateTo), "4.2" => new Course.Modules.Mod4Part2(data.SectionID, NavigateTo), _ => new ManagerHome() }; ContentArea.Content = ViewingPage; } else { //Already on page. Bring chosen section into view ViewingPage.ScrollIntoViewByName(data.SectionID, "ScrollArea"); } }