//public void RedrawGraph() //{ // //LayoutMode bak = GLayoutMode.mode; // //GLayoutMode.mode = MyLayoutMode; // RedrawGraph_(); // //GLayoutMode.mode = bak; //} public void RedrawGraph() { if (TagDB != null && RootTag != null && oriSize.Height != 0 && oriSize.Width != 0 && !oriSize.IsEmpty) { Logger.I("ShowGraph at " + RootTag); if (allTagBox != null) { env.Return(allTagBox); } if (allLine != null) { env.Return(allLine); } //canvasRecentTags.Children.Clear(); //计算有向图布局 ITagLayout tagLayout = TagLayoutFactory.CreateLayout(MyLayoutMode); tagLayout.Layout(TagDB, RootTag, oriSize, env); //将有向图中的元素显示在界面上 IEnumerable <UIElement> lines = tagLayout.Lines; IEnumerable <UIElement> allTxt = tagLayout.TagArea; allTagBox = allTxt as List <TagBox>; allLine = lines as List <System.Windows.Shapes.Path>; AdjustCanvasSize(tagLayout.Size.Width, tagLayout.Size.Height); //canvas.Width = tagLayout.Size.Width; //canvas.Height = tagLayout.Size.Height; //SetHeight(); foreach (UIElement l in lines) { if (!l.IsVisible) { canvas.Children.Add(l); } } foreach (TagBox t in allTxt) { //设置每一个tag的上下文菜单和事件响应钩子 if (t.ContextMenu == null) { t.ContextMenu = TagAreaMenu; t.MouseLeftButtonDown += Tag_MouseLeftButtonDown; t.MouseDoubleClick += Tag_MouseDoubleClick; canvas.Children.Add(t); } } //UpdateRecentTags(root); //SetCurrentTag(root); SetCurrentTag(); } }
public void test() { ITagDB tagdb = TagDBFactory.CreateTagDB(); tagdb.AddTag("parent", "child"); ITagLayout lay = TagLayoutFactory.CreateLayout(); lay.Layout(tagdb, "parent"); Assert.AreEqual(2, lay.Lines.Count()); Assert.AreEqual(2, lay.TagArea.Count()); }