public void UpdateSectionTitleList(Article a) { SectionTitleListItems.Clear(); // List of section titles List <TitleItem> listOfSectionTitles = a.ListOfSectionTitleItems(); SectionTitleListItems.AddRange(listOfSectionTitles); }
string Interactions() { string htmlStr = ""; List <TitleItem> listOfSectionTitles = new List <TitleItem>(); SectionTitleListItems.Clear(); Dictionary <string, string> listOfATCCodePairs = new Dictionary <string, string>(); foreach (var kvp1 in _articleBasket) { Article a1 = kvp1.Value; string title1 = ClampedTitle(a1); string atc1 = GetAtcInfo(a1)?.Item1; foreach (var kvp2 in _articleBasket) { Article a2 = kvp2.Value; string title2 = ClampedTitle(a2); string atc2 = GetAtcInfo(a2)?.Item1; if (!atc1.Equals(atc2)) { string key = atc1 + "-" + atc2; string title = title1 + " ➞ " + title2; if (_interactionsDict.ContainsKey(key)) { htmlStr += _interactionsDict[key]; listOfSectionTitles.Add(new TitleItem() { Id = key, Title = title }); } } } } if (listOfSectionTitles.Count > 0) { listOfSectionTitles.Insert(0, new TitleItem() { Id = "Interaktionen", Title = "Interaktionen" }); listOfSectionTitles.Add(new TitleItem { Id = "Legende", Title = "Legende" }); } SectionTitleListItems.AddRange(listOfSectionTitles); return(htmlStr); }
public void ShowTableWithArticles(List <Article> listOfArticles, Dictionary <string, HashSet <string> > dictOfRegChapters) { Dictionary <string, int> chaptersCountMap = new Dictionary <string, int>(); _listOfArticles = listOfArticles; _dictOfRegChapters = dictOfRegChapters; string htmlStr = ""; string headStr = $"<head><meta charset='UTF-8'><meta http-equiv='X-UA-Compatible' content='IE=10'>{_jsStr}{_cssStr}</head>"; if (_listOfArticles != null) { int rows = 0; string content = "<body><div id=\"fulltext\"><ul>"; foreach (var a in _listOfArticles) { string content_style = ""; string content_title = a.Title; string content_chapters = ""; string anchor = "?"; string regnr = a.Regnrs?.Split(',')[0]; content_title = $"<a onclick=\"displayFachinfo('{regnr}','{anchor}')\"> <span style=\"font-size:0.8em\"><b>{a.Title}</b></span></a> <span style=\"font-size:0.7em\"> | {a.Author}</span><br>"; bool filtered = true; if (_dictOfRegChapters.ContainsKey(regnr)) { var indexToTitlesMap = a.IndexToTitlesMap(); var chapters = _dictOfRegChapters[regnr]; foreach (string ch in chapters) { int c = Convert.ToInt32(ch); if (indexToTitlesMap.ContainsKey(c)) { string chapterStr = indexToTitlesMap[c]; if (chapterStr.Equals(Filter) || Filter.Length == 0) { anchor = "section" + c; if (c > 100) { // These are "old" section titles, e.g. Section7900, Section8000, etc. anchor = "Section" + c; } content_chapters += $"<span style=\"font-size:0.75em; color:#0088BB\"> <a onclick=\"displayFachinfo('{regnr}','{anchor}')\">{chapterStr}</a></span><br>"; filtered = false; } int count = 0; if (chaptersCountMap.ContainsKey(chapterStr)) { count = chaptersCountMap[chapterStr]; } chaptersCountMap[chapterStr] = count + 1; } } } if (!filtered && a.Title != null && a.Title.Length > 1) { string firstLetter = a.Title.Substring(0, 1).ToUpper(); if (rows % 2 == 0) { content_style = $"<li style=\"background-color:whitesmoke;\" id=\"{firstLetter}\">"; } else { content_style = $"<li style=\"background-color:white;\" id=\"{firstLetter}\">"; } content += content_style + content_title + content_chapters + "</li>"; rows++; } } content += "</ul></div></body>"; htmlStr = content; } HtmlText = $"<!DOCTYPE html><html>{headStr}{htmlStr}</html>"; // Section titles SectionTitleListItems.Clear(); List <TitleItem> listOfSectionTitles = new List <TitleItem>(); foreach (var kvp in chaptersCountMap) { listOfSectionTitles.Add(new TitleItem() { Id = kvp.Key, Title = kvp.Key + " (" + kvp.Value + ")" }); } SectionTitleListItems.AddRange(listOfSectionTitles); }