Пример #1
0
        public void PerformSearch()
        {
            if (_MatchingItemEnumerator == null || !_MatchingItemEnumerator.MoveNext())
            {
                VerifyMatchingItemEnumerator();
            }
            if (_MatchingItemEnumerator == null)
            {
                return;
            }

            var item = _MatchingItemEnumerator.Current;

            if (item == null)
            {
                return;
            }

            if (item.Parent != null)
            {
                ClassItemViewModel parent = (ClassItemViewModel)item.Parent;
                parent.IsExpanded = true;
            }

            // TODO switch search to filter (hide unmatched items), probably handled by the UI instead

            item.IsSelected = true;
        }
Пример #2
0
        public ClassItemViewModel(ClassItem item, ClassItemViewModel parent) : base(parent)
        {
            _Model = item;

            _Children = new Services.ObservableSortedList <ClassItemViewModel>(
                (from child in _Model.Children select new ClassItemViewModel(item, null)).ToList <ClassItemViewModel>(),
                new Comparers.ClassItemComparer()
                );
        }
Пример #3
0
        public ClassItemViewModel(ClassItem item, ClassItemViewModel parent)
            : base(parent)
        {
            _Model = item;

            _Children = new Services.ObservableSortedList<ClassItemViewModel>(
                (from child in _Model.Children select new ClassItemViewModel(item, null)).ToList<ClassItemViewModel>(),
                new Comparers.ClassItemComparer()
            );
        }
Пример #4
0
        private void StartTree()
        {
            ClassItemViewModel root = new ClassItemViewModel(new Models.ClassItem()
            {
                Name = "Classes", Type = Models.ClassItemType.Root
            });

            _First.Add(root);

            _First[0].IsExpanded = true;
        }
Пример #5
0
        private void VerifySelectedItemEnumerator()
        {
            ClassItemViewModel root = RootItem;

            var matches = FindSelected(root);

            _SelectedItemEnumerator = matches.GetEnumerator();
            if (!_SelectedItemEnumerator.MoveNext())
            {
                // none selected
            }
        }
Пример #6
0
        private IEnumerable <ClassItemViewModel> FindMatches(string text, ClassItemViewModel item)
        {
            if (item == null)
            {
                yield return(null);
            }
            if (item.NameContainsText(text))
            {
                yield return(item);
            }

            foreach (ClassItemViewModel child in item.Children)
            {
                foreach (ClassItemViewModel match in FindMatches(text, child))
                {
                    yield return(match);
                }
            }
        }
Пример #7
0
        private IEnumerable <ClassItemViewModel> FindSelected(ClassItemViewModel item)
        {
            if (item == null)
            {
                yield return(null);
            }

            if (item.IsSelected)
            {
                yield return(item);
            }

            foreach (ClassItemViewModel child in item.Children)
            {
                foreach (ClassItemViewModel match in FindSelected(child))
                {
                    // TODO fix collection modified exception
                    yield return(match);
                }
            }
        }
Пример #8
0
        public void AddNamespaces(List <Interop.AssemblyObject> namespaces)
        {
            foreach (Interop.AssemblyObject n in namespaces)
            {
                ClassItemViewModel nitem = new ClassItemViewModel(
                    new Models.ClassItem()
                {
                    Name      = n.Name,
                    Namespace = n.Namespace,
                    Type      = Models.ClassItemType.Namespace
                },
                    RootItem
                    );

                foreach (Interop.AssemblyObject child in n.Children)
                {
                    ClassItemViewModel citem = new ClassItemViewModel(
                        new Models.ClassItem()
                    {
                        Name      = child.Name,
                        Namespace = child.Namespace,
                        Type      = Models.ClassItemType.Object
                    },
                        nitem
                        );

                    foreach (Interop.AssemblyObject field in child.Fields)
                    {
                        ClassItemViewModel fitem = new ClassItemViewModel(
                            new Models.ClassItem()
                        {
                            Name      = field.Name,
                            Namespace = field.Namespace,
                            Type      = Models.ClassItemType.Field
                        },
                            citem
                            );
                        citem.AddChild(fitem);
                    }

                    foreach (Interop.AssemblyObject property in child.Properties)
                    {
                        ClassItemViewModel pitem = new ClassItemViewModel(
                            new Models.ClassItem()
                        {
                            Name      = property.Name,
                            Namespace = property.Namespace,
                            Type      = Models.ClassItemType.Property
                        },
                            citem
                            );
                        citem.AddChild(pitem);
                    }

                    foreach (Interop.AssemblyObject method in child.Methods)
                    {
                        ClassItemViewModel mitem = new ClassItemViewModel(
                            new Models.ClassItem()
                        {
                            Name      = method.Name,
                            Namespace = method.Namespace,
                            Type      = Models.ClassItemType.Method
                        },
                            citem
                            );
                        citem.AddChild(mitem);
                    }

                    nitem.AddChild(citem);
                }

                RootItem.AddChild(nitem);
            }
        }
Пример #9
0
 public void AddChild(ClassItemViewModel item)
 {
     _Children.Add(item);
     Model.Children.Add(item.Model);
 }
Пример #10
0
        private void StartTree()
        {
            ClassItemViewModel root = new ClassItemViewModel(new Models.ClassItem() { Name = "Classes", Type = Models.ClassItemType.Root });

            _First.Add(root);

            _First[0].IsExpanded = true;
        }
Пример #11
0
        private IEnumerable<ClassItemViewModel> FindSelected(ClassItemViewModel item)
        {
            if (item == null)
            {
                yield return null;
            }

            if (item.IsSelected)
            {
                yield return item;
            }

            foreach (ClassItemViewModel child in item.Children)
            {
                foreach (ClassItemViewModel match in FindSelected(child))
                {
                    // TODO fix collection modified exception
                    yield return match;
                }
            }
        }
Пример #12
0
        private IEnumerable<ClassItemViewModel> FindMatches(string text, ClassItemViewModel item)
        {
            if (item == null)
            {
                yield return null;
            }
            if (item.NameContainsText(text))
            {
                yield return item;
            }

            foreach (ClassItemViewModel child in item.Children)
            {
                foreach (ClassItemViewModel match in FindMatches(text, child))
                {
                    yield return match;
                }
            }
        }
Пример #13
0
        public void AddNamespaces(List<Interop.AssemblyObject> namespaces)
        {
            foreach (Interop.AssemblyObject n in namespaces)
            {
                ClassItemViewModel nitem = new ClassItemViewModel(
                    new Models.ClassItem()
                    {
                        Name = n.Name,
                        Namespace = n.Namespace,
                        Type = Models.ClassItemType.Namespace
                    },
                    RootItem
                );

                foreach (Interop.AssemblyObject child in n.Children)
                {
                    ClassItemViewModel citem = new ClassItemViewModel(
                        new Models.ClassItem()
                        {
                            Name = child.Name,
                            Namespace = child.Namespace,
                            Type = Models.ClassItemType.Object
                        },
                        nitem
                    );

                    foreach (Interop.AssemblyObject field in child.Fields)
                    {
                        ClassItemViewModel fitem = new ClassItemViewModel(
                            new Models.ClassItem()
                            {
                                Name = field.Name,
                                Namespace = field.Namespace,
                                Type = Models.ClassItemType.Field
                            },
                            citem
                        );
                        citem.AddChild(fitem);
                    }

                    foreach (Interop.AssemblyObject property in child.Properties)
                    {
                        ClassItemViewModel pitem = new ClassItemViewModel(
                            new Models.ClassItem()
                            {
                                Name = property.Name,
                                Namespace = property.Namespace,
                                Type = Models.ClassItemType.Property
                            },
                            citem
                        );
                        citem.AddChild(pitem);
                    }

                    foreach (Interop.AssemblyObject method in child.Methods)
                    {
                        ClassItemViewModel mitem = new ClassItemViewModel(
                            new Models.ClassItem()
                            {
                                Name = method.Name,
                                Namespace = method.Namespace,
                                Type = Models.ClassItemType.Method
                            },
                            citem
                        );
                        citem.AddChild(mitem);
                    }

                    nitem.AddChild(citem);
                }

                RootItem.AddChild(nitem);
            }
        }
Пример #14
0
 public void AddChild(ClassItemViewModel item)
 {
     _Children.Add(item);
     Model.Children.Add(item.Model);
 }