private IEnumerable <MediaFileInfo> GetFilteredFileData(ComponentRole role) { // SP-2171: i.MediaFilePath will be empty if the file is zero length (see MediaFileInfo.GetInfo()). This happens often with the generated oral annotation file. return(_backgroundStatisticsGather.GetAllFileData() .Where(i => !string.IsNullOrEmpty(i.MediaFilePath) && !i.MediaFilePath.EndsWith(Settings.Default.OralAnnotationGeneratedFileSuffix) && role.IsMatch(i.MediaFilePath))); }
public void IsPotential_PathDoesNotMatch_False() { ComponentRole role = GetRoleForSourceRecording(); Assert.IsFalse(role.IsPotential("fub.xmp3")); Assert.IsFalse(role.IsPotential("fub.mp3x")); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets a uniquely colored block for the specified role if the specified role is /// in the list of completed roles. Otherwise a white-ish colored block is returned /// indicating the role is imcomplete. /// </summary> /// ------------------------------------------------------------------------------------ public Image GetComponentStageColorBlock(ComponentRole role, IEnumerable <ComponentRole> completedRoles) { var clr = (role.IsContainedIn(completedRoles) ? role.Color : Settings.Default.IncompleteStageColor); return(GetComponentStageColorBlock(clr)); }
/// ------------------------------------------------------------------------------------ public TimeSpan GetRecordingDurations(ComponentRole role) { // do not include the generated oral annotation file in the calculations var total = GetFilteredFileData(role).Aggregate(TimeSpan.Zero, (current, info) => current + info.Duration); // Trim off the milliseconds so it doesn't get too geeky return(new TimeSpan(total.Hours, total.Minutes, total.Seconds)); }
/// ------------------------------------------------------------------------------------ public TimeSpan GetRecordingDurations(ComponentRole role) { var total = _backgroundStatisticsGather.GetAllFileData() .Where(info => role.IsMatch(info.MediaFilePath)) .Aggregate(TimeSpan.Zero, (current, info) => current + info.Duration); // Trim off the milliseconds so it doesn't get too geeky return(new TimeSpan(total.Hours, total.Minutes, total.Seconds)); }
public void IdentifyAsRole_FileRenamed() { var f = CreateComponentFile("abc.txt"); var role = new ComponentRole(typeof(Session), "someRole", "someRole", ComponentRole.MeasurementTypes.None, p => p.EndsWith("txt"), "$ElementId$_someRole", Color.Magenta, Color.Black); f.AssignRole(role); Assert.AreEqual(ParentFolderName + "_someRole.txt", Path.GetFileName(f.PathToAnnotatedFile)); Assert.IsTrue(File.Exists(f.PathToAnnotatedFile)); }
public void GetRecordingDurations_NoMatches_Zero() { //Mock<ComponentRole> role = new Mock<ComponentRole>(); //role.Setup(x => x.IsMatch("zzzz")).Returns(false); var role = new ComponentRole(typeof(Session), "blah", "blah", ComponentRole.MeasurementTypes.Time, FileSystemUtils.GetIsAudioVideo, "CantMatchThis", Color.Magenta, Color.Black); Assert.AreEqual(new TimeSpan(0), CreateModel().GetRecordingDurations(role)); }
public void IsPotential_PathMatches_True() { ComponentRole role = GetRoleForSourceRecording(); Assert.IsTrue(role.IsPotential("fub.wav")); Assert.IsTrue(role.IsPotential("fub.mp3")); Assert.IsTrue(role.IsPotential("fub.ogg")); Assert.IsTrue(role.IsPotential("fub.avi")); Assert.IsTrue(role.IsPotential("fub.mov")); }
/// ------------------------------------------------------------------------------------ private PictureBox GetNewRolePictureBox(ComponentRole role) { var pb = new PictureBox { Image = _stagesImageMaker.GetComponentStageColorBlock(role), SizeMode = _imageTemplate.SizeMode, Anchor = _imageTemplate.Anchor, Margin = _imageTemplate.Margin, }; return(pb); }
/// ------------------------------------------------------------------------------------ public StageCheckBox(ComponentRole role) { Name = "checkBoxStage_" + role.Name; Font = Program.DialogFont; AutoSize = true; Anchor = AnchorStyles.Left; Text = role.Name; Margin = new Padding(10, 4, 0, 2); UseVisualStyleBackColor = true; Role = role; DoubleBuffered = true; }
/// ------------------------------------------------------------------------------------ private long GetTotalComponentRoleFileSizes(ComponentRole role) { long bytes = 0; foreach (var info in _backgroundStatisticsGather.GetAllFileData()) { if (role.IsMatch(info.MediaFilePath)) { bytes += info.LengthInBytes; } } return(bytes); }
/// ------------------------------------------------------------------------------------ private void AddStageCheckBox(int row, int tabIndex, ComponentRole role) { var stageCheckBox = new StageCheckBox(role) { TabIndex = tabIndex }; stageCheckBox.CheckedChanged += HandleStageCheckBoxCheckChanged; stageCheckBox.IsRoleCompleteProvider = r1 => _file.ParentElement.GetCompletedStages(false).Any(r2 => r2.Id == r1.Id); _tableLayoutOuter.Controls.Add(stageCheckBox, 1, row); _stageCheckBoxes.Add(stageCheckBox); }
private StatisticsViewModel CreateModel() { var nullRole = new ComponentRole(typeof(Session), "someRole", "someRole", ComponentRole.MeasurementTypes.None, p => p.EndsWith("txt"), "$ElementId$_someRole", Color.Magenta, Color.Black); var personInformer = new PersonInformant( new ElementRepository <Person>(_folder.Combine("people"), Person.kFolderName, null, null), null); var sessionInformer = new SessionWorkflowInformant( new ElementRepository <Session>(_folder.Combine("sessions"), Session.kFolderName, null, null), new[] { nullRole }); return(new StatisticsViewModel(null, personInformer, sessionInformer, new[] { nullRole }, new AudioVideoDataGatherer(_folder.Path, new[] { new AudioFileType(null, () => null, null) }))); }
private IEnumerable <ComponentFile> GetFiles() { var dir = Path.Combine(Program.CurrentProject.FolderPath, FolderName); if (!Directory.Exists(dir)) { yield break; } var unknownFileType = new FileType[] { new UnknownFileType(null, null), new AudioFileType(null, null, null), new VideoFileType(null, null, null), new ImageFileType(null, null) }; var blankRoles = new ComponentRole[] {}; var blankSerializer = new XmlFileSerializer(null); var files = Directory.GetFiles(dir); foreach (var file in files.Where(f => !f.EndsWith(Settings.Default.MetadataFileExtension))) { yield return(new ComponentFile(null, file, unknownFileType, blankRoles, blankSerializer, null, null, null)); } }
public void GetCanonicalName_HasDirectoryInPath_ChangesName() { ComponentRole role = GetRoleForSourceRecording(); Assert.AreEqual(@"c:\foo\mySession_Source.wav", role.GetCanoncialName("mySession", @"c:\foo\fub.wav")); }
/// ------------------------------------------------------------------------------------ private long GetTotalComponentRoleFileSizes(ComponentRole role) { // do not include the generated oral annotation file in the calculations return(GetFilteredFileData(role).Sum(info => info.LengthInBytes)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets a uniquely colored block for the specified role. /// </summary> /// ------------------------------------------------------------------------------------ public Image GetComponentStageColorBlock(ComponentRole role) { return(GetComponentStageColorBlock(role.Color)); }