Beispiel #1
0
        private ILexRefType CreateLexRefType(LexRefTypeTags.MappingTypes type, string name, string abbr, string revName, string revAbbr)
        {
            if (Cache.LangProject.LexDbOA.ReferencesOA == null)
            {
                Cache.LangProject.LexDbOA.ReferencesOA = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create();
            }
            var referencePossibilities = Cache.LangProject.LexDbOA.ReferencesOA.PossibilitiesOS;

            if (referencePossibilities.Any(r => r.Name.BestAnalysisAlternative.Text == name))
            {
                return(referencePossibilities.First(r => r.Name.BestAnalysisAlternative.Text == name) as ILexRefType);
            }
            var lrt = Cache.ServiceLocator.GetInstance <ILexRefTypeFactory>().Create();

            referencePossibilities.Add(lrt);
            lrt.MappingType = (int)type;
            lrt.Name.set_String(m_wsEn, name);
            lrt.Abbreviation.set_String(m_wsEn, abbr);
            if (!string.IsNullOrEmpty(revName))
            {
                lrt.ReverseName.set_String(m_wsEn, revName);
            }
            if (!string.IsNullOrEmpty(revAbbr))
            {
                lrt.ReverseAbbreviation.set_String(m_wsEn, revAbbr);
            }
            return(lrt);
        }
        /// <summary>
        /// Override method to handle launching of a chooser for selecting lexical entries.
        /// </summary>
        protected override void HandleChooser()
        {
            ILexRefType lrt = (ILexRefType)m_obj.Owner;

            LexRefTypeTags.MappingTypes type = (LexRefTypeTags.MappingTypes)lrt.MappingType;
            BaseGoDlg dlg = null;

            try
            {
                switch (type)
                {
                case LexRefTypeTags.MappingTypes.kmtSensePair:
                case LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair:                         // Sense pair with different Forward/Reverse names
                    dlg = new LinkEntryOrSenseDlg();
                    (dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
                    break;

                case LexRefTypeTags.MappingTypes.kmtEntryPair:
                case LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair:                         // Entry pair with different Forward/Reverse names
                    dlg = new EntryGoDlg();
                    break;

                case LexRefTypeTags.MappingTypes.kmtEntryOrSensePair:
                case LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair:                         // Entry or sense pair with different Forward/Reverse
                    dlg = new LinkEntryOrSenseDlg();
                    (dlg as LinkEntryOrSenseDlg).SelectSensesOnly = false;
                    break;
                }
                Debug.Assert(dlg != null);
                var wp = new WindowParams();
                //on creating Pair Lexical Relation have an Add button and Add in the title bar
                if (Target == null)
                {
                    wp.m_title   = String.Format(LexEdStrings.ksIdentifyXEntry, lrt.Name.BestAnalysisAlternative.Text);
                    wp.m_btnText = LexEdStrings.ks_Add;
                }
                else                 //Otherwise we are Replacing the item
                {
                    wp.m_title   = String.Format(LexEdStrings.ksReplaceXEntry);
                    wp.m_btnText = LexEdStrings.ks_Replace;
                }

                dlg.SetDlgInfo(m_cache, wp, m_mediator);
                dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
                if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    if (dlg.SelectedObject != null)
                    {
                        AddItem(dlg.SelectedObject);
                        // it is possible that the previous update has caused the data tree to refresh
                        if (!IsDisposed)
                        {
                            m_atomicRefView.RootBox.Reconstruct();                             // view is somehow too complex for auto-update.
                        }
                    }
                }
            }
            finally
            {
                if (dlg != null)
                {
                    dlg.Dispose();
                }
            }
        }