/*设置节点绑定对应的窗体*/ public static void AttachForm(TreeNode node, ShowViewForm form) { NodeInfo info = (NodeInfo)node.Tag; info._formFlag = true; info._form = form; }
public object _info; //其他信息 public NodeInfo() { _formFlag = false; _form = null; _nodeType = string.Empty; _info = null; _formType = 0; }
/*显示被选中的元件节点*/ private void SelectLibNodeToShow(TreeNode node) { ShowViewForm viewForm = null; NodeInfo info = (NodeInfo)node.Tag; CloseExistForm(node); try { if (info._formType == Princeple.FormType.APP || info._formType == Princeple.FormType.STATUS) { TargetNode target = GetTargetNode(node); ShowViewForm destForm = (info._formType == Princeple.FormType.APP ? target.DynamicTopoForm : target.StatusForm); if (destForm != null) { viewForm = destForm; } else { viewForm = new ShowViewForm(node); if (info._formType == Princeple.FormType.APP) { target.DynamicTopoForm = viewForm; } else { target.StatusForm = viewForm; } } } else { viewForm = new ShowViewForm(node); } //1.显示窗体 viewForm.Text = node.Text; WeifenLuo.WinFormsUI.Docking.DockPanel panel = MainForm.GetPanel(); viewForm.Show(panel); //2.通过view来初始化propertyGrid PropertyForm.Show(viewForm.showViewPanel1.ShowView.GetModelInstance()); //3.配置树节点的NodeInfo info._form = viewForm; info._formFlag = true; } catch (Exception e) { MainForm.SetOutPutText(e.StackTrace); } }
/// <summary> /// 选择资源节点去显示 /// </summary> /// <param name="node"></param> private void SelectSourceNodeToShow(TreeNode node) { NodeInfo info = (NodeInfo)node.Tag; String nodeName = node.Text; CloseExistForm(node); //显示一个view ShowViewForm viewForm = new ShowViewForm(node); viewForm.Text = nodeName; WeifenLuo.WinFormsUI.Docking.DockPanel panel = MainForm.GetPanel(); viewForm.Show(panel); }
/*判断对应窗口口是否已经存在:存在,关闭;不存在,跳过;*/ private void CloseExistForm(TreeNode node) { if (NodeInfo.FormShowed(node)) { NodeInfo info = (NodeInfo)node.Tag; ShowViewForm form = info._form; if (form != null) { if (info._formType == Princeple.FormType.APP || info._formType == Princeple.FormType.STATUS) { form.Hide(); } else { form.Close(); } } } }