public static void ToTree(this SimpleObservableCollection <MarbleDiagramTree> tree, IEnumerable <Marble> items) { foreach (var item in items) { tree.ToTree(item); } }
public static void ToTree(this SimpleObservableCollection <MarbleDiagramTree> tree, Marble item) { var path = $"{item.StreamKey}.{item.MachineName}".Split('.'); var mi = GetItem(tree, path[0]); for (int i = 1; i < path.Length; i++) { mi = GetItem(mi.Categories, path[i]); } var diagram = GetDiagram(mi, item.StreamKey); diagram.Items.Add(item); }
private static MarbleDiagramTree GetItem(SimpleObservableCollection <MarbleDiagramTree> tree, string name) { var mi = tree.FirstOrDefault(m => m.Name == name); if (mi == null) { mi = new MarbleDiagramTree() { Name = name }; tree.Add(mi); } return(mi); }