Beispiel #1
0
 protected override void HandleMatchingSelectionChanged()
 {
     if (m_selEntryID > 0)
     {
         // Make sure that none of the allomorphs of this entry match the original
         // form before we can enable btnOK.
         ILexEntry le = LexEntry.CreateFromDBObject(m_cache, m_selEntryID);
         // true if current list of MoForms contains one with matching form text.
         bool fMatchingForm = false;
         // true if current list of MoForms contains one of correct type
         bool fMatchingType = false;
         // If we don't know a morpheme type, don't restrict by type.
         IMoMorphType mtOrig = null;
         if (m_hvoType == 0)
         {
             fMatchingType = true;
         }
         else
         {
             mtOrig = MoMorphType.CreateFromDBObject(m_cache, m_hvoType);
         }
         foreach (IMoForm mf in le.AllAllomorphs)
         {
             if (mf.Form.VernacularDefaultWritingSystem == m_formOrig)
             {
                 fMatchingForm = true;
                 fMatchingType = false;
             }
             // To prevent confusion, allow any type that is ambiguous with the
             // current type (or, of course, if it is the SAME type, which for some
             // reason is NOT considered ambiguous).
             if (mtOrig != null && mf.MorphTypeRA != null &&
                 (m_hvoType == mf.MorphTypeRA.Hvo ||
                  mtOrig.IsAmbiguousWith(m_cache, m_types, mtOrig, mf.MorphTypeRA)))
             {
                 fMatchingType = true;
             }
             if (fMatchingForm)
             {
                 break;
             }
         }
         m_fInconsistentType = !fMatchingType;
         m_fMatchingForm     = fMatchingForm;
         if (fMatchingForm && fMatchingType)
         {
             btnOK.Text = SIL.FieldWorks.LexText.Controls.LexTextControls.ksUseAllomorph;
         }
         else
         {
             btnOK.Text = SIL.FieldWorks.LexText.Controls.LexTextControls.ksAddAllomorph_;
         }
         btnOK.Enabled = true;
     }
     else
     {
         base.HandleMatchingSelectionChanged();
     }
 }
Beispiel #2
0
 protected override void HandleMatchingSelectionChanged()
 {
     if (m_selObject != null)
     {
         // Make sure that none of the allomorphs of this entry match the original
         // form before we can enable btnOK.
         // true if current list of MoForms contains one with matching form text.
         bool fMatchingForm = false;
         // true if current list of MoForms contains one of correct type
         bool fMatchingType = false;
         // If we don't know a morpheme type, don't restrict by type.
         IMoMorphType mtOrig = null;
         if (m_hvoType == 0)
         {
             fMatchingType = true;
         }
         else
         {
             mtOrig = m_cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(m_hvoType);
         }
         foreach (var mf in ((ILexEntry)m_selObject).AllAllomorphs)
         {
             if (mf.Form.VernacularDefaultWritingSystem.Text == m_formOrig)
             {
                 fMatchingForm = true;
                 fMatchingType = false;
             }
             // To prevent confusion, allow any type that is ambiguous with the
             // current type (or, of course, if it is the SAME type, which for some
             // reason is NOT considered ambiguous).
             if (mtOrig != null && mf.MorphTypeRA != null &&
                 (m_hvoType == mf.MorphTypeRA.Hvo ||
                  mtOrig.IsAmbiguousWith(mf.MorphTypeRA)))
             {
                 fMatchingType = true;
             }
             if (fMatchingForm)
             {
                 break;
             }
         }
         m_fInconsistentType = !fMatchingType;
         m_fMatchingForm     = fMatchingForm;
         if (fMatchingForm && fMatchingType)
         {
             m_btnOK.Text = LexTextControls.ksUseAllomorph;
         }
         else
         {
             m_btnOK.Text = LexTextControls.ksAddAllomorph_;
         }
         m_btnOK.Enabled = true;
     }
     else
     {
         base.HandleMatchingSelectionChanged();
     }
 }