Пример #1
0
        void AddTypeItem(List <string> path, ObservableCollection <TypeItem> typeItems, TypeItem item)
        {
            var currentPathName = path[0];

            path.RemoveAt(0);
            if (path.Count == 0)
            {
                typeItems.Add(item);
            }
            else
            {
                bool find = false;
                foreach (var itm in typeItems)
                {
                    if (itm.TypeName == currentPathName)
                    {
                        find = true;
                        AddTypeItem(path, itm.ChildList, item);
                        break;
                    }
                }

                if (!find)
                {
                    var parentItem = new TypeItem();
                    parentItem.TypeName = currentPathName;
                    typeItems.Add(parentItem);
                    AddTypeItem(path, parentItem.ChildList, item);
                }
            }
        }
Пример #2
0
        TypeItem CreateTypeItem(Type type, string typename = null)
        {
            var retVal = new TypeItem()
            {
                Type     = type,
                TypeIcon = TryFindResource("Icon_Pill") as ImageSource,
            };

            if (typename == null)
            {
                retVal.TypeName = type.Name;
            }
            else
            {
                retVal.TypeName = typename;
            }

            return(retVal);
        }