Ejemplo n.º 1
0
        private IEnumerable <T> GetThemeItems(ThemeItemCategoryModel item)
        {
            IEnumerable <T> first = Enumerable.OfType <T>((IEnumerable)item.Children);

            foreach (ThemeItemCategoryModel itemCategoryModel in Enumerable.OfType <ThemeItemCategoryModel>((IEnumerable)item.Children))
            {
                first = Enumerable.Concat <T>(first, this.GetThemeItems(itemCategoryModel));
            }
            return(first);
        }
Ejemplo n.º 2
0
        private void AddThemeItem(ThemeItemModel model, bool isDefault)
        {
            ThemeItemCategoryModel category = this.GetCategory(model);

            if (Enumerable.FirstOrDefault <ThemeItemModel>(Enumerable.Where <ThemeItemModel>(Enumerable.OfType <ThemeItemModel>((IEnumerable)category.Children), (Func <ThemeItemModel, bool>)(t => ThemeModel.ThemeItemsEqual(t.ThemeItem, model.ThemeItem)))) != null)
            {
                return;
            }
            model.Parent = (ThemeTreeItem)category;
            category.Children.Add((ThemeTreeItem)model);
        }
Ejemplo n.º 3
0
        protected void Sort()
        {
            List <ThemeTreeItem> list = new List <ThemeTreeItem>((IEnumerable <ThemeTreeItem>) this.Children);

            list.Sort();
            this.Children.Clear();
            foreach (ThemeTreeItem themeTreeItem in list)
            {
                this.Children.Add(themeTreeItem);
                ThemeItemCategoryModel itemCategoryModel = themeTreeItem as ThemeItemCategoryModel;
                if (itemCategoryModel != null)
                {
                    itemCategoryModel.Sort();
                }
            }
        }
Ejemplo n.º 4
0
        private ThemeItemCategoryModel GetCategory(ThemeItemModel item)
        {
            string[] categoryNames = (item.Category ?? string.Empty).Split(new char[1]
            {
                '\\'
            });
            ThemeItemCategoryModel itemCategoryModel1 = (ThemeItemCategoryModel)this;

            for (int index = 0; index < categoryNames.Length; ++index)
            {
                if (categoryNames[index] != string.Empty)
                {
                    int i1 = index;
                    ThemeItemCategoryModel itemCategoryModel2 = Enumerable.FirstOrDefault <ThemeItemCategoryModel>(Enumerable.Where <ThemeItemCategoryModel>(Enumerable.OfType <ThemeItemCategoryModel>((IEnumerable)itemCategoryModel1.Children), (Func <ThemeItemCategoryModel, bool>)(c => c.Name == categoryNames[i1])));
                    if (itemCategoryModel2 == null)
                    {
                        itemCategoryModel2 = item.CreateCategory(categoryNames[index], (ThemeTreeItem)itemCategoryModel1);
                        itemCategoryModel1.Children.Add((ThemeTreeItem)itemCategoryModel2);
                    }
                    itemCategoryModel1 = itemCategoryModel2;
                }
            }
            return(itemCategoryModel1);
        }
Ejemplo n.º 5
0
        private static void UpdateVisibility(ThemeModel themeModel, ThemeTreeItem item)
        {
            ThemeItemModel themeItemModel = item as ThemeItemModel;

            if (themeItemModel != null)
            {
                if (themeModel.HideDefaultItems)
                {
                    themeItemModel.Visibility = themeItemModel.IsDefault ? Visibility.Collapsed : Visibility.Visible;
                }
                else
                {
                    themeItemModel.Visibility = Visibility.Visible;
                }
            }
            else
            {
                ThemeItemCategoryModel itemCategoryModel = item as ThemeItemCategoryModel;
                if (itemCategoryModel == null)
                {
                    return;
                }
                foreach (ThemeTreeItem themeTreeItem in (Collection <ThemeTreeItem>)itemCategoryModel.Children)
                {
                    ThemeModel.UpdateVisibility(themeModel, themeTreeItem);
                }
                if (Enumerable.FirstOrDefault <ThemeTreeItem>((IEnumerable <ThemeTreeItem>)itemCategoryModel.Children, (Func <ThemeTreeItem, bool>)(o => o.Visibility != Visibility.Collapsed)) == null)
                {
                    itemCategoryModel.Visibility = Visibility.Collapsed;
                }
                else
                {
                    itemCategoryModel.Visibility = Visibility.Visible;
                }
            }
        }