Exemple #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);
     }
 }
Exemple #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;
        }
Exemple #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"));
        }
Exemple #4
0
        public static List <PaField> LoadFields(string path, string rootElementName, Fw7CustomField mCustomfields)
        {
            Exception e;
            var       list = XmlSerializationHelper.DeserializeFromFile <List <PaField> >(path, rootElementName, out e);

            AddCustomFields(mCustomfields, list);
            if (e == null)
            {
                return(EnsureListContainsCalculatedFields(list).ToList());
            }

            App.NotifyUserOfProblem(e, LocalizationManager.GetString(
                                        "ProjectFields.ReadingFieldsFileErrorMsg",
                                        "There was an error reading field information from the file '{0}'."), path);

            return(null);
        }
Exemple #5
0
        public static List <PaField> GetProjectFields(PaProject project)
        {
            s_displayPropsCache = FieldDisplayPropsCache.LoadProjectFieldDisplayProps(project);
            if (project.DataSources.Count <= 0)
            {
                return(GetDefaultFields());
            }
            Fw7CustomField cusfields = null;

            foreach (var ds in project.DataSources)
            {
                if (cusfields == null)
                {
                    cusfields = new Fw7CustomField(ds);
                }
                else
                {
                    cusfields.CustomFields.AddRange(
                        new Fw7CustomField(ds).CustomFields.Where(p => cusfields.CustomFields.All(s => s.Name != p.Name)));
                    cusfields.CustomValues.AddRange(
                        new Fw7CustomField(ds).CustomValues.Where(p => cusfields.CustomValues.All(s => s.CustomFields != p.CustomFields)));
                }
            }
            var defaultFields = GetDefaultFields(cusfields);
            var path          = GetFileForProject(project.ProjectPathFilePrefix);

            if (!File.Exists(path))
            {
                return(defaultFields);
            }

            // Go through the project's fields making sure that
            // all the default fields are contained therein.
            var fields = LoadFields(path, "Fields", cusfields);

            foreach (var fld in defaultFields.Where(fld => !fields.Any(f => f.Name == fld.Name)))
            {
                fields.Add(fld);
            }

            return(fields);
        }
Exemple #6
0
        public static List <PaField> GetDefaultFields(Fw7CustomField customField)
        {
            var path = FileLocationUtilities.GetFileDistributedWithApplication(App.ConfigFolderName, "DefaultFields.xml");

            return(EnsureListContainsCalculatedFields(LoadFields(path, "DefaultPaFields", customField)).ToList());
        }