/// <summary> /// 根据拓扑数据显示布线图 /// </summary> private void ShowGraph(BranchView obj) { this.Dispatcher.Invoke((Action)(() => { LayoutDocument doc = new LayoutDocument(); WireGraph graph = null; bool left = true, right = true; doc.Title = obj.GraphName; switch (obj.GraphType) { case GraphType.VccToGndGraph: { left = true; right = true; break; } case GraphType.VccToCFGraph: { left = true; right = false; break; } case GraphType.CFToGndGraph: { left = true; right = false; break; } case GraphType.CompleteGraph: { left = true; right = false; break; } } LayoutContent other = ShowPanel.Children.FirstOrDefault(p => p.Title.Equals(doc.Title)); if (other != null) { other.IsActive = true; return; } ShowPanel.Children.Add(doc); doc.IsActive = true; if (obj.page == null) { graph = new WireGraph(obj, left, right); obj.page = graph; } else { graph = (WireGraph)obj.page; } doc.Content = graph; })); }
/// <summary> /// 退出工作模式后恢复到开启工作模式时的页面打开状态 /// </summary> private void RecoverPages(object obj) { IList <string> pages = (IList <string>)obj; List <LayoutDocument> docs = new List <LayoutDocument>(); foreach (LayoutDocument page in ShowPanel.Children) { if (pages.Contains(page.Title)) { page.CanClose = true; } else { docs.Add(page); } if (page.Content is WireGraph) { WireGraph graph = (WireGraph)page.Content; graph.resetComponents(); } } docs.ForEach(doc => doc.Close()); }