public TreeListBoxItem() { Children = new ObservableCollection<TreeListBoxItem>(); Children.CollectionChanged += Children_CollectionChanged; ChildrenProxy = new CompositeListProxy<TreeListBoxItem>(Children, e => e.List); List = new CompositeList(); List.AddCollection(new TreeListBoxItem[] { this }); List.AddCollection(ChildrenProxy); IsVisible = true; IsSelected = false; }
public TreeListBoxItem(bool isExanded) { _IsExpanded = isExanded; Children = new ObservableCollection<TreeListBoxItem>(); ChildrenProxy = new CompositeListProxy<TreeListBoxItem>(Children, e => e.List); List = new CompositeList(); List.AddCollection(new TreeListBoxItem[] { this }); if (isExanded) { List.AddCollection(ChildrenProxy); } IsVisible = true; IsSelected = false; }
public MainWindowModel() { SplitButtonCommand = new DelegateCommand<object>((o) => MessageBox.Show(string.Format("Hello from SplitButton: {0}", o))); SplitButtonItemCommand = new DelegateCommand<object>((o) => MessageBox.Show(string.Format("Hello from SplitButtonItem: {0}", o))); AddTabCommand = new DelegateCommand(AddTab); Items = new List<string>() { "Aaa", "Bbb", "Ccc" }; OpenItems = new List<string>() { "Open", "Open read-only", "Open as copy", "Open in browser", "Open with transform", "Open and repair", "Show previous version" }; Tabs1 = new ObservableCollection<object>(); Tabs2 = new ObservableCollection<object>(); Tabs3 = new ObservableCollection<object>(); RequestAutoCompleteItemsCommand = new DelegateCommand(RequestAutoCompleteItems); var cl = new CompositeList(); foreach (var item in Enumerable.Range(1, 100)) { cl.AddCollection(new FolderNode(string.Format("Folder {0}", item), Enumerable.Range(1, 500).Select(i => string.Format("File {0}", i + (item - 1) * 100)).ToList()).List); } TreeList = cl; }
public void TestAddChild_and_parent() { var listA = new CompositeList <string> { Content = "a" }; var listB = new CompositeList <string> { Content = "b" }; var listC = new CompositeList <string>(); listC.AddChild(listA); listC.AddChild(listB); var listE = new CompositeList <string> { Content = "e" }; var listF = new CompositeList <string> { Content = "f" }; var listG = new CompositeList <string>(); listG.AddChild(listE); listG.AddChild(listF); var listD = new CompositeList <string>(); listD.AddChild(listC); listD.AddChild(listG); listD.Count().ShouldEqual(7); listA.Parent.ShouldEqual(listC); listB.Parent.ShouldEqual(listC); listE.Parent.ShouldEqual(listG); listF.Parent.ShouldEqual(listG); listC.Parent.ShouldEqual(listD); listG.Parent.ShouldEqual(listD); Assert.IsNull(listD.Parent); }
public CompositeListEnumerator(CompositeList list) { _list = list; }
public void TestAddChild_and_parent() { var listA = new CompositeList<string> { Content = "a" }; var listB = new CompositeList<string> { Content = "b" }; var listC = new CompositeList<string>(); listC.AddChild(listA); listC.AddChild(listB); var listE = new CompositeList<string> { Content = "e" }; var listF = new CompositeList<string> { Content = "f" }; var listG = new CompositeList<string>(); listG.AddChild(listE); listG.AddChild(listF); var listD = new CompositeList<string>(); listD.AddChild(listC); listD.AddChild(listG); listD.Count().ShouldEqual(7); listA.Parent.ShouldEqual(listC); listB.Parent.ShouldEqual(listC); listE.Parent.ShouldEqual(listG); listF.Parent.ShouldEqual(listG); listC.Parent.ShouldEqual(listD); listG.Parent.ShouldEqual(listD); Assert.IsNull(listD.Parent); }
public static CompositeList<string> ParseBrackets(this string @string) { var result = new CompositeList<string>(); var stack = new Stack<Tuple<char, string>>(); var collected = ""; var currentComposite = result; for (var i = 0; i < @string.Length; i++) { var c = @string.CharAt(i); switch (c) { case '(': stack.Push(c.Pair(collected)); collected = ""; var child = new CompositeList<string>(); currentComposite.AddChild(child); currentComposite = child; break; case '{': stack.Push(c.Pair(collected)); collected = ""; var child2 = new CompositeList<string>(); currentComposite.AddChild(child2); currentComposite = child2; break; case ')': if (stack.None()) return result; if (stack.Peek().Item1 == '(') { currentComposite.Content = collected; collected = stack.Pop().Item2; currentComposite = (CompositeList<string>)currentComposite.Parent; } else return result; break; case '}': if (stack.None()) return result; if (stack.Peek().Item1 == '{') { currentComposite.Content = collected; collected = stack.Pop().Item2; currentComposite = (CompositeList<string>)currentComposite.Parent; } else return result; break; default: collected += c; break; } } currentComposite.Content = collected; return result; }
public static CompositeList <string> ParseBrackets(this string @string) { var result = new CompositeList <string>(); var stack = new Stack <Tuple <char, string> >(); var collected = ""; var currentComposite = result; for (var i = 0; i < @string.Length; i++) { var c = @string.CharAt(i); switch (c) { case '(': stack.Push(c.Pair(collected)); collected = ""; var child = new CompositeList <string>(); currentComposite.AddChild(child); currentComposite = child; break; case '{': stack.Push(c.Pair(collected)); collected = ""; var child2 = new CompositeList <string>(); currentComposite.AddChild(child2); currentComposite = child2; break; case ')': if (stack.None()) { return(result); } if (stack.Peek().Item1 == '(') { currentComposite.Content = collected; collected = stack.Pop().Item2; currentComposite = (CompositeList <string>)currentComposite.Parent; } else { return(result); } break; case '}': if (stack.None()) { return(result); } if (stack.Peek().Item1 == '{') { currentComposite.Content = collected; collected = stack.Pop().Item2; currentComposite = (CompositeList <string>)currentComposite.Parent; } else { return(result); } break; default: collected += c; break; } } currentComposite.Content = collected; return(result); }