private void SelectItem(object sender, RoutedEventArgs e) { var item = ((Grid)((Button)sender).Parent).DataContext; var container = (ListViewItem)DefectsList.ContainerFromItem(item); container.IsSelected = true; }
//增加 public int AddModelParameter(ModelParameterCls mpc) { using (HullShellContainer hs = new HullShellContainer()) { //测量点云 ScanPoints spts = new ScanPoints { FileName = mpc.spc.FileName }; for (int i = 0; i < mpc.spc.SPList.Count; i++) { Point pt = new Point { X = mpc.spc.SPList[i].x, Y = mpc.spc.SPList[i].y, Z = mpc.spc.SPList[i].z }; spts.Point.Add(pt); } //调形文件 AdjustShapeFile asf = new AdjustShapeFile { FileName = mpc.asfc.FileName }; for (int i = 0; i < mpc.asfc.HeightValuesList.Count; i++) { HeightValueList hvs = new HeightValueList { R = mpc.asfc.HeightValuesList[i].C, C = mpc.asfc.HeightValuesList[i].R, Z = mpc.asfc.HeightValuesList[i].Z }; asf.HeightValueList.Add(hvs); } //插值文件 InterpolationFile _if = new InterpolationFile { FileName = mpc.ifc.FileName }; for (int i = 0; i < mpc.ifc.InterpolationList.Count; i++) { HeightValueList hvs = new HeightValueList { R = mpc.ifc.InterpolationList[i].C, C = mpc.ifc.InterpolationList[i].R, Z = mpc.ifc.InterpolationList[i].Z }; _if.HeightValueList.Add(hvs); } //缺陷 DefectsList dlc = new DefectsList { DefectName = mpc.dlc.DefectName, DefectReason = mpc.dlc.DefectReason, Solution = mpc.dlc.Slution }; ModelingParameter mp = new ModelingParameter { //基本属性 ProcessNumbers = mpc.ProcessNumbers, EnvTemperation = mpc.EnvTemperation, RecordTime = mpc.RecordTime, Coefficient = mpc.Coefficient, ResilienceValue = mpc._ResilienceValue, //索引属性 StdHullShell = hs.StdHullShellSet.Where(s => s.PlateModel == mpc.StdHullName).FirstOrDefault(), ProcessingEquipment = hs.ProcessingEquipmentSet.Where(s => s.EquipMentName == mpc.ProcessEquipmentName).FirstOrDefault(), Software = hs.SoftwareSet.Where(s => s.SoftwareName == mpc.SoftwareName).FirstOrDefault(), DetectEquipment = hs.DetectEquipmentSet.Where(s => s.DetectEquipmentName == mpc.DetectEquipmentName).FirstOrDefault(), Admins = hs.AdminsSet.Where(a => a.UserName == mpc.UserName).FirstOrDefault(), //关联属性 ScanPoints = spts, AdjustShapeFile = asf, InterpolationFile = _if, DefectsList = dlc, }; hs.AddToModelingParameterSet(mp); return(hs.SaveChanges()); } }