using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using CellAddressable; using Activizr.Basic.Enums; using Activizr.Logic.Security; using System.Text.RegularExpressions; public class AdminPermsMainGridTable : CellAddressableTable { public int firstcol = 1; //first role column public AdminPermsMainGridTable () : base() { } class RoleSortKey : IComparable { static Dictionary staticSortOrder = new Dictionary(); static RoleSortKey () { int order = 0; foreach (RoleType rt in RoleTypes.AllRoleTypes) { staticSortOrder[rt]= order++; } staticSortOrder[RoleType.Unknown]= order++; } public RoleSortKey (RoleType t) { role = t; } public RoleType role; public int CompareTo (RoleSortKey other) { if (!staticSortOrder.ContainsKey(this.role)) this.role = RoleType.Unknown; if (!staticSortOrder.ContainsKey(other.role)) other.role = RoleType.Unknown; return staticSortOrder[this.role].CompareTo(staticSortOrder[other.role]); } } SortedList Roles = new SortedList(); public Column AddRole (RoleType role) { int col = firstcol; //first role column RoleSortKey newKey = new RoleSortKey(role); foreach (RoleSortKey t in Roles.Keys) { if (t.CompareTo(newKey) == 1) { if (col - firstcol < Roles.Count) this.InsertColumnAt(col); break; } ++col; } Column newColumn = this.Columns[col]; Roles.Add(newKey, newColumn); if (col > firstcol) { this[0, firstcol].JoinCell(CellJoinDirection.RIGHT); } else { this[0, firstcol].AddClass("topLock").AddClass("gridCell").AddClass("rolecell"); } string[] name = SplitInWords(Enum.GetName(role.GetType(), role)); newColumn[1].Cell.InnerHtml = name[0]; name[0] = ""; newColumn[2].Cell.InnerHtml = (string.Join("
", name) + " ").Substring(6).Trim(); newColumn[2].Cell.Attributes["roleID"] = ((int)role).ToString(); newColumn[2].Cell.ID = "R" + ((int)role).ToString(); //CellAdressableCell c = this._Cells[3, col]; //string cbName = "cb_" + ((int)role).ToString() + "_all"; //c.Cell.InnerHtml = "