示例#1
0
        /// <summary>
        /// Create the ordered vector of writing sytems to try for displaying names.
        /// </summary>
        protected void EstablishWritingSystemsToTry(string sDisplayWs)
        {
            if (m_writingSystemIds != null || m_cache == null || m_obj == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(sDisplayWs))
            {
                sDisplayWs = "analysis vernacular";                             // very general default.
            }
            int flid = 0;

            if (!string.IsNullOrEmpty(m_displayNameProperty))
            {
#if WANTPORT //  (FWR-2786 to investigate this)(FLEx) Needs replacement for virtual property handler
                CmObject          obj       = m_cache.GetObject(Hvo);
                string            className = m_cache.MetaDataCache.GetClassName(obj.ClassID);
                IVwVirtualHandler vh        = m_cache.VwCacheDaAccessor.GetVirtualHandlerName(className, m_displayNameProperty);
                if (vh != null)
                {
                    flid = vh.Tag;
                }
#endif
            }
            m_writingSystemIds = WritingSystemServices.GetWritingSystemIdsFromLabel(m_cache,
                                                                                    sDisplayWs,
                                                                                    m_cache.ServiceLocator.WritingSystemManager.UserWritingSystem,
                                                                                    m_obj.Hvo,
                                                                                    flid,
                                                                                    null);
        }
        private void CreateSearcher()
        {
            int control = 0;

            for (; m_curPossIndex < m_possibilities.Count; m_curPossIndex++)
            {
                // Every so often see whether the user has typed something that makes our search irrelevant.
                if (control++ % 50 == 0 && ShouldAbort())
                {
                    return;
                }

                ICmPossibility poss = m_possibilities[m_curPossIndex];
                ITsString      name = null;
                foreach (int ws in WritingSystemServices.GetWritingSystemIdsFromLabel(m_cache, m_displayWs, m_cache.ServiceLocator.WritingSystemManager.UserWritingSystem,
                                                                                      poss.Hvo, CmPossibilityTags.kflidName, null))
                {
                    ITsString tss = poss.Name.StringOrNull(ws);
                    if (tss != null && tss.Length > 0)
                    {
                        name = tss;
                        m_searcher.Add(poss, 0, tss);
                        break;
                    }
                }

                foreach (int ws in WritingSystemServices.GetWritingSystemIdsFromLabel(m_cache, m_displayWs, m_cache.ServiceLocator.WritingSystemManager.UserWritingSystem,
                                                                                      poss.Hvo, CmPossibilityTags.kflidAbbreviation, null))
                {
                    ITsString tss = poss.Abbreviation.StringOrNull(ws);
                    if (tss != null && tss.Length > 0)
                    {
                        m_searcher.Add(poss, 0, tss);
                        if (name != null)
                        {
                            var tisb = TsIncStrBldrClass.Create();
                            tisb.AppendTsString(tss);
                            tisb.AppendTsString(m_cache.TsStrFactory.MakeString(" - ", m_cache.DefaultUserWs));
                            tisb.AppendTsString(name);
                            m_searcher.Add(poss, 0, tisb.GetString());
                        }
                        break;
                    }
                }
            }
        }