private void FullfillTreeNode(EntityTreeViewItem node, TreeNodeEntity nodeEntity, BitmapImage image) { foreach (var item in nodeEntity.SubNodes.OrderBy(s => s.Name)) { EntityTreeViewItem directoryNode = new EntityTreeViewItem(item.Name, null, _folderImage); node.Items.Add(directoryNode); FullfillTreeNode(directoryNode, item, image); } foreach (var item in nodeEntity.Entities.OrderBy(s => s.Item1)) { string name = item.Item1; EntityTreeViewItem tn = new EntityTreeViewItem(name, item.Item2, image); StringBuilder result = new StringBuilder(); if (item.Item2.IsManaged.GetValueOrDefault()) { if (result.Length > 0) { result.Append(" "); } result.Append("Managed"); } if (item.Item2.IsHidden.Value) { if (result.Length > 0) { result.Append(" "); } result.Append("Hidden"); } if (result.Length > 0) { tn.Description = result.ToString(); } node.Items.Add(tn); } if (node.Items.Count > 0) { node.Description = node.Items.Count.ToString(); } }
private void LoadWebResources(IEnumerable <WebResource> results) { ObservableCollection <EntityTreeViewItem> list = new ObservableCollection <EntityTreeViewItem>(); var groupList = results .GroupBy(a => a.WebResourceType.Value) .OrderBy(a => a.Key); foreach (var group in groupList) { var groupName = group.First().FormattedValues[WebResource.Schema.Attributes.webresourcetype]; BitmapImage image = null; if (_typeImageMapping.ContainsKey(group.Key)) { image = _typeImageMapping[group.Key]; } var node = new EntityTreeViewItem(groupName, null, image); var nodeEntity = TreeNodeEntity.Convert(group); FullfillTreeNode(node, nodeEntity, image); list.Add(node); } ExpandNode(list); this.trVWebResources.Dispatcher.Invoke(() => { this.trVWebResources.BeginInit(); this.trVWebResources.ItemsSource = list; this.trVWebResources.EndInit(); }); }