public static void AddItem(this CommunityViewModel viewModel, MessageViewModel messageViewModel) { if (messageViewModel.BuildIn) { viewModel.BuildInTypes.Add(messageViewModel); return; } viewModel.AddItem(messageViewModel, messageViewModel.RelativeNamespace); }
public static TreeViewItem FindViewItemById(this CommunityViewModel community, Guid id) { Stack <TreeViewItem> unvisited = new(new [] { community }); while (unvisited.Any()) { TreeViewItem item = unvisited.Pop(); if (item is AgentViewModel agent && agent.ModelId == id) { return(agent); }
public static IEnumerable <T> FindItemsByType <T>(this CommunityViewModel community) where T : TreeViewItem { List <T> items = new(); Stack <TreeViewItem> unvisited = new(new [] { community }); while (unvisited.Any()) { TreeViewItem item = unvisited.Pop(); if (item is T value) { items.Add(value); } foreach (TreeViewItem child in item.Items) { unvisited.Push(child); } } return(items); }
public static T FindItemByType <T>(this CommunityViewModel community) where T : TreeViewItem { return(community.FindItemsByType <T>().FirstOrDefault()); }
public static void AddItem(this CommunityViewModel viewModel, AgentViewModel agentViewModel) { viewModel.AddItem(agentViewModel, agentViewModel.RelativeNamespace); }
public TreeViewModel() { Community = new CommunityViewModel(); }