Exemplo n.º 1
0
 public static void SelectAll(this CategoryViewModelCollection categories, bool isSelected)
 {
     foreach (var category in categories.GetDescendants())
     {
         category.IsSelected = isSelected;
     }
 }
Exemplo n.º 2
0
 public static void ExpandAllMain(this CategoryViewModelCollection categories, bool isExpanded)
 {
     foreach (var category in categories.GetDescendants())
     {
         category.IsExpandedMainView = isExpanded;
     }
 }
Exemplo n.º 3
0
        public static void ExpandMainViewToDescendant(this CategoryViewModelCollection categories, CategoryViewModel item, bool isExpanded)
        {
            // update parent nodes
            var tmp = item;

            while (tmp.HasParent)
            {
                var parent = categories.GetDescendants().FirstOrDefault(_ => _.Id == tmp.ParentCategoryId.Value);
                parent.IsExpandedMainView = isExpanded;
                tmp = parent;
            }
        }
Exemplo n.º 4
0
        public static void SelectBranch(this CategoryViewModelCollection categories, CategoryViewModel item, bool isSelected)
        {
            void SelectAll(CategoryViewModel category)
            {
                category.IsSelected = isSelected;
                foreach (var child in category.Children)
                {
                    SelectAll(child);
                }
            };

            SelectAll(item);
        }
Exemplo n.º 5
0
        public CategoryDetailsView(ICategoryService service, CategoryModel entity, bool isNew, CategoryViewModelCollection categories)
            : base(service, entity, isNew)
        {
            InitializeComponent();

            // init categories
            var cats = new CategoryViewModelCollection(categories);

            ParentCategorySelector.Categories = cats;

            // set header and commands panel context
            LabelHeader.Content       = ViewHeader;
            CommandsPanel.DataContext = Commands;
        }
Exemplo n.º 6
0
        public static CategoryViewModelCollection BuildTree(IEnumerable <CategoryModel> categories, bool insertEmpty = false)
        {
            var result = new CategoryViewModelCollection();

            foreach (var category in categories.Where(_ => !_.ParentCategoryId.HasValue))
            {
                result.Add(BuildCategoryBranch(categories, category));
            }

            if (insertEmpty)
            {
                result.Insert(0, new CategoryViewModel()
                {
                    Id   = -1,
                    Name = MultiLangResourceManager.Instance[MultiLangResourceName.None]
                });
            }

            return(result);
        }