public IActionResult B(int b_i) { Type t = typeof(Test); var tool = t.GetMethod(nameof(Test.fouEa)); var method = t.GetMethod(nameof(Test.fouEa), new[] { typeof(string) }); ViewBag.method = method; ModelOper op = toolBase; b_i = 789; int see = op(b_i); ViewBag.op = see; return(View()); }
private PlateModel analyticalPaper(string url) { //DateTime beforDT = System.DateTime.Now; PlateModel plate = new PlateModel(); string[] urlStr = url.Split('\\'); string[] nameAndNum = urlStr[urlStr.Length - 1].Split('-'); plate.PlateName = nameAndNum[0]; plate.PlateCode = nameAndNum[0]; plate.PlateCount = int.Parse(nameAndNum[1].Substring(0, nameAndNum[1].Length - 4)); #region 加载dxf文件,获取文件每行的内容 List <string> listDxfInfo = new List <string>(); StreamReader sr = new StreamReader(url, Encoding.Default); String input; while ((input = sr.ReadLine()) != "EOF") { listDxfInfo.Add(input); } listDxfInfo.Add("EOF"); sr.Close(); #endregion #region 提取需要的信息内容,这里按图形和文字进行分类提取 List <string> listLine = new List <string>(); //直线类型 List <string> listCircle = new List <string>(); //圆类型 List <string> listArc = new List <string>(); //圆弧类型 List <string> listEllipse = new List <string>(); //椭圆类型 List <string> listText = new List <string>(); //单行文字类型 List <string> listMtext = new List <string>(); //多行文字类型 List <string> listLayer = new List <string>(); //图层信息 Dictionary <string, string> layerNandC = new Dictionary <string, string>(); //图层颜色和信息 for (int i = 0; i < listDxfInfo.Count; i++) { string s1 = listDxfInfo[i].Trim(); string s2 = listDxfInfo[i = i + 1].Trim(); if ("LAYER".Equals(s2) && "0".Equals(s1)) { List <string> getList = createListByClass(i - 1, listDxfInfo); listLayer.AddRange(getList); i = i + getList.Count - 2; getList.Clear(); } else if ("LINE".Equals(s2) && "0".Equals(s1)) { List <string> getList = createListByClass(i - 1, listDxfInfo); listLine.AddRange(getList); i = i + getList.Count - 2; getList.Clear(); } else if ("CIRCLE".Equals(s2) && "0".Equals(s1)) { List <string> getList = createListByClass(i - 1, listDxfInfo); listCircle.AddRange(getList); i = i + getList.Count - 2; getList.Clear(); } else if ("ARC".Equals(s2) && "0".Equals(s1)) { List <string> getList = createListByClass(i - 1, listDxfInfo); listArc.AddRange(getList); i = i + getList.Count - 2; getList.Clear(); } else if ("ELLIPSE".Equals(s2) && "0".Equals(s1)) { List <string> getList = createListByClass(i - 1, listDxfInfo); listEllipse.AddRange(getList); i = i + getList.Count - 2; getList.Clear(); } else if ("TEXT".Equals(s2) && "0".Equals(s1)) { List <string> getList = createListByClass(i - 1, listDxfInfo); listText.AddRange(getList); i = i + getList.Count - 2; getList.Clear(); } else if ("MTEXT".Equals(s2) && "0".Equals(s1)) { List <string> getList = createListByClass(i - 1, listDxfInfo); listMtext.AddRange(getList); i = i + getList.Count - 2; getList.Clear(); } } listDxfInfo.Clear(); #endregion #region 利用GDI+在自己的cad面板中画出提取出的内容 if (listLayer.Count > 0) { layerNandC = new LayerTool().getLayer(listLayer); } if (listLine.Count > 0) { plate.OutModel.ListShape.AddRange(new LineTool().getLineByColor(listLine, layerNandC)); } if (listCircle.Count > 0) { plate.OutModel.ListShape.AddRange(new CircleTool().getLineByColor(listCircle, layerNandC)); } if (listArc.Count > 0) { plate.OutModel.ListShape.AddRange(new ArcTool().getLineByColor(listArc, layerNandC)); } //if (listText.Count > 0) { new TextTool().createText(listText); } if (listEllipse.Count > 0) { plate.OutModel.ListShape.AddRange(new EllipseTool().getLineByColor(listEllipse, layerNandC)); } #endregion listEllipse.Clear(); listText.Clear(); listArc.Clear(); listCircle.Clear(); listLine.Clear(); listLayer.Clear(); layerNandC.Clear(); ModelOper modelOper = new ModelOper(); plate = modelOper.baseShapeSort(plate); for (int k = 0; k < plate.InnerModel.Count; k++) { plate.InnerModel[k] = modelOper.reSetPointShunXu(plate.InnerModel[k], false); } //for (int i = 0; i < plate.InnerModel[0].ListShape.Count; i++) //{ // Console.WriteLine("{0},{1},{2}", // plate.InnerModel[0].ListShape[i].ShapeClass, plate.InnerModel[0].ListShape[i].StartPoint, plate.InnerModel[0].ListShape[i].EndPoint); //} //CADInterface.currentPlates.Add(plate.OutModel); //这里不存在外围面域,下面的判断之后才选定外围面域 CADInterface.currentPlates.AddRange(plate.InnerModel); CADInterface.DrawShap(); plate = modelOper.reSetOutInner(plate); plate = modelOper.juedeIsArc(plate); plate = new CalculateArea().getPlateArea(plate); plate = new CalculateArea().getPlateBound(plate); plate = new CreateCenterPoint().getRotateCenter(plate); plate = new CreateCenterPoint().getPowCenter(plate); //DateTime afterDT = System.DateTime.Now; //TimeSpan ts = afterDT.Subtract(beforDT); //Console.WriteLine("件号:{0},时间:{1}", // plate.PlateName, ts.TotalSeconds); return(plate); //DateTime afterDT = System.DateTime.Now; //TimeSpan ts = afterDT.Subtract(beforDT); //MessageBox.Show("DateTime总共花费:" + ts.TotalMilliseconds); }