public WorkspaceItem(MLTProject pProject, VideoInfo pNew, VideoInfo pFinal) { ID = Guid.NewGuid(); Project = pProject; New = pNew; Final = pFinal; if (Project != null) { Project.ProjectChanged += (sender, e) => { Log.Info("WorkspaceItem was change - notify workspace"); switch (Project.Status) { case ProjectStatus.Error: case ProjectStatus.Finished: case ProjectStatus.SourceInvalid: case ProjectStatus.SourceMissing: case ProjectStatus.TargetExists: case ProjectStatus.TargetInvalid: if (Project.TargetExists) { Final = Project.VideoInfoProvider.Get(Project.TargetPath); } break; } Updated?.Invoke(this, this); }; } }
/// <summary> /// Links the new, final and projects together /// </summary> /// <param name="pNew"></param> /// <param name="pFinal"></param> /// <param name="pProjects"></param> /// <returns></returns> private List <WorkspaceItem> GetMatches(IEnumerable <string> pNew, IEnumerable <string> pFinal, IEnumerable <string> pProjects) { var matches = new List <WorkspaceItem>(); var lstNew = new List <VideoInfo>(); var lstFinal = new List <VideoInfo>(); var lstProjects = new List <MLTProject>(); pNew.ToList().ForEach(n => { var i = VideoInfoProvider.Get(n); if (i != null) { lstNew.Add(i); } }); pFinal.ToList().ForEach(f => { var i = VideoInfoProvider.Get(f); if (f != null) { lstFinal.Add(i); } }); pProjects.ToList().ForEach(p => { var mp = new MLTProject(p, VideoInfoProvider); if (mp != null) { lstProjects.Add(mp); } }); //The project links the new and final files together //Without it a link to the final file cannot be made // //Note: It can, but then the name needs to be calculated here based on the video info // If needed this can be added, but if it is not a problem, leave as is new List <MLTProject>(lstProjects).ForEach(p => { _ = lstProjects.Remove(p); var final = lstFinal.Where(f => f.Path.Equals(p.TargetPath)).FirstOrDefault(); if (final != null) { _ = lstFinal.Remove(final); } var newfile = lstNew.Where(n => n.Path.Equals(p.SourcePath)).FirstOrDefault(); if (newfile != null) { _ = lstNew.Remove(newfile); } matches.Add(new WorkspaceItem(p, newfile, final)); }); lstNew.ForEach(n => matches.Add(new WorkspaceItem(null, n, null))); lstFinal.ForEach(f => matches.Add(new WorkspaceItem(null, null, f))); return(matches); }
public bool UpdateProject(MLTProject pProject) { if (pProject == null) { if (Project != null) { Project = pProject; Updated?.Invoke(this, this); return(true); } } else if (!pProject.Equals(Project)) { Project = pProject; Updated?.Invoke(this, this); return(true); } return(false); }