/// ---------------------------------------------------------------------------------------- public StatusAndStagesEditor(ComponentFile file, string imageKey, IEnumerable <ComponentRole> componentRoles) : base(file, null, imageKey) { InitializeComponent(); Name = "StatusAndStages"; _componentRoles = componentRoles.ToArray(); AddStatusFields(); AddStageFields(); _tableLayoutOuter.ColumnStyles[0].SizeType = SizeType.AutoSize; _buttonReadAboutStatus.Click += (s, e) => Program.ShowHelpTopic("/Using_Tools/Sessions_tab/Status_Stages_tab/Select_session_status.htm"); _buttonReadAboutStages.Click += (s, e) => Program.ShowHelpTopic("/Using_Tools/Sessions_tab/Status_Stages_tab/Select_session_stages.htm"); }
public static Task UpdateFileHashesAsync(this Photo targetPhoto, Photo sourcePhoto, ISettings settings) { if (targetPhoto != null) { foreach (ComponentFile sourceFile in sourcePhoto.Files.Where(predicate: s => string.IsNullOrWhiteSpace(s.Hash))) { ComponentFile targetFile = targetPhoto.Files.FirstOrDefault(predicate: s => s.Extension == sourceFile.Extension && !string.IsNullOrWhiteSpace(s.Hash)); if (targetFile != null) { sourceFile.Hash = targetFile.Hash; } } } return(Task.WhenAll(sourcePhoto.Files.Where(predicate: s => string.IsNullOrWhiteSpace(s.Hash)) .Select(selector: x => sourcePhoto.SetFileHashAsync(x, settings)))); }
/// ------------------------------------------------------------------------------------ public override sealed void SetComponentFile(ComponentFile file) { Deactivated(); this.SetWindowRedraw(false); base.SetComponentFile(file); var annotationFile = (AnnotationComponentFile)file; _splitter.Panel1Collapsed = annotationFile.GetIsAnnotatingAudioFile(); var exception = annotationFile.TryLoadAndReturnException(); if (exception != null) { var msg = LocalizationManager.GetString("SessionsView.Transcription.TextAnnotationEditor.LoadingAnnotationFileErrorMsg", "There was an error loading the annotation file '{0}'."); ErrorReport.NotifyUserOfProblem(exception, msg, file.PathToAnnotatedFile); } _grid.Load(annotationFile); _grid.SetColumnFonts(_project.TranscriptionFont, _project.FreeTranslationFont); // check if there are oral translation or careful speach audio files var annotationsDirName = annotationFile.AssociatedComponentFile.PathToAnnotatedFile + Settings.Default.OralAnnotationsFolderSuffix; if (Directory.Exists(annotationsDirName)) { _carefulSpeachAudioExportMenuItem.Enabled = (Directory.GetFiles(annotationsDirName, "*" + Settings.Default.OralAnnotationCarefulSegmentFileSuffix).Length > 0); _oralTranslationAudioExportMenuItem.Enabled = (Directory.GetFiles(annotationsDirName, "*" + Settings.Default.OralAnnotationTranslationSegmentFileSuffix).Length > 0); } else { _carefulSpeachAudioExportMenuItem.Enabled = false; _oralTranslationAudioExportMenuItem.Enabled = false; } _exportMenu.Enabled = (_grid.RowCount > 0); SetupWatchingForFileChanges(); this.SetWindowRedraw(true); _videoPanel.ShowVideoThumbnailNow(); }
static void Test01() { var filename = "ddc_sdk.dill"; filename = "test_scripts/hello.dill"; var bytes = System.IO.File.ReadAllBytes(filename); Console.WriteLine(bytes.Length); // foreach (var b in bytes.Take(16)) Console.WriteLine(b.ToString("X2")); var componentFile = ComponentFile.Load(filename); Console.WriteLine(new DartStringBuilder().Serialize(componentFile).ToString()); Console.WriteLine(); int x = 3; }
/// ------------------------------------------------------------------------------------ private void LoadAnnotationFile(ComponentFile file) { try { _mediaPlayerViewModel.LoadFile(file.PathToAnnotatedFile); } catch (Exception e) { { if (InvokeRequired) { Invoke((Action)(() => ErrorReport.NotifyUserOfProblem(e.Message))); } else { ErrorReport.NotifyUserOfProblem(e.Message); } }; } }
/// ------------------------------------------------------------------------------------ private static ComponentFile SetupData(string annotatedFilePath, FileType fileType, string first, string last, string birth, string death) { var file = ComponentFile.CreateMinimalComponentFileForTests(annotatedFilePath, fileType); File.CreateText(annotatedFilePath).Close(); file.MetaDataFieldValues.Clear(); file.MetaDataFieldValues.Add(new FieldInstance("firstName", first)); file.MetaDataFieldValues.Add(new FieldInstance("lastName", last)); var fav = new FieldInstance("born", birth); file.MetaDataFieldValues.Add(fav); fav = new FieldInstance("died", death); file.MetaDataFieldValues.Insert(0, fav); file.Save(); return(file); }
/// ------------------------------------------------------------------------------------ public void SetComponentFile(ComponentFile file) { _file = file; _file.Load(); RowData = new List <FieldInstance>(); LoadFields(); file.PostGenerateOralAnnotationFileAction += generated => { if (generated) { RowData = new List <FieldInstance>(); LoadFields(); } }; if (ComponentFileChanged != null) { ComponentFileChanged(); } }
public void SerializeAndDeserializeComponentFile() { var component = TestModels.TestComponent; var jsonOutput = component.Write(); var reparsedComponent = ComponentFile.Read(jsonOutput); Assert.AreEqual(component.Name, reparsedComponent.Name); Assert.AreEqual(component.NumberOfPlies, reparsedComponent.NumberOfPlies); Assert.AreEqual(component.DistanceUnit, reparsedComponent.DistanceUnit); Assert.AreEqual(component.AngleUnit, reparsedComponent.AngleUnit); Assert.AreEqual(component.ComponentUsage, reparsedComponent.ComponentUsage); var firstMember = component.Members.First(); Assert.AreEqual("B1", firstMember.Name); Assert.AreEqual(MemberType.BottomChord, firstMember.MemberType); Assert.AreEqual("#2 SYP 2x4", firstMember.MaterialDescription); Assert.AreEqual(MemberMaterialType.Lumber, firstMember.MaterialType); Assert.AreEqual(120, firstMember.StockLength); }
/// ------------------------------------------------------------------------------------ public ComponentFileRenamingDialog(ComponentFile componentFile, IEnumerable <ComponentRole> componentRoles) : this() { Logger.WriteEvent("ComponentFileRenamingDialog constructor. componentFile = {0}", componentFile); _componentFile = componentFile; _componentRoles = componentRoles.ToArray(); _labelPrefix.Text = _componentFile.ParentElement.Id + ComponentRole.kFileSuffixSeparator; _labelExtension.Text = Path.GetExtension(_componentFile.PathToAnnotatedFile); HandleTextBoxTextChanged(null, null); SetFonts(); IntializeLink(_linkSource, ComponentRole.kSourceComponentRoleId); IntializeLink(_linkConsent, ComponentRole.kConsentComponentRoleId); IntializeLink(_linkCareful, ComponentRole.kCarefulSpeechComponentRoleId); IntializeLink(_linkOralTranslation, ComponentRole.kOralTranslationComponentRoleId); IntializeLink(_linkTranscription, ComponentRole.kTranscriptionComponentRoleId); IntializeLink(_linkWrittenTranslation, ComponentRole.kFreeTranslationComponentRoleId); _textBox.ReadOnly = !_componentFile.CanBeCustomRenamed; }
/// ------------------------------------------------------------------------------------ public ContributorsEditor(ComponentFile file, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, PersonInformant personInformant) : base(file, null, imageKey) { InitializeComponent(); Name = "Contributors"; _model = new ContributorsListControlViewModel(autoCompleteProvider, SaveContributors); var dataGridView = new DataGridView(); dataGridView.Columns[dataGridView.Columns.Add("date", "date")].Visible = false; _model.ContributorsGridSettings = GridSettings.Create(dataGridView); // ReSharper disable once UseObjectOrCollectionInitializer _contributorsControl = new ContributorsListControl(_model); _contributorsControl.Dock = DockStyle.Fill; _contributorsControl.ValidatingContributor += HandleValidatingContributor; InitializeGrid(); // imageKey == "Contributor" when ContributorsEditor is lazy loaded for the session file type if (imageKey != null) { AddSessionControls(); } else { Controls.Add(_contributorsControl); } file.AfterSave += file_AfterSave; SetComponentFile(file); if (personInformant != null) { personInformant.PersonUiIdChanged += HandlePersonsUiIdChanged; } }
/// ------------------------------------------------------------------------------------ public SessionBasicEditor(ComponentFile file, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer, PersonInformant personInformant) : base(file, null, imageKey) { Logger.WriteEvent("PersonBasicEditor constructor. file = {0}", file); InitializeComponent(); Name = "SessionEditor"; _personInformant = personInformant; _autoCompleteProvider = autoCompleteProvider; _autoCompleteProvider.NewDataAvailable += LoadGenreList; _binder.TranslateBoundValueBeingRetrieved += HandleBinderTranslateBoundValueBeingRetrieved; _binder.TranslateBoundValueBeingSaved += HandleBinderTranslateBoundValueBeingSaved; SetBindingHelper(_binder); _autoCompleteHelper.SetAutoCompleteProvider(autoCompleteProvider); _id.Enter += delegate { EnsureFirstRowLabelIsVisible(_labelId); }; _date.Enter += delegate { EnsureFirstRowLabelIsVisible(_labelDate); }; _genre.Enter += delegate { _genreFieldEntered = true; }; _genre.Leave += delegate { _genreFieldEntered = false; }; _genre.KeyPress += HandleGenreKeyPress; InitializeGrid(autoCompleteProvider, fieldGatherer); file.AfterSave += file_AfterSave; if (_personInformant != null) { _personInformant.PersonUiIdChanged += HandlePersonsUiIdChanged; } }
/// ------------------------------------------------------------------------------------ public ImageViewer(ComponentFile file) : base(file, null, "Image") { Logger.WriteEvent("ImageViewer constructor. file = {0}", file); InitializeComponent(); Name = "ImageViewer"; _labelZoom.Font = Program.DialogFont; _zoomTrackBar.BackColor = BackColor; _panelImage = new EnhancedPanel(); _panelImage.Dock = DockStyle.Fill; _panelImage.AutoScroll = true; _panelImage.Cursor = Cursors.Hand; Controls.Add(_panelImage); _panelImage.BringToFront(); _panelImage.Paint += HandleImagePanelPaint; _panelImage.Scroll += HandleImagePanelScroll; _panelImage.MouseClick += HandleImagePanelMouseClick; _panelImage.MouseDoubleClick += HandleImagePanelMouseClick; _panelImage.HandleDestroyed += _panelImage_HandleDestroyed; SetComponentFile(file); }
/// ------------------------------------------------------------------------------------ public override void SetComponentFile(ComponentFile file) { base.SetComponentFile(file); Name = "AudioVideoPlayer:" + Path.GetFileName(file.PathToAnnotatedFile); file.PreDeleteAction = (() => _mediaPlayerViewModel.Stop(true)); file.PreFileCommandAction = (() => _mediaPlayerViewModel.Stop(true)); file.PostFileCommandAction = (() => LoadAnnotationFile(file)); file.PreRenameAction = (() => _mediaPlayerViewModel.Stop(true)); file.PostRenameAction = (() => LoadAnnotationFile(file)); _playerPausedWhenTabChanged = false; LoadAnnotationFile(file); if (Settings.Default.MediaPlayerVolume >= 0) { _mediaPlayerViewModel.SetVolume(Settings.Default.MediaPlayerVolume); } _mediaPlayerViewModel.VolumeChanged = delegate { Invoke((Action)HandleMediaPlayerVolumeChanged); }; UseWaitCursor = false; Cursor = Cursors.Default; }
/// ------------------------------------------------------------------------------------ public void SetComponentFile(ComponentFile file) { if (DesignMode) { return; } if (ComponentFile != null) { ComponentFile.MetadataValueChanged -= HandleValueChangedOutsideBinder; } ComponentFile = file; ComponentFile.MetadataValueChanged += HandleValueChangedOutsideBinder; // First, collect only the extended controls that are bound. _boundControls = _extendedControls.Where(x => x.Value).Select(x => x.Key).ToList(); foreach (var ctrl in _boundControls) { ctrl.Font = Program.DialogFont; BindControl(ctrl); } }
/// ------------------------------------------------------------------------------------ public CarefulSpeechAnnotationRecorderDlgViewModel(ComponentFile file) : base(file) { }
/// ------------------------------------------------------------------------------------ protected OralAnnotationRecorderDlgViewModel(ComponentFile file) : base(file) { NewSegmentEndBoundary = GetEndOfLastSegment(); }
/// ------------------------------------------------------------------------------------ public override sealed void SetComponentFile(ComponentFile file) { base.SetComponentFile(file); _model.SetContributionList(file.GetValue(SessionFileType.kContributionsFieldName, null) as ContributionCollection); }
public void Deserialize_QualityControlFile() { var qc = ComponentFile.Read(Resources.GetResourceAsString("Test.qc")); Assert.IsTrue(qc != null); }
private Mock <IMDIArchivingDlgViewModel> AddIMDISessionTestSetup(out Mock <SIL.Archiving.IMDI.Schema.Session> imdiSession, ComponentFile mediaFile = null) { var model = new Mock <IMDIArchivingDlgViewModel>(MockBehavior.Strict, "SayMore", "ddo", "ddo-session", "whatever", false, null, @"C:\my_imdi_folder"); imdiSession = new Mock <SIL.Archiving.IMDI.Schema.Session>(MockBehavior.Strict); imdiSession.Object.Name = "ddo"; model.Setup(m => m.AddSession(_session.Id)).Returns(imdiSession.Object); _session.MediaFiles = mediaFile == null ? new ComponentFile[0] : new[] { mediaFile }; return(model); }
/// ------------------------------------------------------------------------------------ public virtual bool ComponentFileDeletionInitiated(ComponentFile file) { return(true); }
/// ------------------------------------------------------------------------------------ public CustomFieldsValuesGridViewModel(ComponentFile file, IMultiListDataProvider autoCompleteProvider, FieldGatherer fieldGatherer) : base(file, autoCompleteProvider, fieldGatherer, key => key.StartsWith(XmlFileSerializer.kCustomFieldIdPrefix)) { }
/// ------------------------------------------------------------------------------------ public EditorBase(ComponentFile file, string tabText, string imageKey) : this() { _file = file; Initialize(tabText, imageKey); }
/// ------------------------------------------------------------------------------------ public VideoComponentEditor(ComponentFile file, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer) : base(file, null, imageKey, autoCompleteProvider, fieldGatherer) { Name = "Video File Information"; }
/// ------------------------------------------------------------------------------------ public OralTranslationAnnotationRecorderDlgViewModel(ComponentFile file) : base(file) { }
private Mock <IMDIArchivingDlgViewModel> AddIMDISessionTestSetup(out Mock <SIL.Archiving.IMDI.Schema.Session> imdiSession, ComponentFile mediaFile = null) { var model = new Mock <IMDIArchivingDlgViewModel>(MockBehavior.Strict, "SayMore", "ddo", "ddo-session", "whatever", false, null, @"C:\my_imdi_folder"); imdiSession = new Mock <SIL.Archiving.IMDI.Schema.Session>(MockBehavior.Strict); imdiSession.Object.Name = "ddo"; model.Setup(m => m.AddSession(_session.Id)).Returns(imdiSession.Object); _session.MediaFiles = mediaFile == null ? new ComponentFile[0] : new[] { mediaFile }; // We have to use real objects here because ArchivingPackage.FundingProject is not virtual. // We typically need an ArchivingPackage with a FundingProject because Session.AddProject() // uses FundingProject.Name. var ap = new IMDIPackage(false, ""); model.Setup(m => m.ArchivingPackage).Returns(ap); ap.FundingProject = new ArchivingProject(); return(model); }
/// ------------------------------------------------------------------------------------ public ManualSegmenterDlgViewModel(ComponentFile file) : base(file) { }
private static ComponentFile MakeComponent(ProjectElement parentElement, string pathtoannotatedfile) { return(ComponentFile.CreateMinimalComponentFileForTests(parentElement, pathtoannotatedfile)); }
private static string GetFieldValue(ComponentFile file, string valueName) { var stringVal = file.GetStringValue(valueName, null); return(string.IsNullOrEmpty(stringVal) ? null : stringVal); }
/// ------------------------------------------------------------------------------------ public override void SetComponentFile(ComponentFile file) { base.SetComponentFile(file); UpdateDisplay(); }
private static async Task SetFileHashAsync(this Photo sourcePhoto, ComponentFile file, ISettings settings) { string filename = Path.Combine(settings.RootFolder, sourcePhoto.BasePath + file.Extension); file.Hash = await Hasher.HashFileAsync(filename); }