예제 #1
0
        private void m_btnAddCustom_Click(object sender, EventArgs e)
        {
            // What we'd like to do is the following bit of code, but we can't due to
            // circular dependencies that would be introduced.  We could possibly move
            // the dialog to another assembly/dll, but that would require reworking a
            // fair number of strings that have been converted to resources.
            //using (var dlg = new AddCustomFieldDlg(m_mediator, AddCustomFieldDlg.LocationType.Notebook))
            //    dlg.ShowDialog();
            System.Type typeFound;
            MethodInfo  mi = XmlUtils.GetStaticMethod("xWorks.dll",
                                                      "SIL.FieldWorks.XWorks.AddCustomFieldDlg",
                                                      "ShowNotebookCustomFieldDlg",
                                                      "AnthroFieldMappingDlg.m_btnAddCustom_Click()", out typeFound);

            if (mi != null)
            {
                var parameters = new object[2];
                parameters[0] = m_mediator;
                parameters[1] = m_propertyTable;
                mi.Invoke(typeFound,
                          System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public |
                          System.Reflection.BindingFlags.NonPublic, null, parameters, null);
                // Now, clean up our map of possible field targets and reload the field combo list.
                List <int> delFields = new List <int>();
                foreach (int key in m_mapFlidName.Keys)
                {
                    if (!m_mdc.FieldExists(key))
                    {
                        delFields.Add(key);
                    }
                }
                foreach (int flid in delFields)
                {
                    m_mapFlidName.Remove(flid);
                }
                foreach (int flid in m_mdc.GetFields(RnGenericRecTags.kClassId, false, (int)CellarPropertyTypeFilter.All))
                {
                    if (m_mapFlidName.ContainsKey(flid))
                    {
                        continue;
                    }
                    if (m_mdc.IsCustom(flid))
                    {
                        string name = m_mdc.GetFieldName(flid);
                        m_mapFlidName.Add(flid, name);
                    }
                }
                FillInFieldList();
            }
            else
            {
            }
        }
예제 #2
0
 /// <summary>
 /// Pass it on by default.
 /// </summary>
 public bool FieldExists(string className, string fieldName, bool includeBaseClasses)
 {
     return(m_metaDataCache.FieldExists(className, fieldName, includeBaseClasses));
 }
예제 #3
0
		/// <summary>
		/// This seems a bit clumsy, but the metadata cache now throws an exception if the class
		/// id/field name pair isn't valid for GetFieldId2(). So we check first in cases where
		/// we want a zero if not found.
		/// </summary>
		private int GetFlidIfPossible(int clid, string fieldName, IFwMetaDataCacheManaged mdc)
		{
			if (!mdc.FieldExists(clid, fieldName, true))
				return 0;
			return mdc.GetFieldId2(clid, fieldName, true);
		}
예제 #4
0
 /// <summary>
 /// Check whether the fieldName is in use.
 /// </summary>
 /// <returns></returns>
 public bool IsFieldNameUsed(string className, string fieldName)
 {
     return(m_mdc.FieldExists(className, fieldName, true));
 }