Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        private IEnumerable <FieldMapping> CreateDefaultFw7Mappings(IEnumerable <PaField> projectFields)
        {
            var prjFields         = projectFields.ToArray();
            var writingSystems    = FwDataSourceInfo.GetWritingSystems().ToArray();
            var defaultFieldNames = Properties.Settings.Default.DefaultMappedFw7Fields.Cast <string>()
                                    .Where(n => n != PaField.kAudioFileFieldName).ToList();

            // Add a mapping for the phonetic field.
            //yield return new FieldMapping(prjFields.First(f => f.Type == FieldType.Phonetic), true)
            //	{ FwWsId = FwDBUtils.GetDefaultPhoneticWritingSystem(writingSystems).Id };

            // Add a mapping for the audio file field.
            var    audioWs   = FwDBUtils.GetDefaultAudioWritingSystem(writingSystems);
            string audioWsId = audioWs != null ? audioWs.Id : null;

            yield return(new FieldMapping(prjFields.Single(f => f.Type == FieldType.AudioFilePath), false)
            {
                FwWsId = audioWsId
            });

            // Add mappings for all the other fields.
            foreach (var mapping in prjFields.Where(f => defaultFieldNames.Contains(f.Name))
                     .Select(field => new FieldMapping(field, Properties.Settings.Default.ParsedFw7Fields.Cast <string>())))
            {
                FieldMapping.CheckMappingsFw7WritingSystem(mapping, writingSystems);
                yield return(mapping);
            }
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        private void InitializePhoneticAndAudioFieldInfo()
        {
            var vernOptions = m_potentialVernacularFields.Select(f => f.Name).ToArray();

            cboVernacularOptions.Items.AddRange(vernOptions);
            cboVernacularOptions.SelectedItem = null;
            if (m_vernacularMapping != null)
            {
                cboVernacularOptions.SelectedItem = vernOptions.FirstOrDefault(v => v == m_vernacularMapping.NameInDataSource);
                m_selectedvernacularItem          = m_vernacularMapping.Field;
            }
            if (cboVernacularOptions.SelectedItem == null)
            {
                cboVernacularOptions.SelectedItem = vernOptions.Contains("LexemeForm") ? "LexemeForm" : cboVernacularOptions.Items[0];
                m_selectedvernacularItem          = m_potentialVernacularFields.FirstOrDefault(v => v.Name == "LexemeForm");
            }
            cboPhoneticWritingSystem.Items.AddRange(m_datasource.FwDataSourceInfo.GetWritingSystems()
                                                    .Where(ws => ws.Type == FwDBUtils.FwWritingSystemType.Vernacular)
                                                    .Select(ws => ws.Name).ToArray());

            // Set the phonetic writing system combo's initial value.
            var writingSystems = m_datasource.FwDataSourceInfo.GetWritingSystems().ToArray();
            var fwws           = writingSystems.SingleOrDefault(ws => ws.Id == m_phoneticMapping.FwWsId);

            cboPhoneticWritingSystem.SelectedItem = (fwws != null ? fwws.Name : cboPhoneticWritingSystem.Items[0]);

            InitializePronunciationCombo();

            if (m_datasource.FwDataSourceInfo.PhoneticStorageMethod == FwDBUtils.PhoneticStorageMethod.PronunciationField)
            {
                cboPronunciationOptions.SelectedIndex = 0;
            }
            else if (m_datasource.FwDataSourceInfo.PhoneticStorageMethod == FwDBUtils.PhoneticStorageMethod.AllPronunciationFields)
            {
                cboPronunciationOptions.SelectedIndex = 1;
            }

            rbVernForm.Checked =
                (m_datasource.FwDataSourceInfo.PhoneticStorageMethod == FwDBUtils.PhoneticStorageMethod.LexemeForm);

            rbPronunField.Checked =
                (m_datasource.FwDataSourceInfo.PhoneticStorageMethod != FwDBUtils.PhoneticStorageMethod.LexemeForm);

            // update audio WS in case it changed or has now been defined
            var audioWs = FwDBUtils.GetDefaultAudioWritingSystem(writingSystems);

            m_audioFileMapping.FwWsId = audioWs != null ? audioWs.Id : null;
        }