private void BindRepeater() { var dictList = new List <CategoryDictionary>(); var calList = Wiki.GetCategories(); List <string> letters = new List <string>(WikiResource.wikiCategoryAlfaList.Split(',')); string otherSymbol = string.Empty; if (letters.Count > 0) { otherSymbol = letters[0]; letters.Remove(otherSymbol); } string firstLetter; CategoryDictionary catDic; foreach (Category cat in calList) { if (string.IsNullOrEmpty(cat.CategoryName)) { continue; } firstLetter = new string(cat.CategoryName[0], 1); if (!letters.Exists(lt => lt.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { firstLetter = otherSymbol; } if (!dictList.Exists(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { catDic = new CategoryDictionary(); catDic.HeadName = firstLetter; catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); dictList.Add(catDic); } else { catDic = dictList.Find(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase)); catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); } } dictList.Sort(SortCatDict); int countAll = dictList.Count * 3 + calList.Count; //1 letter is like 2 links to category int perColumn = (int)(Math.Round((decimal)countAll / 3)); List <List <CategoryDictionary> > mainDictList = new List <List <CategoryDictionary> >(); int index = 0, lastIndex = 0, count = 0; CategoryDictionary cd; for (int i = 0; i < dictList.Count; i++) { cd = dictList[i]; count += 3; count += cd.Categories.Count; index++; if (count >= perColumn || i == dictList.Count - 1) { count = count - perColumn; mainDictList.Add(dictList.GetRange(lastIndex, index - lastIndex)); lastIndex = index; } } HasCategories = mainDictList.Count > 0; if (HasCategories) { rptCategoryList.DataSource = mainDictList; rptCategoryList.DataBind(); } else { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("wikilogo150.png", WikiManager.ModuleId), Header = WikiResource.EmptyScreenWikiCategoriesCaption, Describe = WikiResource.EmptyScreenWikiCategoriesText }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } EmptyContent.Controls.Add(emptyScreenControl); } }
private int SortCatDict(CategoryDictionary cd1, CategoryDictionary cd2) { return(cd1.HeadName.CompareTo(cd2.HeadName)); }
private void BindRepeater() { var dictList = new List<CategoryDictionary>(); var calList = Wiki.GetCategories(); List<string> letters = new List<string>(WikiResource.wikiCategoryAlfaList.Split(',')); string otherSymbol = string.Empty; if (letters.Count > 0) { otherSymbol = letters[0]; letters.Remove(otherSymbol); } string firstLetter; CategoryDictionary catDic; foreach (Category cat in calList) { if (string.IsNullOrEmpty(cat.CategoryName)) continue; firstLetter = new string(cat.CategoryName[0], 1); if (!letters.Exists(lt => lt.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { firstLetter = otherSymbol; } if (!dictList.Exists(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { catDic = new CategoryDictionary(); catDic.HeadName = firstLetter; catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); dictList.Add(catDic); } else { catDic = dictList.Find(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase)); catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); } } dictList.Sort(SortCatDict); int countAll = dictList.Count * 3 + calList.Count; //1 letter is like 2 links to category int perColumn = (int)(Math.Round((decimal)countAll / 3)); List<List<CategoryDictionary>> mainDictList = new List<List<CategoryDictionary>>(); int index = 0, lastIndex = 0, count = 0; CategoryDictionary cd; for (int i = 0; i < dictList.Count; i++) { cd = dictList[i]; count += 3; count += cd.Categories.Count; index++; if (count >= perColumn || i == dictList.Count - 1) { count = count - perColumn; mainDictList.Add(dictList.GetRange(lastIndex, index - lastIndex)); lastIndex = index; } } HasCategories = mainDictList.Count > 0; if (HasCategories) { rptCategoryList.DataSource = mainDictList; rptCategoryList.DataBind(); } else { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("WikiLogo150.png", WikiManager.ModuleId), Header = WikiResource.EmptyScreenWikiCategoriesCaption, Describe = WikiResource.EmptyScreenWikiCategoriesText }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } EmptyContent.Controls.Add(emptyScreenControl); } }
private int SortCatDict(CategoryDictionary cd1, CategoryDictionary cd2) { return cd1.HeadName.CompareTo(cd2.HeadName); }
private void BindRepeater() { var dictList = new List<CategoryDictionary>(); var calList = Wiki.GetCategories(); List<string> letters = new List<string>(WikiResource.wikiCategoryAlfaList.Split(',')); string otherSymbol = string.Empty; if (letters.Count > 0) { otherSymbol = letters[0]; letters.Remove(otherSymbol); } string firstLetter; CategoryDictionary catDic; foreach (Category cat in calList) { if (string.IsNullOrEmpty(cat.CategoryName)) continue; firstLetter = new string(cat.CategoryName[0], 1); if (!letters.Exists(lt => lt.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { firstLetter = otherSymbol; } if (!dictList.Exists(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { catDic = new CategoryDictionary(); catDic.HeadName = firstLetter; catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); dictList.Add(catDic); } else { catDic = dictList.Find(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase)); catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); } } dictList.Sort(SortCatDict); int countAll = dictList.Count * 3 + calList.Count; //1 letter is like 2 links to category int perColumn = (int)(Math.Round((decimal)countAll / 3)); List<List<CategoryDictionary>> mainDictList = new List<List<CategoryDictionary>>(); int index = 0, lastIndex = 0, count = 0; CategoryDictionary cd; for (int i = 0; i < dictList.Count; i++) { cd = dictList[i]; count += 3; count += cd.Categories.Count; index++; if (count >= perColumn || i == dictList.Count - 1) { count = count - perColumn; mainDictList.Add(dictList.GetRange(lastIndex, index - lastIndex)); lastIndex = index; } } rptCategoryList.DataSource = mainDictList; rptCategoryList.DataBind(); }
private void BindRepeater() { var dictList = new List <CategoryDictionary>(); var calList = Wiki.GetCategories(); List <string> letters = new List <string>(WikiResource.wikiCategoryAlfaList.Split(',')); string otherSymbol = string.Empty; if (letters.Count > 0) { otherSymbol = letters[0]; letters.Remove(otherSymbol); } string firstLetter; CategoryDictionary catDic; foreach (Category cat in calList) { if (string.IsNullOrEmpty(cat.CategoryName)) { continue; } firstLetter = new string(cat.CategoryName[0], 1); if (!letters.Exists(lt => lt.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { firstLetter = otherSymbol; } if (!dictList.Exists(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { catDic = new CategoryDictionary(); catDic.HeadName = firstLetter; catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); dictList.Add(catDic); } else { catDic = dictList.Find(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase)); catDic.Categories.Add(GetCategoryInfo(cat.CategoryName)); } } dictList.Sort(SortCatDict); int countAll = dictList.Count * 3 + calList.Count; //1 letter is like 2 links to category int perColumn = (int)(Math.Round((decimal)countAll / 3)); List <List <CategoryDictionary> > mainDictList = new List <List <CategoryDictionary> >(); int index = 0, lastIndex = 0, count = 0; CategoryDictionary cd; for (int i = 0; i < dictList.Count; i++) { cd = dictList[i]; count += 3; count += cd.Categories.Count; index++; if (count >= perColumn || i == dictList.Count - 1) { count = count - perColumn; mainDictList.Add(dictList.GetRange(lastIndex, index - lastIndex)); lastIndex = index; } } rptCategoryList.DataSource = mainDictList; rptCategoryList.DataBind(); }