// 添加静力触探孔函数 private void AddNewJk() { this.ContectGrid.Children.Clear(); CPTControl newCPT = new CPTControl(); this.ContectGrid.Children.Add(newCPT); }
// TreeView选择节点变化时激活不同的内容控件 private void ProjectTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { // 读取选中节点 TreeViewItem selectedItem = (TreeViewItem)e.NewValue; // 根据选中状况清空窗口中的控件 if (selectedItem == null) { this.ContectGrid.Children.Clear(); return; } if (selectedItem.Header.ToString() != "基本信息" && selectedItem.Parent != null) { this.ContectGrid.Children.Clear(); } // 选中一级节点时 // 选中"基本信息" if (selectedItem.Header.ToString() == "基本信息") { ProjectBasicInfo prjb = new ProjectBasicInfo(); this.ContectGrid.Children.Add(prjb); } // 选中二级、三级节点时 if (selectedItem.Parent != null) { // 读取父节点 TreeViewItem parentItem = (TreeViewItem)selectedItem.Parent; // 选中"钻孔"子节点 if (parentItem.Header.ToString() == "钻孔") { // 读取当前所选钻孔名称 string prj = Program.currentProject; string zkName = selectedItem.Header.ToString(); // 实例化一个Borehole类,并将当前所选钻孔的数据库信息赋值给此实例 Borehole bh = new Borehole(zkName, BoreholeDataBase.ReadAltitude(prj, zkName)); bh.X = BoreholeDataBase.ReadXAxis(prj, zkName); bh.Y = BoreholeDataBase.ReadYAxis(prj, zkName); bh.InitialWaterLevel = BoreholeDataBase.ReadInitialWaterLevel(prj, zkName); bh.StableWaterLevel = BoreholeDataBase.ReadStableWaterLevel(prj, zkName); bh.Layers = BoreholeDataBase.ReadZkLayer(prj, zkName); bh.Samples = BoreholeDataBase.ReadZkSample(prj, zkName); bh.NTests = BoreholeDataBase.ReadZkNTest(prj, zkName); // 实例化BoreholeControl用户控件,并赋值 BoreholeControl bhc = new BoreholeControl(bh); this.ContectGrid.Children.Add(bhc); } // 选取"原位测试"-"静力触探"子节点 if (parentItem.Header.ToString() == "静力触探") { // 读取当前所选触探孔名称 string prj = Program.currentProject; string jkName = selectedItem.Header.ToString(); // 实例化一个CPT类,并将当前所选触探孔的数据库信息赋值给此实例 CPT cpt = new CPT(jkName, CPTDataBase.ReadAltitude(prj, jkName)); cpt.X = CPTDataBase.ReadXAxis(prj, jkName); cpt.Y = CPTDataBase.ReadYAxis(prj, jkName); cpt.Layers = CPTDataBase.ReadJkLayer(prj, jkName); cpt.PsList = CPTDataBase.ReadJkPs(prj, jkName); // 实例化CPTControl用户控件,并赋值 CPTControl cptc = new CPTControl(cpt); this.ContectGrid.Children.Add(cptc); } // 选取"室内试验"-"土工常规"子节点 if (selectedItem.Header.ToString() == "土工常规") { // 实例化一个RoutineSoilTest类列表,并读取数据库信息赋值给此实例 List <RoutineSoilTest> rsts = RoutineSoilTestDataBase.ReadAllData(Program.currentProject); // 实例化RoutineSoilTestControl用户控件,并赋值 RoutineSoilTestControl rstc = new RoutineSoilTestControl(rsts); this.ContectGrid.Children.Add(rstc); } // 选取"室内试验"-"颗粒分析"子节点 if (selectedItem.Header.ToString() == "颗粒分析") { // 实例化一个RoutineSoilTest类列表,并读取数据库信息赋值给此实例 List <GrainAnalysisTest> gats = GrainAnalysisTestDataBase.ReadAllData(Program.currentProject); // 实例化RoutineSoilTestControl用户控件,并赋值 GrainAnalysisTestControl gatc = new GrainAnalysisTestControl(gats); this.ContectGrid.Children.Add(gatc); } } }