Esempio n. 1
0
        public IOItem AddItem(FileSystemInfo pathInfo, IOItemType type)
        {
            string[] segments = pathInfo.FullName.Split(Path.DirectorySeparatorChar);

            ObservableCollection <IOItem> currentItemList = Root;
            IOItem lastItem = null;

            //enumerate through all items in the list
            for (int i = 0; i < segments.Length - 1; i++)
            {
                foreach (IOItem item in currentItemList)
                {
                    string name = item.DisplayName.Trim('\\');
                    if (item.DisplayName.Trim('\\') == segments[i])
                    {
                        //item found, set currentItemList one path higher
                        currentItemList = item.Children;
                        lastItem        = item;
                    }
                }
            }
            //reload the children (refresh TreeView UI)
            lastItem.SetChildren();
            //return the new IOItem
            return(lastItem.Children.Single(i => i.DisplayName == segments[segments.Length - 1]));
        }
Esempio n. 2
0
        internal IOItem(string path, IOItemType type, IOItem parent, List <Wildcard> fileWildcard, List <Wildcard> dirWildcard, FileSystemTemplate template)
        {
            switch (type)
            {
            case IOItemType.Folder:
                ItemInfo = new DirectoryInfo(path);
                break;

            case IOItemType.File:
                ItemInfo = new FileInfo(path);
                break;
            }

            Icon i = GetIcon(path, type);

            this.Icon         = Imaging.CreateBitmapSourceFromHIcon(i.Handle, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(i.Width, i.Height));
            this.Type         = type;
            this.Parent       = parent;
            this.fileWildcard = fileWildcard;
            this.dirWildcard  = dirWildcard;
            _template         = template;
        }