private void AddGroup_Click(object sender, EventArgs e) { GroupEditForm groupEditWindow = new GroupEditForm(); groupEditWindow.Model.ParentGroupID = (Guid)currentTreeNode.Tag; var result = groupEditWindow.ShowDialog(); var model = groupEditWindow.Model.Clone(); if (result == DialogResult.OK) { var newNode = new RDSDataNode() { Name = "node_" + model.GroupID, Text = model.GroupName, Tag = model.GroupID, RDSData = model, ContextMenuStrip = rightButtonMenu, NodeType = RDSDataNodeType.Group, ImageIndex = 0, SelectedImageIndex = 0 }; currentTreeNode.Nodes.Add(newNode); currentTreeNode.Expand(); } }
private void InitTreeView() { RDSDataManager dataManager = new RDSDataManager(); var doc = dataManager.GetData(); var root = doc.Root; RDSDataNode rootNode = new RDSDataNode(); rootNode.Text = "远程桌面"; rootNode.Tag = Guid.Empty; rootNode.NodeType = RDSDataNodeType.Group; rootNode.ContextMenuStrip = rightButtonMenu; rootNode.ImageIndex = 0; InitTreeNodes(root, rootNode); serverTree.Nodes.Add(rootNode); serverTree.ImageList = imageList1; rootNode.Expand(); currentTreeNode = rootNode; }