/// ------------------------------------------------------------------------------------ public Fw7DataSourcePropertiesDlg(PaDataSource ds, IEnumerable <PaField> projectFields) : this() { if (App.DesignMode) { return; } m_datasource = ds; // Save the phonetic and audio file mappings because we need to remove them from the // mappings list so the user won't see them. They're mapped for free and the user // can't control that. These will get added back in when the dialog is closed. m_phoneticMapping = ds.FieldMappings.Single(m => m.Field.Type == FieldType.Phonetic && m.NameInDataSource == "Phonetic"); m_vernacularMapping = ds.FieldMappings.FirstOrDefault( m => m.Field.Name == ds.FwDataSourceInfo.PhoneticSourceField && m.NameInDataSource != "Phonetic"); m_audioFileMapping = ds.FieldMappings.Single(m => m.Field.Type == FieldType.AudioFilePath); ds.FieldMappings.Remove(m_phoneticMapping); ds.FieldMappings.Remove(m_audioFileMapping); var potentialFieldNames = Properties.Settings.Default.DefaultFw7Fields.Cast <string>(); var customFields = new Fw7CustomField(ds); var cuslist = potentialFieldNames.ToList(); cuslist.AddRange(customFields.FieldNames()); potentialFieldNames = cuslist; //(IEnumerable<string>) m_potentialFields = projectFields.Where(f => potentialFieldNames.Contains(f.Name)); m_potentialVernacularFields = m_potentialFields.Where(f => f.FwWsType == FwDBUtils.FwWritingSystemType.Vernacular).ToList(); foreach (var field in customFields.FieldNames().Where(fieldName => customFields.FwWritingSystemType(fieldName) == FwDBUtils.FwWritingSystemType.Vernacular).Select(fieldName => new PaField(fieldName) { FwWsType = FwDBUtils.FwWritingSystemType.Vernacular })) { if (m_potentialVernacularFields.FirstOrDefault(f => f.Name == field.Name) == null) { m_potentialVernacularFields.Add(field); } } lblProjectValue.Text = ds.FwDataSourceInfo.ToString(); lblProject.Font = FontHelper.UIFont; lblProjectValue.Font = FontHelper.MakeFont(FontHelper.UIFont, FontStyle.Bold); grpFields.Font = FontHelper.UIFont; grpPhoneticField.Font = FontHelper.UIFont; rbVernForm.Font = FontHelper.UIFont; rbPronunField.Font = FontHelper.UIFont; cboPhoneticWritingSystem.Font = FontHelper.UIFont; lblPronunciationOptions.Font = FontHelper.UIFont; cboPronunciationOptions.Font = FontHelper.UIFont; InitializeGrid(); InitializePhoneticAndAudioFieldInfo(); m_dirty = false; LocalizeItemDlg <TMXDocument> .StringsLocalized += InitializePronunciationCombo; }
/// ------------------------------------------------------------------------------------ public void Read(RecordCache recCache) { var allLexEntries = FwDBUtils.GetLexEntriesFromFw7Project(m_fwDsInfo).ToArray(); if (allLexEntries == null) { return; } m_worker.ReportProgress(allLexEntries.Length, m_dataSource.DisplayTextWhenReading); var customnames = m_customfield.FieldNames(); foreach (var lxEntry in allLexEntries) { m_worker.ReportProgress(0); var entry = ReadSingleLexEntry(lxEntry); if (entry != null) { var customvalues = m_customfield.CustomValues.FindAll(m => m.Guid == lxEntry.Guid.ToString()); SetCustomFieldsforEntry(customnames, customvalues, entry); if (m_dataSource.FwDataSourceInfo != null && m_dataSource.FwDataSourceInfo.PhoneticSourceField != null) { var vernacularMapping = new PaField(m_dataSource.FwDataSourceInfo.PhoneticSourceField); entry.SetValue(PaField.kPhoneticSourceFieldName.ToString(CultureInfo.InvariantCulture), m_fwDsInfo.PhoneticStorageMethod != FwDBUtils.PhoneticStorageMethod.PronunciationField && m_fwDsInfo.PhoneticStorageMethod != FwDBUtils.PhoneticStorageMethod.AllPronunciationFields ? vernacularMapping.Name : m_fwDsInfo.PhoneticStorageMethod.ToString()); } recCache.Add(entry); } } m_dataSource.UpdateLastModifiedTime(); }
public void LoadFw7CustomFieldData() { _dataSource.FwDataSourceInfo = new FwDataSourceInfo(TestInput("Ikposo-01.fwdata"), null, DataSourceType.FW7); var customField = new Fw7CustomField(_dataSource); Assert.AreEqual(new[] { "Stem Syllable Type", "Surface Tone Temp", "Word-CV Pattern" }, customField.FieldNames()); Assert.AreEqual("en", customField.FieldWs("Word-CV Pattern")); Assert.AreEqual(3, customField.CustomValues.Count); Assert.AreEqual("H H HF", customField.Value("Surface Tone Temp", "5375a8ef-6958-48ca-9c57-02246177e07f")); Assert.AreEqual("VCVCV", customField.Value("Word-CV Pattern", "5375a8ef-6958-48ca-9c57-02246177e07f")); Assert.AreEqual("en", customField.Ws("Stem Syllable Type", "5375a8ef-6958-48ca-9c57-02246177e07f")); Assert.AreEqual(FwDBUtils.FwWritingSystemType.Analysis, customField.FwWritingSystemType("Surface Tone Temp")); }