private void treeViewBranches_AfterExpand(object sender, TreeViewEventArgs e) { if (e.Node.Nodes.Count > 1) { return; } List <TreeNode> list = new List <TreeNode>(); List <OpcNode> opcNodes = client.ShowBranches(((OpcNode)e.Node.Tag).NodeId); foreach (var nodeSon in opcNodes) { TreeNode treeNode = new TreeNode(); treeNode.Name = nodeSon.NodeName; treeNode.Text = nodeSon.NodeName; treeNode.Tag = nodeSon; treeNode.ImageKey = nodeSon.Key; treeNode.SelectedImageKey = nodeSon.Key; if (nodeSon.IsExpand) { treeNode.Nodes.Add(new TreeNode()); } list.Add(treeNode); } e.Node.Nodes.Clear(); e.Node.Nodes.AddRange(list.ToArray()); }
private void btnConnServer_Click(object sender, EventArgs e) { client.Connect(cmbServerName.Text); List <string> branches = client.ShowBranches(); client.CreateGroupData(); listBoxGroups.Items.Clear(); foreach (string item in branches) { listBoxGroups.Items.Add(item); } btnDisconnServer.Enabled = true; btnConnServer.Enabled = false; }
public AddTags(IOpcClient iOpc, string groupName, string blockName) { InitializeComponent(); this.client = iOpc; this.groupName = groupName; this.blockName = blockName; lblGroup.Text = this.groupName; lblBlock.Text = this.blockName; imageList.Images.Add("Class_489", Properties.Resources.Class_489); imageList.Images.Add("ClassIcon", Properties.Resources.ClassIcon); imageList.Images.Add("brackets", Properties.Resources.brackets_Square_16xMD); imageList.Images.Add("VirtualMachine", Properties.Resources.VirtualMachine); imageList.Images.Add("Enum_582", Properties.Resources.Enum_582); imageList.Images.Add("Method_636", Properties.Resources.Method_636); imageList.Images.Add("Module_648", Properties.Resources.Module_648); imageList.Images.Add("Loading", Properties.Resources.loading); treeViewBranches.ImageList = imageList; treeViewBranches.Nodes.Add(new TreeNode("Browsering...", 7, 7)); List <TreeNode> listNode = Task.Run(() => { List <TreeNode> list = new List <TreeNode>(); List <OpcNode> opcNodes = client.ShowBranches(); foreach (var nodeSon in opcNodes) { TreeNode treeNode = new TreeNode(); treeNode.Name = nodeSon.NodeName; treeNode.Text = nodeSon.NodeName; treeNode.Tag = nodeSon; treeNode.ImageKey = nodeSon.Key; treeNode.SelectedImageKey = nodeSon.Key; if (nodeSon.IsExpand) { treeNode.Nodes.Add(new TreeNode()); } list.Add(treeNode); } return(list); }).Result; treeViewBranches.Nodes.Clear(); treeViewBranches.Nodes.AddRange(listNode.ToArray()); }