Beispiel #1
0
        public void CreateDefaultFolders()
        {
            var f1 = new FolderSpec(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));
            var f2 = new FolderSpec(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu));

            Save(f1);
            Save(f2);
            Flush();
        }
Beispiel #2
0
 public FolderSpecViewModel(FolderSpec folderSpec, FolderSpecRepo folderSpecRepo)
 {
     if (folderSpec == null)
     {
         throw new ArgumentNullException("folderSpec");
     }
     Instance        = folderSpec;
     _folderSpecRepo = folderSpecRepo;
 }
Beispiel #3
0
        public void Delete(FolderSpec folderSpec)
        {
            var existingSpec = _folderDirectory.Folders.SingleOrDefault(x => x.Id == folderSpec.Id);

            if (existingSpec == null)
            {
                return;
            }
            _folderDirectory.Folders.Remove(existingSpec);
        }
Beispiel #4
0
        public void Save(FolderSpec folderSpec)
        {
            var existingEntry = _folderDirectory.Folders.SingleOrDefault(x => x.Id == folderSpec.Id);

            if (existingEntry != null)
            {
                _folderDirectory.Folders.Remove(existingEntry);
            }
            var entriesByName = _folderDirectory.Folders.Where(x => x.FolderName.Equals(folderSpec.FolderName, StringComparison.InvariantCultureIgnoreCase)).ToList();

            foreach (var entry in entriesByName)
            {
                _folderDirectory.Folders.Remove(entry);
            }

            _folderDirectory.Folders.Add(folderSpec);
        }
Beispiel #5
0
        public void AddFolder()
        {
            var s      = new VistaFolderBrowserDialog();
            var result = s.ShowDialog();

            if (result.HasValue == false || result.Value == false || string.IsNullOrEmpty(s.SelectedPath))
            {
                return;
            }

            var newFolderSpec = new FolderSpec(s.SelectedPath);

            _folderSpecRepo.Save(newFolderSpec);
            var newVm = new FolderSpecViewModel(newFolderSpec, _folderSpecRepo);

            Folders.Add(newVm);
            SelectedFolder = newVm;
        }