Esempio n. 1
0
 //By Johann
 /// <summary>
 /// Loads the child categories of the selected parent category into the BindableCollection
 /// </summary>
 private void LoadChildCategories()
 {
     ChildCategories.Clear();
     if (SelectedParentCategory != null)
     {
         ChildCategories.AddRange(Category.GetCategoriesByParent(SelectedParentCategory.Id));
     }
 }
        internal void FillImageCategoriesTree(IDictionary <string, IList <string> > categories, List <string> imageNames, ICollection <string> currentLevelChildren)
        {
            List <string> nextLevelChildren = new List <string>(currentLevelChildren);

            if (ParentCategory != null && ParentCategory.ParentCategory == null)
            {
                nextLevelChildren = new List <string>(categories.Keys);
            }
            nextLevelChildren.Remove(Name);

            List <string> nextLevelImageTreeNodes = new List <string>(imageNames);
            Dictionary <string, List <string> > childCategoriesImageNames = new Dictionary <string, List <string> >();

            foreach (string imageName in imageNames)
            {
                images.Add(new ImagePreviewObject(Owner, imageName));
                foreach (string categoryName in nextLevelChildren)
                {
                    if (categoryName != Name)
                    {
                        if (!childCategoriesImageNames.ContainsKey(categoryName))
                        {
                            childCategoriesImageNames.Add(categoryName, new List <string>());
                        }
                        if (categories[categoryName].Contains(imageName))
                        {
                            childCategoriesImageNames[categoryName].Add(imageName);
                            nextLevelImageTreeNodes.Remove(imageName);
                        }
                    }
                }
            }

            foreach (string childCategoryName in childCategoriesImageNames.Keys)
            {
                if (childCategoriesImageNames[childCategoryName].Count == 1)
                {
                    if (!nextLevelImageTreeNodes.Contains(childCategoriesImageNames[childCategoryName][0]))
                    {
                        nextLevelImageTreeNodes.Add(childCategoriesImageNames[childCategoryName][0]);
                    }
                }
                else if (childCategoriesImageNames[childCategoryName].Count > 1)
                {
                    ImagesGroupNode childCategory = new ImagesGroupNode(Owner, this, childCategoryName);
                    ChildCategories.Add(childCategory);
                    childCategory.FillImageCategoriesTree(categories, childCategoriesImageNames[childCategoryName], nextLevelChildren);
                }
            }
            foreach (string nextLevelImageTreeNode in nextLevelImageTreeNodes)
            {
                ImageNode imageTreeNode = new ImageNode(Owner, nextLevelImageTreeNode);
                ChildCategories.Add(imageTreeNode);
            }
        }
Esempio n. 3
0
 public virtual void AddChildCategory(Category category)
 {
     if (category == null)
     {
         throw new ArgumentException("Can't add a null Category as child.");
     }
     // Remove from old parent category
     if (category.ParentCategory != null)
     {
         category.ParentCategory.ChildCategories.Remove(category);
     }
     // Set parent in child
     category.ParentCategory = this;
     // Set child in parent
     ChildCategories.Add(category);
 }
Esempio n. 4
0
 protected override void ClearNavigationProperties()
 {
     ChildCategories.Clear();
     ParentCategory = null;
 }
Esempio n. 5
0
 public void AddChild(Category category) => ChildCategories.Add(category);
Esempio n. 6
0
 private void AddChildCategory(Category category)
 {
     ChildCategories.Add(category);
 }
Esempio n. 7
0
 private void RemoveChildCategory(Category category)
 {
     ChildCategories.Remove(category);
 }
 public virtual void AddChild(Category child)
 {
     ChildCategories.Add(child);
     child.ParentCategory = this;
 }