/// <summary> /// Creates a ProjectFile with a given relative path, and a base path that will contain the /// relative path. Use this when given a relative path but not an absolute path. /// </summary> /// <param name="relativePath">A non-rooted path.</param> /// <param name="basePath"> /// A rooted path that will serve as the parent folder to the relative path. /// </param> /// <returns>A ProjectFile with a set AbsolutePath and RelativePath.</returns> public static ProjectFile FromRelativePath(string relativePath, string basePath) { var pf = new ProjectFile { RelativePath = relativePath }; pf.MakeAbsoluteWith(basePath); return pf; }
public void ProjectFile_ExternalRelativeFileCreationTest() { //Arrange const string pathToProjectFolder = "D:\\Test\\RelTest2"; const string relativePath1 = "../../Valentin/Videos/Wildlife.wmv"; const string expectedPath1 = "D:\\Valentin\\Videos\\Wildlife.wmv"; ProjectFile pf1; ProjectFile pf1a; //Act pf1 = ProjectFile.FromRelativePath(relativePath1, pathToProjectFolder); pf1a = new ProjectFile { RelativePath = relativePath1 }; pf1a.MakeAbsoluteWith(pathToProjectFolder); //Assert Assert.AreEqual(expectedPath1, pf1.AbsolutePath); Assert.AreEqual(expectedPath1, pf1a); }
public void ProjectFile_ExternalAbsoluteFileCreationTest() { //Arrange const string absolutePath1 = "D:\\Valentin\\Videos\\Wildlife.wmv"; const string basePath = "D:\\Test\\RelTest2"; const string expectedRelativePath1 = "../../Valentin/Videos/Wildlife.wmv"; ProjectFile pf1; ProjectFile pf1a; //Act pf1 = ProjectFile.FromAbsolutePath(absolutePath1, basePath); pf1a = new ProjectFile { AbsolutePath = absolutePath1 }; pf1a.MakeRelativeTo(basePath); //Assert Assert.AreEqual(expectedRelativePath1, pf1.RelativePath); Assert.AreEqual(expectedRelativePath1, pf1a.RelativePath); }
public Description(ProjectFile filepath, double startwavefiletime, double endwavefiletime, double startinvideo, bool extendedDescription) : this() { AudioFile = filepath; Text = Path.GetFileNameWithoutExtension(filepath); IsExtendedDescription = extendedDescription; //I specifically use the instance variables rather than the properties //because the property events can possibly be caught in the view //leading to an uneeded amount of changes to the description graphics _startwavefiletime = startwavefiletime; _endwavefiletime = endwavefiletime; StartInVideo = startinvideo; if (!extendedDescription) EndInVideo = startinvideo + (endwavefiletime - startwavefiletime); else EndInVideo = startinvideo; }
/// <summary> /// Creates a ProjectFile with a given absolute(rooted) path, and a base path. The /// ProjectFile's RelativePath will be set relative to the given base path. Use this when /// given an absolute path but not a relative path. Note that the basePath does not have to /// contain the relative path. /// </summary> /// <param name="absolutePath">A rooted path.</param> /// <param name="basePath">A base path to make the file relative to.</param> /// <returns></returns> public static ProjectFile FromAbsolutePath(string absolutePath, string basePath) { var pf = new ProjectFile { AbsolutePath = absolutePath }; pf.MakeRelativeTo(basePath); return pf; }
public void ProjectFile_InternalAbsoluteFileCreationTest() { //Arrange const string pathToProjectFolder = "D:\\Test\\Wildlife"; const string absolutePath1 = "D:\\Test\\Wildlife\\Wildlife.wmv"; const string absolutePath2 = "D:\\Test\\Wildlife\\projectCache\\waveform.bin"; const string expectedRelativePath1 = "Wildlife.wmv"; const string expectedRelativePath2 = "projectCache/waveform.bin"; ProjectFile pf1; ProjectFile pf1a; ProjectFile pf2; ProjectFile pf2a; //Act pf1 = ProjectFile.FromAbsolutePath(absolutePath1, pathToProjectFolder); pf1a = new ProjectFile { AbsolutePath = absolutePath1 }; pf1a.MakeRelativeTo(pathToProjectFolder); pf2 = ProjectFile.FromAbsolutePath(absolutePath2, pathToProjectFolder); pf2a = new ProjectFile { AbsolutePath = absolutePath2 }; pf2a.MakeRelativeTo(pathToProjectFolder); //Assert Assert.AreEqual(expectedRelativePath1, pf1.RelativePath); Assert.AreEqual(expectedRelativePath1, pf1a.RelativePath); Assert.AreEqual(expectedRelativePath2, pf2.RelativePath); Assert.AreEqual(expectedRelativePath2, pf2a.RelativePath); }
public void ProjectFile_StringTest() { //Arrange const string absolutePath1 = "D:\\Valentin\\Videos\\Wildlife.wmv"; const string relativePath1 = "../../Valentin/Videos/Wildlife.wmv"; const string expectedString = absolutePath1; ProjectFile pf1; //Act pf1 = new ProjectFile { AbsolutePath = absolutePath1, RelativePath = relativePath1 }; //Assert Assert.AreEqual(expectedString, pf1); Assert.AreEqual(expectedString, pf1.AbsolutePath); Assert.AreEqual(expectedString, pf1.ToString()); }
public void RecordDescription(ProjectFile file, bool recordExtended, double videoPositionMilliseconds) { lock (_recordingAccessLock) { Log.Info("Beginning to record audio"); try { MicrophoneStream = GetMicrophone(_deviceNumber); } catch (MmException) { Log.Warn("Microphone not found"); throw; } Log.Info("Recording..."); _waveWriter = new WaveFileWriter(file.AbsolutePath, MicrophoneStream.WaveFormat); _recordExtended = recordExtended; _recordedFile = file; try { _descriptionStartTime = videoPositionMilliseconds; MicrophoneStream.StartRecording(); } catch (MmException) { Log.Error("Previous Microphone was found then unplugged (No Microphone) Exception..."); throw; } IsRecording = true; } }