예제 #1
0
 public static void AddCustomFields(Fw7CustomField mCustomfields, List <PaField> list)
 {
     if (mCustomfields != null && mCustomfields.CustomFields.Count > 0)
     {
         foreach (var mFieldValue in mCustomfields.CustomFields.Select(s => s.Name))
         {
             var fd = new PaField(mFieldValue, FieldType.GeneralText);
             if (
                 mFieldValue.Any(
                     fieldName =>
                     mCustomfields.FwWritingSystemType(mFieldValue) ==
                     FwDBUtils.FwWritingSystemType.Vernacular))
             {
                 fd.FwWsType = FwDBUtils.FwWritingSystemType.Vernacular;
             }
             if (list.All(f => f.Name != mFieldValue))
             {
                 list.Add(fd);
             }
             if (!Properties.Settings.Default.DefaultVisibleFields.Contains(fd.Name))
             {
                 Properties.Settings.Default.DefaultVisibleFields.Add(fd.Name);
             }
         }
     }
     if (list.All(f => f.Name != kPhoneticSourceFieldName))
     {
         list.Add(new PaField(kPhoneticSourceFieldName, default(FieldType)));
     }
     if (!Properties.Settings.Default.DefaultVisibleFields.Contains(kPhoneticSourceFieldName))
     {
         Properties.Settings.Default.DefaultVisibleFields.Add(kPhoneticSourceFieldName);
     }
 }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        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;
        }
예제 #3
0
        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"));
        }