/// ------------------------------------------------------------------------------------
        protected override void OnCellValuePushed(DataGridViewCellValueEventArgs e)
        {
            // Check if we need to add a new field to the end of the list.
            if (e.RowIndex >= 0 && GetColumnName(e.ColumnIndex) == "tgtfield")
            {
                FieldMapping mapping;
                var          field = m_potentialFields.Single(f => f.DisplayName == e.Value as string);

                if (e.RowIndex == m_mappings.Count)
                {
                    mapping = new FieldMapping(field, false);
                    m_mappings.Add(mapping);
                }
                else
                {
                    mapping = m_mappings[e.RowIndex];
                    mapping.NameInDataSource = field.Name;
                    mapping.Field            = field;
                }

                FieldMapping.CheckMappingsFw7WritingSystem(mapping, m_writingSystems);
                UpdateCellValue(Columns["fwws"].Index, e.RowIndex);
            }

            base.OnCellValuePushed(e);
        }
Ejemplo n.º 2
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);
            }
        }