diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-21 14:30:01 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-21 14:30:01 +0200 |
| commit | 36dcf50eec20835ab1955932e89f9c6ffc68acde (patch) | |
| tree | 3ca1331b626f04c8f19af24b65b7459b5f0660cb /Software/Visual_Studio/Tango.Explorer/ExplorerFolderItem.cs | |
| parent | 5f321b419501b2c836e8b03400fff2934be5f135 (diff) | |
| download | Tango-36dcf50eec20835ab1955932e89f9c6ffc68acde.tar.gz Tango-36dcf50eec20835ab1955932e89f9c6ffc68acde.zip | |
Working on Touch FileExplorer !
Diffstat (limited to 'Software/Visual_Studio/Tango.Explorer/ExplorerFolderItem.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Explorer/ExplorerFolderItem.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Explorer/ExplorerFolderItem.cs b/Software/Visual_Studio/Tango.Explorer/ExplorerFolderItem.cs new file mode 100644 index 000000000..48f870b20 --- /dev/null +++ b/Software/Visual_Studio/Tango.Explorer/ExplorerFolderItem.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace Tango.Explorer +{ + public class ExplorerFolderItem : ExplorerItem + { + private static List<String> extensions = ExplorerFileDefinition.GetSupportedExtensions().Select(x => x.Replace(".","")).ToList(); + + public List<ExplorerItem> Items { get; set; } + + public ExplorerFolderItem() + { + Items = new List<ExplorerItem>(); + } + + public static ExplorerFolderItem LoadFromPath(String path) + { + ExplorerFolderItem folderItem = new ExplorerFolderItem(); + + folderItem.Path = path; + folderItem.Icon = ExplorerFileDefinition.Folder.Icon; + folderItem.Name = System.IO.Path.GetFileName(path); + + foreach (var folder in new DirectoryInfo(path).GetDirectories().Where(x => !x.Attributes.HasFlag(FileAttributes.Hidden))) + { + ExplorerFolderItem fItem = new ExplorerFolderItem(); + fItem.Path = folder.FullName; + fItem.Icon = ExplorerFileDefinition.Folder.Icon; + fItem.Name = System.IO.Path.GetFileName(folder.FullName); + folderItem.Items.Add(fItem); + } + + foreach (var file in Directory.GetFiles(path,"*.*").Where(f => extensions.Contains(f.Split('.').Last().ToLower())).ToArray()) + { + folderItem.Items.Add(ExplorerFileItem.LoadFromPath(file)); + } + + return folderItem; + } + + public String GetParentPath() + { + var parent = new DirectoryInfo(Path).Parent; + var parentPath = parent != null ? parent.FullName : null; + return parentPath; + } + } +} |
