/// <summary> /// Load all the assets from the Mediabin of the project. /// </summary> /// <param name="project">The current project.</param> private void LoadMediaBin(Project project) { if (project != null) { if (project.MediaBin.ProviderUri != null) { if (this.currentFolderAsset != null) { this.currentFolderAsset.AddAssets(project.MediaBin.Assets); } else { this.currentAssets = project.MediaBin.Assets; } this.FilterAssets(); this.UpArrowCommand.RaiseCanExecuteChanged(); this.AddFolderCommand.RaiseCanExecuteChanged(); } else { this.projectService.GetCurrentProject().MediaBin.AddAssets(new ObservableCollection <Asset>()); this.currentAssets = this.projectService.GetCurrentProject().MediaBin.Assets; this.FilterAssets(); } this.View.HideProgressBar(); } }
/// <summary> /// Callback handler for the LoadProject method. /// </summary> /// <param name="project">The project.</param> private void LoadProjectCompleted(Project project) { if (project == null) { string projectId = null; if (!HtmlPage.Document.QueryString.TryGetValue("projectId", out projectId)) { projectId = Guid.NewGuid().ToString(); } project = new Project { Name = projectId, Creator = this.configurationService.GetUserName(), Created = DateTime.Now, SmpteFrameRate = SmpteFrameRate.Smpte2997NonDrop, AutoSaveInterval = 180, RippleMode = false }; Sequence sequence = this.CreateTimeline(); project.AddTimeline(sequence); project.StartTimeCode = TimeCode.FromAbsoluteTime(0, project.SmpteFrameRate); } this.currentProject = project; }
/// <summary> /// Saves the project asynchronously. /// </summary> /// <param name="project">The project.</param> public void SaveProjectAsync(Project project) { if (!this.isSaving) { this.isSaving = true; DataServiceClient client = this.CreateDataServiceClient(); RCE.Services.Contracts.Project dataProject = DataServiceTranslator.ConvertToDataServiceProject(project); client.SaveProjectCompleted += (sender, args) => { this.isSaving = false; if (args.Error != null) { client.Abort(); this.logger.Log(this.GetType().Name, args.Error); if (args.Error.GetType() == typeof(Exception)) { throw args.Error; } return; } this.OnSaveProjectCompleted(new DataEventArgs <bool>(args.Result)); }; client.SaveProjectAsync(dataProject); } }
public void ShouldSetCurrentProjectWhenInvokingLoadProjectCompleted() { var project = new Project(); this.configurationService.GetParameterValueReturnFunction = parameter => parameter == "ProjectId" ? "http://test/" : null; var projectService = this.CreateProjectService(); Assert.AreNotEqual(project, projectService.GetCurrentProject()); this.dataServiceFacade.InvokeLoadProjectCompleted(project); Assert.AreEqual(project, projectService.GetCurrentProject()); }
/// <summary> /// Loads the project asynchronously. /// </summary> /// <param name="projectUri">The project URI.</param> public void LoadProjectAsync(Uri projectUri) { this.OnLoadProjectCompleted(new DataEventArgs <Project>(null, null)); if (projectUri == null) { return; } DataServiceClient client = this.CreateDataServiceClient(); client.LoadProjectCompleted += (sender, args) => { if (args.Error != null) { client.Abort(); this.logger.Log(this.GetType().Name, args.Error); if (args.Error.GetType() == typeof(Exception)) { throw args.Error; } return; } try { Project project = DataServiceTranslator.ConvertToProject(args.Result); this.OnLoadProjectCompleted(new DataEventArgs <Project>(project)); } catch (Exception e) { client.Abort(); this.logger.Log(this.GetType().Name, e); throw; } }; client.LoadProjectAsync(projectUri); }
/// <summary> /// Saves the project asynchronously. /// </summary> /// <param name="project">The project.</param> public void SaveProjectAsync(Project project) { if (!this.isSaving) { this.isSaving = true; DataServiceClient client = this.CreateDataServiceClient(); RCE.Services.Contracts.Project dataProject = DataServiceTranslator.ConvertToDataServiceProject(project); string projectId = null; if (HtmlPage.Document.QueryString.TryGetValue("projectId", out projectId)) { dataProject.HighlightId = Guid.Parse(projectId); } client.SaveProjectCompleted += (sender, args) => { this.isSaving = false; if (args.Error != null) { client.Abort(); this.logger.Log(this.GetType().Name, args.Error); if (args.Error.GetType() == typeof(Exception)) { throw args.Error; } return; } this.OnSaveProjectCompleted(new DataEventArgs <bool>(args.Result)); }; client.SaveProjectAsync(dataProject); } }
/// <summary> /// Callback handler for the LoadProject method. /// </summary> /// <param name="project">The project.</param> private void LoadProjectCompleted(Project project) { if (project == null) { project = new Project { Name = Guid.NewGuid().ToString(), Creator = this.configurationService.GetUserName(), Created = DateTime.Now, SmpteFrameRate = SmpteFrameRate.Smpte2997NonDrop, AutoSaveInterval = 5, RippleMode = false }; project.Timeline.Add(new Track { TrackType = TrackType.Visual }); int?maxNumberOfAudioTracks = this.configurationService.GetParameterValueAsInt("MaxNumberOfAudioTracks").GetValueOrDefault(1); for (int i = 1; i <= maxNumberOfAudioTracks.Value; i++) { project.Timeline.Add(new Track { Number = i, TrackType = TrackType.Audio }); } project.Timeline.Add(new Track { TrackType = TrackType.Title }); project.StartTimeCode = TimeCode.FromAbsoluteTime(0, project.SmpteFrameRate); } this.currentProject = project; }