Beispiel #1
0
 static void Remove()
 {
     if (PromptFileAndTags(out var fn, out var tags))
     {
         var kf = new Rox.Core.File {
             Path = fn
         };
         if (_repo.All.TryGetValue(kf, out var f))
         {
             if (tags.Count > 0)
             {
                 _repo.UnlinkItemTags(f, tags.Select(t => new Tag(t)), false);
                 if (f.Tags.Count == 0)
                 {
                     _repo.RemoveItem(f);
                 }
             }
             else
             {
                 Console.Write("No tags specified, delete the file?(Yes/no)>");
                 var rl = Console.ReadLine();
                 if (rl == "Yes")
                 {
                     _repo.RemoveItem(f);
                 }
             }
         }
     }
 }
Beispiel #2
0
        private void OnRenamed(object sender, RenamedEventArgs e)
        {
            var key = new Rox.Core.File {
                Path = e.OldFullPath
            };

            _repo.ModifyItem(key, (actual) =>
            {
                ((Rox.Core.File)actual).Path = e.FullPath;
            });
        }
Beispiel #3
0
 private void OnChanged(object sender, FileSystemEventArgs e)
 {
     switch (e.ChangeType)
     {
     case WatcherChangeTypes.Deleted:
     {
         var key = new Rox.Core.File {
             Path = e.FullPath
         };
         _repo.RemoveItem(key);
         break;
     }
     }
 }
Beispiel #4
0
 static void Add()
 {
     if (PromptFileAndTags(out var fn, out var tags))
     {
         var kf = new Rox.Core.File {
             Path = fn
         };
         if (_repo.All.TryGetValue(kf, out var f))
         {
             kf = (Rox.Core.File)f;
         }
         kf.Tags.UnionWith(tags.Select(t => new Tag(t)));
         _repo.AddItem(kf);
     }
 }