示例#1
0
        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;
        }
示例#2
0
        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);
        }
示例#3
0
        public void AddChild(ThemeResource resource)
        {
            if (resource.IsDirectory)
            {
                resource = Get(resource.Path);
            }

            this.Children.Add(resource);
        }
示例#4
0
        public void AddChild(ThemeResource resource)
        {
            if (resource.IsDirectory)
            {
                resource = Get(resource.Path);
            }

            this.Children.Add(resource);
        }
示例#5
0
        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;
        }
示例#6
0
        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);
        }