private void button1_Click(object sender, EventArgs e) { SrcFragmentCC.Clear(); XmlDocument crdXml = new XmlDocument(); crdXml.Load(path); string ccid = comboBox2.Text; foreach (XmlElement classNode in crdXml.DocumentElement.SelectNodes("class")) { if (classNode.GetAttribute("classid") == ccid) { List <string> fullSource = new List <string>(); string sourcePath = ((XmlElement)classNode.ChildNodes[0]).GetAttribute("file"); //获取目标系统文件夹起始路径 string subSysStartPath = Global.mainForm.subSysDirectory; //绝对路径=起始路径+相对路径 string subSysPath = subSysStartPath + "\\" + sourcePath; //获得源文件代码 SrcPathCC = subSysPath; fullSource = Global.GetFileContent(subSysPath); //提取对应行号的代码片段 int startLine = int.Parse(((XmlElement)classNode.ChildNodes[0]).GetAttribute("startline")); int endLine = int.Parse(((XmlElement)classNode.ChildNodes[0]).GetAttribute("endline")); for (int j = startLine - 1; j < endLine; j++) //注意,索引从0起算,而行号从1起算 { SrcFragmentCC.Add(fullSource[j]); } break; } } FragmentSettingForm.flag = 0; FragmentSettingForm test = new FragmentSettingForm(); flag = 1; test.Confirm(SrcFragmentCC); this.Close(); }
private void button1_Click(object sender, EventArgs e) { Clustering pre = new Clustering(); pre.CreatMatrix(); List <XmlElement> dest_xml = new List <XmlElement>(); for (int k = 0; k < (pre.xtemp_matrix.Count - 1); k++) { if (judge(textBox1.Text, textBox2.Text, pre.xtemp_matrix[k + 1][1]) == 0) { continue; } if (judge(textBox3.Text, textBox4.Text, pre.xtemp_matrix[k + 1][7]) == 0) { continue; } if (judge(textBox5.Text, textBox6.Text, pre.xtemp_matrix[k + 1][8]) == 0) { continue; } if (judge(textBox7.Text, textBox8.Text, pre.xtemp_matrix[k + 1][9]) == 0) { continue; } if (judge(textBox9.Text, textBox10.Text, pre.xtemp_matrix[k + 1][10]) == 0) { continue; } if (judge(textBox11.Text, textBox12.Text, pre.xtemp_matrix[k + 1][11]) == 0) { continue; } if (judge(textBox13.Text, textBox14.Text, pre.xtemp_matrix[k + 1][12]) == 0) { continue; } if (judge(textBox15.Text, textBox16.Text, pre.xtemp_matrix[k + 1][13]) == 0) { continue; } if (judge(textBox17.Text, textBox18.Text, pre.xtemp_matrix[k + 1][14]) == 0) { continue; } dest_xml.Add(pre.CFinfo[k]); } Global.mainForm.tabControl1.TabPages.Add(" ");//创建新的tabPage,显示文件名 Global.mainForm.tabControl1.SelectedTab = Global.mainForm.tabControl1.TabPages[Global.mainForm.tabControl1.TabPages.Count - 1]; //创建TreeView控件 TreeView newTreeView = new TreeView(); Global.mainForm.tabControl1.TabPages[Global.mainForm.tabControl1.TabPages.Count - 1].Controls.Add(newTreeView); newTreeView.Dock = DockStyle.Fill; if (dest_xml.Count == 0) { MessageBox.Show("No match"); } else { FragmentSettingForm sxml = new FragmentSettingForm(); sxml.ShowXml(dest_xml, ref newTreeView); } this.Close(); newTreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(Global.mainForm.newTreeView_NodeMouseClick); //添加预定义的上下文菜单 newTreeView.ContextMenuStrip = Global.mainForm.contextMenuStrip1; newTreeView.ExpandAll(); }