public static void ToggleHideDebugCategory(string DebugCategory) { if (HiddenCategories.Contains(DebugCategory)) { HiddenCategories.Remove(DebugCategory); } else { HiddenCategories.Add(DebugCategory); } }
internal static void Initialize() { MDCommands.RegisterCommandAttributes(typeof(MDOnScreenDebug)); AddBasicInfo(); // Load hidden categories from config string HiddenCategoryString = MDStatics.GetGameInstance().GetConfiguration().GetString(MDConfiguration.ConfigurationSections.OnScreenDebug, MDConfiguration.HIDDEN_CATEGORIES, ""); string[] HiddenCategoryArray = HiddenCategoryString.Replace(", ", ",").Replace(" ,", ",").Split(','); HiddenCategories.AddRange(HiddenCategoryArray); }
// Internals ////////////////////////////////////////////////////////////// private void CollectEditableProperties(object editableObject) { _groupProperties = new Dictionary <string, List <PropertyDescriptor> >(); var controls = Controls; controls.Clear(); EditorControls.Clear(); controls.Add(new PlaceHolder()); var properties = GetEditableProperties(editableObject); // grouping foreach (PropertyDescriptor descriptor in properties) { if ((this.HiddenProperties != null) && (this.HiddenProperties.Contains(descriptor.Name))) { continue; } var categoryTitle = GetCategoryTitle(descriptor); if (HiddenCategories == null || !HiddenCategories.Contains(categoryTitle)) { if (!String.IsNullOrEmpty(categoryTitle)) { List <PropertyDescriptor> categoryValue = null; categoryValue = _groupProperties.ContainsKey(categoryTitle) ? _groupProperties[categoryTitle] : new List <PropertyDescriptor>(); categoryValue.Add(descriptor); if (!_groupProperties.ContainsKey(categoryTitle)) { _groupProperties.Add(categoryTitle, categoryValue); } } } if (_categories.Contains(categoryTitle) || String.IsNullOrEmpty(categoryTitle)) { continue; } _categories.Add(categoryTitle); } // create controls var editorControls = new PlaceHolder { ID = "GroupProperties", EnableViewState = false }; foreach (var entry in _groupProperties) { var title = entry.Key; entry.Value.Sort(new WebOrderComparer()); var descriptors = entry.Value; if (String.IsNullOrEmpty(title) || descriptors == null) { continue; } var groupControl = new PropertyFieldPanel { Title = title }; groupControl.EnableViewState = false; foreach (var descriptor in descriptors) { var editorControl = CreateEditorControl(descriptor); if (editorControl == null) { continue; } editorControl.EnableViewState = false; groupControl.Controls.Add(editorControl); } if (groupControl.Controls.Count > 0) { editorControls.Controls.Add(groupControl); } } if (editorControls.Controls.Count == 0) { return; } EditorControls.Add(editorControls); controls.Add(editorControls); }
private void CreateEditor() { if (_selectedObject == null) { return; } Controls.Clear(); _properties.Clear(); _proplist.Clear(); _itemcounter = 0; _catcounter = 0; _subcounter = 0; var cats = new Hashtable(); foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(_selectedObject)) { if (!pd.IsBrowsable) { continue; } var cat = pd.Category ?? "Default"; var mems = cats[cat] as Hashtable; if (mems == null) { cats[cat] = mems = new Hashtable(); } try { var pgi = new PropertyGridItem(pd) { ControlId = ID + "_" + _itemcounter++ }; _properties[pgi.ControlId] = pgi; var o = _selectedObject; object subo = null; try { subo = pd.GetValue(o); } catch { } if (pd.Converter.GetPropertiesSupported()) { foreach (PropertyDescriptor spd in pd.Converter.GetProperties(subo)) { if (!spd.IsBrowsable) { continue; } PropertyGridItem pgsi = new PropertyGridSubItem(spd, pgi); pgsi.ControlId = ID + "_" + _itemcounter++; pgi.Subitems.Add(pgsi); _properties[pgsi.ControlId] = pgsi; } } var orderAttribute = pd.Attributes.OfType <PropertyOrderAttribute>().FirstOrDefault(); var order = orderAttribute != null?orderAttribute.Order.ToString("D3") : "999"; mems.Add(order + pd.Name, pgi); } catch (Exception ex) { Page.Response.Write(ex); } } _catlist.Clear(); var catlist = new ArrayList(cats.Keys); catlist.Sort(); HtmlContainerControl cc = new HtmlGenericControl("div"); cc.ID = "cats"; Controls.Add(cc); foreach (string category in catlist) { if (HiddenCategories != null) { if (HiddenCategories.Contains(category)) { continue; } } var pgc = new PropertyGridCategory { CategoryName = category }; _catlist.Add(pgc); cc.Controls.Add(pgc); var i = cats[category] as Hashtable; var il = new ArrayList(i.Keys); il.Sort(); foreach (string pginame in il) { var pgi = i[pginame] as PropertyGridItem; _proplist.Add(pgi); pgc.Controls.Add(pgi); if (pgi.Subitems.Count > 0) { var si = new SubItems(); pgi.Controls.Add(si); foreach (PropertyGridItem spgi in pgi.Subitems) { si.Controls.Add(spgi); _proplist.Add(spgi); } } } } }
/// <summary> /// Needs to be called to update selections that depend on the available logs, such as /// filtering by encounter name. /// </summary> /// <param name="logs">Logs to be available for filtering.</param> public void UpdateLogs(IReadOnlyList <LogData> logs) { // We construct a tree of groups. Everything is under an "All logs" node that can be used to easily select all. // All raid wings which have separate categories are within a meta group "Raids". Other than that, only // Encounter.Other logs have special handling - each unique target getting its own group. var rootGroup = new RootLogGroup(logs); var rootItem = new GroupFilterTreeItem(rootGroup); void UpdateIcons(GroupFilterTreeItem item) { item.Icon = item.LogGroup switch { RootLogGroup => imageProvider.GetTinyLogIcon(), RaidLogGroup => imageProvider.GetTinyRaidIcon(), CategoryLogGroup categoryGroup => GetCategoryIcon(categoryGroup.Category), EncounterLogGroup encounterGroup => GetEncounterIcon(encounterGroup.Encounter), MapLogGroup mapGroup => imageProvider.GetWvWMapIcon(mapGroup.Map), _ => item.Icon }; foreach (var child in item.Children) { UpdateIcons((GroupFilterTreeItem)child); } } void UpdateCounts(GroupFilterTreeItem item) { item.LogCount = logs.Count(log => item.LogGroup.IsInGroup(log)); foreach (var child in item.Children) { UpdateCounts((GroupFilterTreeItem)child); } } void PruneEmptyHiddenItems(GroupFilterTreeItem item) { // Removes items that have no logs associated with them and are undesirable for some reason. var toRemove = new List <GroupFilterTreeItem>(); foreach (var child in item.Children) { var groupTreeItem = (GroupFilterTreeItem)child; bool removed = false; if (groupTreeItem.LogGroup is EncounterLogGroup encounterLogGroup) { if (HiddenEncounters.Contains(encounterLogGroup.Encounter) && groupTreeItem.LogCount == 0) { toRemove.Add(groupTreeItem); removed = true; } } else if (groupTreeItem.LogGroup is CategoryLogGroup categoryLogGroup) { if (HiddenCategories.Contains(categoryLogGroup.Category) && groupTreeItem.LogCount == 0) { toRemove.Add(groupTreeItem); removed = true; } } if (!removed) { PruneEmptyHiddenItems(groupTreeItem); } } foreach (var childToRemove in toRemove) { item.Children.Remove(childToRemove); } } UpdateIcons(rootItem); UpdateCounts(rootItem); PruneEmptyHiddenItems(rootItem); DataStore = new TreeGridItemCollection { rootItem }; }