Beispiel #1
0
        public Folder(OtherFilesFolder source)
        {
            Type = Settings.Current.Types.First(t => t.Name == "Folder");
            Contents = new ObservableCollection<Node>();
            Name = source.Name;

            foreach (var node in source.Contents)
                Add(node);
        }
Beispiel #2
0
        protected void Update(AllFiles allFiles, string realPathDir)
        {
            string readDir = Path.Combine(Directory.GetCurrentDirectory(), realPathDir);
            string realPath = null;

            this.Contents.Clear();

            foreach (string file in Directory.GetFiles(readDir))
            {
                realPath = Path.Combine(realPathDir, Path.GetFileName(file));
                if (!allFiles.Any(f =>
                    Path.Equals(f.RealPath, realPath)))
                    this.Add(new OtherFile()
                    {
                        Name = Path.GetFileName(file),
                        RealPath = realPath,
                    });
            }
            foreach (string dir in Directory.GetDirectories(readDir))
            {
                realPath = Path.Combine(realPathDir, Path.GetFileName(dir));
                OtherFilesFolder child = new OtherFilesFolder()
                {
                    Name = Path.GetFileName(dir),
                    RealPath = realPath,
                };
                child.Update(allFiles,  Path.Combine(realPathDir, child.Name));
                this.Add(child);
            }
        }
Beispiel #3
0
        private void UpdateOtherFiles(OtherFilesFolder folder, AllFiles allFiles, string savePathDir)
        {
            string pathOffset = Path.GetDirectoryName(SavePath);
            string realPath = null;

            foreach (string file in Directory.GetFiles(savePathDir))
            {
                realPath = file.Substring(pathOffset.Length + (pathOffset.EndsWith("\\")? 0 : 1));
                if (!allFiles.Any(f =>
                    Path.Equals(f.RealPath, realPath)))
                    folder.Add(new OtherFile()
                    {
                        Name = Path.GetFileName(file),
                        RealPath = realPath
                    });
            }
            foreach (string dir in Directory.GetDirectories(savePathDir))
            {
                OtherFilesFolder child = new OtherFilesFolder()
                {
                    Name = Path.GetFileName(dir),
                };
                UpdateOtherFiles(child, allFiles, dir+"\\");
                folder.Add(child);
            }
        }
Beispiel #4
0
        private void UpdateOtherFiles()
        {
            OtherFilesFolder off = (OtherFilesFolder)BaseFolder.Contents.FirstOrDefault(f => f is OtherFilesFolder);
            AllFiles allFiles = new AllFiles(BaseFolder);

            if(off == null){
                off = new OtherFilesFolder();
                BaseFolder.Add(off);
            }
            else{
                off.Contents.Clear();
            }

            off.Update(allFiles);
        }