private static void Update(WorkspaceContainer pContainer, VideoInfoProvider pVideoInfoProvider, WorkspaceType pType, FSEventInfo pEvent) { var objWSItem = WorkspaceItemMatcher.FindMatch(pContainer.GetAll(), pType, pEvent.Args.FullPath); if (objWSItem != null) { switch (pType) { case WorkspaceType.Final: var path = pEvent.Args.FullPath; if (pEvent.Args.ChangeType != WatcherChangeTypes.Deleted) { if (File.GetAttributes(path).HasFlag(FileAttributes.Directory)) { if (objWSItem.Project != null) { if (File.Exists(objWSItem.Project.TargetPath)) { path = objWSItem.Project.TargetPath; } } } } _ = objWSItem.UpdateFinal( File.Exists(path) ? pVideoInfoProvider.Get(path) : null ); break; case WorkspaceType.New: _ = objWSItem.UpdateNew(pVideoInfoProvider.Get(pEvent.Args.FullPath)); break; case WorkspaceType.Project: _ = objWSItem.UpdateProject(new MLT.MLTProject(pEvent.Args.FullPath, pVideoInfoProvider)); break; } } else { switch (pType) { case WorkspaceType.Final: pContainer.Add(new WorkspaceItem(null, null, pVideoInfoProvider.Get(pEvent.Args.FullPath))); break; case WorkspaceType.New: pContainer.Add(new WorkspaceItem(null, pVideoInfoProvider.Get(pEvent.Args.FullPath), null)); break; case WorkspaceType.Project: pContainer.Add(new WorkspaceItem(new MLT.MLTProject(pEvent.Args.FullPath, pVideoInfoProvider), null, null)); break; } } }
public void Reload() { UpdateCollector.Stop(); var items = WorkspaceScanner.Scan(); WorkspaceContainer.Clear(); items.ForEach(i => { WorkspaceContainer.Add(i); }); Reloaded?.Invoke(this, new EventArgs()); UpdateCollector.Start(); }