private void listViewTemplates_DoubleClick(object sender, EventArgs e) { if (this._listViewTemplates.SelectedItems.Count > 0) { BatchTemplateTree templateTree = this._listViewTemplates.SelectedItems[0].Tag as BatchTemplateTree; if (templateTree != null) { this._splitContainer1.Panel2.Controls.Clear(); currentTemplateTree = templateTree; currentTemplateTree.ExpandAll(); //this._splitContainer1.Panel2.Controls.Remove(currentTemplateTree); this._splitContainer1.Panel2.Controls.Add(currentTemplateTree.GetRadTreeView()); this._splitContainer1.Panel2.Refresh(); } //BatchTemplateDef batchTemplate = this._listViewTemplates.SelectedItems[0].Tag as BatchTemplateDef; //if (batchTemplate != null) //{ // //templateTree.ClearNodes(); // this.Curbatch = batchTemplate; // //templateTree.CreateTreeFromTemplate(batchTemplate); // BatchTemplateTree templateTree = BatchTemplateTree.CreateTreeFromTemplate(batchTemplate); // currentTemplateTree = templateTree; // this._splitContainer1.Panel2.Controls.Remove(currentTemplateTree); // this._splitContainer1.Panel2.Controls.Add(currentTemplateTree); // currentTemplateTree.ExpandAll(); // //TODO Expand Node //} } }
private void btnNewTemplate_Click(object sender, EventArgs e) { UCBatchTempalteName uCBatchTempalteName = new UCBatchTempalteName(); if (uCBatchTempalteName.ShowInContainer() == DialogResult.OK) { BatchTemplateDef batchTemplate = new BatchTemplateDef(); batchTemplate.Name = uCBatchTempalteName.TemplateName; //根据模板创建树 BatchTemplateTree templateTree = BatchTemplateTree.CreateTreeFromTemplate(batchTemplate); //在右边视图中重新生成树 this._splitContainer1.Panel2.Controls.Clear(); currentTemplateTree = templateTree; this._splitContainer1.Panel2.Controls.Add(currentTemplateTree.GetRadTreeView()); this._splitContainer1.Panel2.Refresh(); //currentTemplateTree.Refresh(); //列表中添加新项,并保存树 ListViewItem listViewItem = new ListViewItem(uCBatchTempalteName.TemplateName); listViewItem.Tag = templateTree; this._listViewTemplates.Items.Add(listViewItem); //this._listViewTemplates.Items.Insert(0, listViewItem); } }
public static BatchTemplateDef FromBatchTemplateTree(BatchTemplateTree templateTree, string templateName) { BatchTemplateDef template = new BatchTemplateDef(); template.Name = templateName; RadTreeNode treeRootNode = templateTree.GetRadTreeView().Nodes[0]; if (treeRootNode != null) { template.RootNode = new TemplateNode() { Name = treeRootNode.Text }; template.AddTemplateNodeFromTreeNode(template.RootNode, treeRootNode); } return(template); }
public UCBatchTemplateEdit() { this.InitializeComponent(); currentTemplateTree = BatchTemplateTree.CreateTreeFromTemplate(null); //tree.Dock = DockStyle.Fill; //tree.AllowEdit = true; //tree.ShowLines = true; //this._splitContainer1.Panel2.Controls.Add(cutree this._splitContainer1.Panel2.Controls.Add(currentTemplateTree.GetRadTreeView()); this._listViewTemplates.MouseClick += new MouseEventHandler(this.listViewTemplates_MouseClick); this._listViewTemplates.DoubleClick += new EventHandler(this.listViewTemplates_DoubleClick); List <BatchTemplateDef> templates = BatchTemplateMgr.GetTemplates(); foreach (BatchTemplateDef template in templates) { ListViewItem listViewItem = new ListViewItem(template.Name); listViewItem.Tag = BatchTemplateTree.CreateTreeFromTemplate(template); this._listViewTemplates.Items.Add(listViewItem); } }