public static ThemeResource Get(string path) { var directory = new DirectoryInfo(path); var resource = new ThemeResource { Path = directory.FullName, Text = directory.Name, IsDirectory = true }; foreach (var child in directory.GetFiles()) { resource.AddChild(new ThemeResource { Path = child.FullName, Text = child.Name, IsDirectory = false, Icon = "file text outline icon" }); } foreach (var child in directory.GetDirectories()) { resource.AddChild(new ThemeResource { Path = child.FullName, Text = child.Name, IsDirectory = true, Icon = "folder open outline icon" }); } return resource; }
public static ThemeResource Get(string path) { var directory = new DirectoryInfo(path); var resource = new ThemeResource { Path = directory.FullName, Text = directory.Name, IsDirectory = true }; foreach (var child in directory.GetFiles()) { resource.AddChild(new ThemeResource { Path = child.FullName, Text = child.Name, IsDirectory = false, Icon = "file text outline icon" }); } foreach (var child in directory.GetDirectories()) { resource.AddChild(new ThemeResource { Path = child.FullName, Text = child.Name, IsDirectory = true, Icon = "folder open outline icon" }); } return(resource); }
public void AddChild(ThemeResource resource) { if (resource.IsDirectory) { resource = Get(resource.Path); } this.Children.Add(resource); }
public static ThemeResource NormalizePath(string root, ThemeResource resource) { resource.Path = resource.Path.Replace(root, "").Replace(@"\", @"/"); foreach (var child in resource.Children) { child.Path = child.Path.Replace(root, "").Replace(@"\", @"/"); if (child.IsDirectory) { NormalizePath(root, child); } } return resource; }
public static ThemeResource NormalizePath(string root, ThemeResource resource) { resource.Path = resource.Path.Replace(root, "").Replace(@"\", @"/"); foreach (var child in resource.Children) { child.Path = child.Path.Replace(root, "").Replace(@"\", @"/"); if (child.IsDirectory) { NormalizePath(root, child); } } return(resource); }