private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { lstProjectFolder.Items.Clear(); if (treeStep7Project.SelectedNode is myTreeNode) { var tmp = (myTreeNode)treeStep7Project.SelectedNode; if (tmp.myObject.GetType() == typeof(BlocksOfflineFolder)) { BlocksOfflineFolder blkFld = (BlocksOfflineFolder)tmp.myObject; if ((int)SelectPart > 1000) { List <ProjectBlockInfo> blocks = blkFld.readPlcBlocksList(); foreach (ProjectBlockInfo step7ProjectBlockInfo in blocks) { if (step7ProjectBlockInfo.BlockType == PLCBlockType.VAT && SelectPart == SelectPartType.VariableTable) { lstProjectFolder.Items.Add(step7ProjectBlockInfo); } if (step7ProjectBlockInfo.BlockType == PLCBlockType.DB && SelectPart == SelectPartType.DataBlock) { lstProjectFolder.Items.Add(step7ProjectBlockInfo); } if (step7ProjectBlockInfo.BlockType == PLCBlockType.UDT && SelectPart == SelectPartType.DataType) { lstProjectFolder.Items.Add(step7ProjectBlockInfo); } if ((step7ProjectBlockInfo.BlockType == PLCBlockType.FB || step7ProjectBlockInfo.BlockType == PLCBlockType.FC) && SelectPart == SelectPartType.FunctionBlock) { lstProjectFolder.Items.Add(step7ProjectBlockInfo); } } } } } else if (treeStep7Project.SelectedNode is DBValueTreeNode) { //Maybe a DBTreeNode is not yet Expanded, then it need to be filled after select! if (treeStep7Project.SelectedNode is DBTreeNode) { AddDBValueNodes((DBTreeNode)treeStep7Project.SelectedNode); } DBValueTreeNode tmp = (DBValueTreeNode)treeStep7Project.SelectedNode; foreach (S7DataRow s7DataRow in tmp.s7datarow.Children) { if (s7DataRow.DataType != S7DataRowType.STRUCT && s7DataRow.DataType != S7DataRowType.UDT) { lstProjectFolder.Items.Add(new DBRowValue() { myRow = s7DataRow }); } } } }
private void AddDBValueSubNodes(TreeNode nd, S7DataRow row) { if (row.Children!=null) foreach (S7DataRow s7DataRow in row.Children) { if (s7DataRow._children!=null && s7DataRow.Children.Count>0) { DBValueTreeNode newNd = new DBValueTreeNode(); newNd.Text = s7DataRow.Name; newNd.s7datarow = s7DataRow; nd.Nodes.Add(newNd); AddDBValueSubNodes(newNd, s7DataRow); } } }
private void AddDBValueSubNodes(TreeNode nd, S7DataRow row) { if (row.Children != null) { foreach (S7DataRow s7DataRow in row.Children) { if (s7DataRow._children != null && s7DataRow.Children.Count > 0) { DBValueTreeNode newNd = new DBValueTreeNode(); newNd.Text = s7DataRow.Name; newNd.s7datarow = s7DataRow; nd.Nodes.Add(newNd); AddDBValueSubNodes(newNd, s7DataRow); } } } }