Made the LibraryProvider implement iDisposable and we try to dispose them when appropriate.

Made dispose of a collection warn if there are child items or collections.
Made the bread cumbs a clickable navigation rather than just names.
This commit is contained in:
Lars Brubaker 2015-07-02 18:34:10 -07:00
parent 8778a2dd33
commit 60ad94be68
9 changed files with 92 additions and 27 deletions

View file

@ -67,10 +67,10 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
directoryWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
directoryWatcher.Changed += new FileSystemEventHandler(DiretoryContentsChanged);
directoryWatcher.Created += new FileSystemEventHandler(DiretoryContentsChanged);
directoryWatcher.Deleted += new FileSystemEventHandler(DiretoryContentsChanged);
directoryWatcher.Renamed += new RenamedEventHandler(DiretoryContentsChanged);
directoryWatcher.Changed += DiretoryContentsChanged;
directoryWatcher.Created += DiretoryContentsChanged;
directoryWatcher.Deleted += DiretoryContentsChanged;
directoryWatcher.Renamed += DiretoryContentsChanged;
// Begin watching.
directoryWatcher.EnableRaisingEvents = true;
@ -78,6 +78,16 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
GetFilesAndCollectionsInCurrentDirectory();
}
public override void Dispose()
{
directoryWatcher.EnableRaisingEvents = false;
directoryWatcher.Changed -= DiretoryContentsChanged;
directoryWatcher.Created -= DiretoryContentsChanged;
directoryWatcher.Deleted -= DiretoryContentsChanged;
directoryWatcher.Renamed -= DiretoryContentsChanged;
}
public override int CollectionCount
{
get
@ -175,7 +185,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
if (Directory.Exists(directoryPath))
{
Stopwatch time = Stopwatch.StartNew();
Directory.Delete(directoryPath);
Directory.Delete(directoryPath, true);
// Wait for up to some amount of time for the directory to be gone.
while (Directory.Exists(directoryPath)
&& time.ElapsedMilliseconds < 100)