private void FilterEntities() { List <object> list = new List <object>(); foreach (var entity in _game.Entities) { var tags = entity.Value.Tags.Select(GetTagKeyValue).Aggregate((c, n) => c + " | " + n); var card = GameV2.GetCardFromId(entity.Value.CardId); var cardName = card != null ? card.Name : ""; var name = string.IsNullOrEmpty(entity.Value.Name) ? cardName : entity.Value.Name; list.Add(new { Name = name, entity.Value.CardId, Tags = tags }); } var firstNotSecond = list.Except(_previous).ToList(); var secondNotFirst = _previous.Except(list).ToList(); if (firstNotSecond.Any() || secondNotFirst.Any()) { DataGridProperties.ItemsSource = list; DataGridProperties.UpdateLayout(); foreach (var item in firstNotSecond) { var row = DataGridProperties.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow; if (row != null) { row.Background = new SolidColorBrush(Color.FromArgb(50, 0, 205, 0)); } } _previous = list; } }
private void FilterGame() { List <object> list = new List <object>(); var props = typeof(GameV2).GetProperties().OrderBy(x => x.Name); foreach (var prop in props) { if (prop.Name == "HSLogLines" || prop.Name == "Entities") { continue; } string val = ""; var propVal = prop.GetValue(_game, null); if (propVal != null) { var enumerable = propVal as IEnumerable <object>; var collection = propVal as ICollection; if (enumerable != null) { enumerable = enumerable.Where(x => x != null); if (enumerable.Any()) { val = enumerable.Select(x => x.ToString()).Aggregate((c, n) => c + ", " + n); } } else if (collection != null) { var objects = collection.Cast <object>().Where(x => x != null); if (objects.Any()) { val = objects.Select(x => x.ToString()).Aggregate((c, n) => c + ", " + n); } } else { val = propVal.ToString(); } } list.Add(new { Property = prop.Name, Value = val }); } var firstNotSecond = list.Except(_previous).ToList(); var secondNotFirst = _previous.Except(list).ToList(); if (firstNotSecond.Any() || secondNotFirst.Any()) { DataGridProperties.ItemsSource = list; DataGridProperties.UpdateLayout(); foreach (var item in firstNotSecond) { var row = DataGridProperties.ItemContainerGenerator.ContainerFromItem(item) as DataGridRow; if (row != null) { row.Background = new SolidColorBrush(Color.FromArgb(50, 0, 205, 0)); } } _previous = list; } }