Beispiel #1
0
        public void SearchByTxt(AutoCompleteTipsItem aItem)
        {
            //先在main中查找,如果有,切换焦点后返回
            if (MainCanvas.ChangeSelectedByTxt(aItem) != null)
            {
                return;
            }
            //再在sub中查找,如果有,切换焦点后返回
            if (SubCanvas.ChangeSelectedByTxt(aItem) != null)
            {
                MainCanvas.ClearSelected();
                return;
            }

            //如果item精确对应到一个GUTag,直接使用该GUTag
            GUTag tag = aItem.Data as GUTag;

            if (tag == null)
            {
                List <GUTag> tags = TagDB.QueryTags(aItem.Content);
                if (tags.Count > 0)
                {
                    tag = tags[0];
                }
            }

            //如果不在视图中,但数据库中存在,TODO:如何有效的切换??是一个需要考虑的问题
            if (tag != null)
            {
                GUTag        mainRoot = TagDB.GetTag(StaticCfg.Ins.DefaultTagID);
                GUTag        subRoot  = mainRoot;
                GUTag        subSel   = subRoot;
                List <GUTag> parents  = QueryParentHistory(tag);
                int          cnt      = parents.Count;
                if (cnt > 0)
                {
                    subSel   = parents[0];
                    subRoot  = parents[Math.Min(3, cnt - 1)];
                    mainRoot = parents[Math.Min(6, cnt - 1)];
                }

                ChangeRoot(mainRoot, subRoot, subSel);
            }
            //不存在精确匹配的tag
            else
            {
            }
        }