Exemplo n.º 1
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var path = (string)value;

            // if path is null
            if (path == null)
            {
                return(null);
            }

            //get name of file/folder
            var name = DirectoryStructure.GetFileFolderName(path);
            //by default, assume file image
            var image = "Images/file.png";

            if (string.IsNullOrEmpty(name))
            {
                image = "Images/drive.png";
            }
            else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory))
            {
                image = "Images/folder-closed.png";
            }

            return(new BitmapImage(new Uri($"pack://application:,,,/{image}")));
        }
Exemplo n.º 2
0
        //expands directory
        private void Expand()
        {
            if (this.Type == DirectoryItemType.File)
            {
                return;
            }

            var children = DirectoryStructure.GetDirectoryContent(this.FullPath);

            this.Children = new ObservableCollection <DirectoryItemViewModel>(
                children.Select(content => new DirectoryItemViewModel(content.FullPath, content.Type)));
        }