예제 #1
0
        private void ShowRootPath()
        {
            //如果配置不需要显示,则直接返回
            if (!NeedShowRootPath())
            {
                return;
            }
            if (RootTag == null)
            {
                return;
            }

            connectCanvas.Children.Clear();

            //需要显示从全局根到当前视图根节点之间的路径
            //查找出所有从当前视图根节点到全局根节点之间的中间节点
            List <GUTag> connect = new List <GUTag>();
            GUTag        from    = RootTag;
            GUTag        tmp     = from;

            connect.Add(from);
            while (connect.Count < 20 && tmp != null)
            {
                List <GUTag> ps = TagDB.QueryTagParent(tmp);
                if (ps.Count > 0)
                {
                    tmp = ps[0];
                    connect.Add(tmp);
                }
                else
                {
                    break;
                }
            }
            connect.Reverse();

            //显示所有中间节点
            double X = 0;

            foreach (GUTag u in connect)
            {
                GTagBox gt = new GTagBox(5, u, X, 0, 1);
                TagBox  tx = UIElementFactory.CreateTagBox(gt, null);
                tx.HideCircle();

                X += gt.OutterBox.Width;
                if (tx.ContextMenu == null)
                {
                    tx.ContextMenu          = TagAreaMenu;
                    tx.MouseLeftButtonDown += Tag_MouseLeftButtonDown;
                    tx.MouseDoubleClick    += Tag_MouseDoubleClick;
                }
                connectCanvas.Children.Add(tx);
            }
        }
예제 #2
0
        private string GetTagInf(GUTag tag, ITagDB db)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("当前选中标签:" + tag);

            List <GUTag> parents = db.QueryTagParent(tag);

            if (parents.Count > 0)
            {
                sb.Append(" Parent::= ");
                foreach (GUTag s in parents)
                {
                    sb.Append(" " + s.Title);
                }
            }


            List <GUTag> children = TagDB.QueryTagChildren(tag);

            if (children.Count > 0)
            {
                sb.Append(" Children::= ");
                foreach (GUTag s in children)
                {
                    sb.Append(" " + s.Title);
                }
            }
            return(sb.ToString().Trim());
        }
예제 #3
0
        public void testParent()
        {
            Logger.Log("0");
            db.AddTag("p1", "c");
            List <string> p = db.QueryTagParent("c");

            Assert.AreEqual(1, p.Count);
            Assert.AreEqual("p1", p[0]);


            db.AddTag("p2", "c");
            p = db.QueryTagParent("c");
            Assert.AreEqual(2, p.Count);
            Assert.AreEqual("p1", p[0]);
            Assert.AreEqual("p2", p[1]);
        }
예제 #4
0
        private List <GUTag> QueryParentHistory(GUTag tag)
        {
            List <GUTag> ret   = new List <GUTag>();
            int          MAX   = 6;
            GUTag        child = tag;

            while (ret.Count < MAX)
            {
                ret.Add(child);
                List <GUTag> tmp = TagDB.QueryTagParent(child);
                if (tmp.Count > 0)
                {
                    child = tmp[0];
                }
                else
                {
                    break;
                }
            }
            return(ret);
        }
예제 #5
0
        public void ITagDB_Test_Remove()//添加后删除
        {
            GUTag p  = db.NewTag("p");
            GUTag c1 = db.NewTag("c1");

            db.SetParent(p, c1);

            List <string> a = db.QueryTagAlias(c1);

            Assert.AreEqual(1, a.Count);
            Assert.AreEqual("c1", a[0]);

            db.RemoveTag(c1);
            a = db.QueryTagAlias(c1);
            Assert.AreEqual(0, a.Count);

            Assert.AreEqual(0, db.QueryTagParent(c1).Count);
        }