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); } } } } }
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; }); }
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; } } }
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); } }