Exemplo n.º 1
0
        public void AddItem(int index, ITreeViewItem item)
        {
            SubCategory category = item as SubCategory;

            if (category.IsNullObj())
            {
                return;
            }
            SubCategories.Insert(index, category);
        }
Exemplo n.º 2
0
        public void InsertSubCategory(NodeCategoryViewModel newSubCategory)
        {
            var list = SubCategories.Where(cat => !(cat is ClassesNodeCategoryViewModel));
            var nextLargerItemIndex = FindInsertionPointByName(list, newSubCategory.Name);

            if (nextLargerItemIndex >= 0)
            {
                bool hasClasses = SubCategories.FirstOrDefault() is ClassesNodeCategoryViewModel;
                var  offset     = hasClasses ? 1 : 0;
                SubCategories.Insert(nextLargerItemIndex + offset, newSubCategory);
            }
            else
            {
                SubCategories.Add(newSubCategory);
            }
        }
Exemplo n.º 3
0
        public void InsertSubCategory(NodeCategoryViewModel newSubCategory)
        {
            var first = SubCategories.Select((x, i) => new { x.Name, Idx = i })
                        .FirstOrDefault(
                x =>
                string.Compare(
                    x.Name,
                    newSubCategory.Name,
                    StringComparison.Ordinal)
                >= 0);

            if (first != null)
            {
                SubCategories.Insert(first.Idx, newSubCategory);
            }
            else
            {
                SubCategories.Add(newSubCategory);
            }
        }