コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public CompositeListEnumerator(CompositeList list)
 {
     _list = list;
 }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: Parsing.cs プロジェクト: drbatty/c-sharp-extensions
        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;
        }
コード例 #8
0
ファイル: Parsing.cs プロジェクト: drbatty/c-sharp-extensions
        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);
        }