/// <summary> /// 生成浏览dxf代码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { //DxfDocument dxf = new DxfDocument(); DxfModel dxf = new DxfModel(DxfVersion.Dxf15); //获取dxf图纸左上角图纸说明信息 List<string> dxfImageInfoList = FrontPhotoService.translateImageInfo(FrontPhotoService.productionDescription, imageBoxList); //缩放到真实比例 List<ImageEntity> dxfPaintImageBoxList = new List<ImageEntity>(); for (int i = 0; i < imageBoxList.Count;i++ ) { ImageEntity dxfPaintEntity = new ImageEntity(); dxfPaintEntity.Name = imageBoxList.ElementAt(i).Name; dxfPaintEntity.Rect = imageBoxList.ElementAt(i).Rect; dxfPaintEntity.imageWidth = imageBoxList.ElementAt(i).imageWidth; dxfPaintEntity.Type = imageBoxList.ElementAt(i).Type; dxfPaintEntity.Url = imageBoxList.ElementAt(i).Url; dxfPaintEntity.Text = imageBoxList.ElementAt(i).Text; dxfPaintEntity.firstDistance = imageBoxList.ElementAt(i).firstDistance; dxfPaintEntity.secondDistance = imageBoxList.ElementAt(i).secondDistance; dxfPaintEntity.coolingType = imageBoxList.ElementAt(i).coolingType; dxfPaintEntity.thirdDistance = imageBoxList.ElementAt(i).thirdDistance; dxfPaintEntity.topViewFirstDistance = imageBoxList.ElementAt(i).topViewFirstDistance; dxfPaintEntity.topViewSecondDistance = imageBoxList.ElementAt(i).topViewSecondDistance; dxfPaintImageBoxList.Add(dxfPaintEntity); } dxfPaintImageBoxList = FrontPhotoService.zoomOutImageEntity(dxfPaintImageBoxList, 1 / FrontPhotoService.factor); List<PictureBoxInfo> dxfReflectPictureNameList = new List<PictureBoxInfo>(); for (int i = 0, len = dxfPaintImageBoxList.Count; i < len; i++) { ImageEntity imageEntity = dxfPaintImageBoxList.ElementAt(i); // if(imageEntity.Name!="virtualHRA"){ PictureBoxInfo pbi = new PictureBoxInfo(); //pbi.location = new Location(tempDxfRelectPictureBox.Location.X,tempDxfRelectPictureBox.Location.Y,0); pbi.DLocation = new DLocation(imageEntity.Rect.X, imageEntity.Rect.Y, 0); pbi.height = imageEntity.Rect.Height; //相当于设备的长度 pbi.width = imageEntity.Rect.Width; pbi.topViewHeight = imageEntity.imageWidth; pbi.name = imageEntity.Name; pbi.text = TextSplitService.textSplit(imageEntity.Text); pbi.firstDistance = imageEntity.firstDistance; pbi.secondDistance = imageEntity.secondDistance; pbi.coolingType = imageEntity.coolingType; pbi.thirdDistance = imageEntity.thirdDistance; pbi.topViewFirstDistance = imageEntity.topViewFirstDistance; pbi.topViewSecondDistance = imageEntity.topViewSecondDistance; dxfReflectPictureNameList.Add(pbi); // } } //dxfReflectPictureNameList = FrontPhotoService.getRanglePictureInfoList(dxfReflectPictureNameList); DataCenter dataCenter = new DataCenter(); dataCenter.SectionEntity = new SectionEntity("40", "60"); dataCenter.OrderEntity = new OrderEntity("jobname", "unittag"); //图纸左上角说明信息 dataCenter.Configurations = dxfImageInfoList; dataCenter.detailMechineConfigure=new DetailMechineConfigure(dxfReflectPictureNameList, new string[] { "hello", "world", "helloworld" }, 44.0f, 18, 1.0f, 1.56f, 2.0f, 2.0f); dataCenter.topViewConfigure = new TopViewConfigure(dxfReflectPictureNameList, dxf, null, 50.0f, 18.0f, 2.0f, 2.86f, 2.0f, 2.0f); //float totalWidth = TotalWidthAndHeight.getWidth(dxfReflectPictureNameList); //获得下层链表 List<ImageEntity> tempDownList = FrontPhotoService.getDownList(imageBoxList); double totalWidth = TotalWidthAndHeight.getWidth(tempDownList); //double totalWidth = TotalWidthAndHeight.getWidth(dxfReflectPictureNameList); if (AssembleDetailMechine.isTwoLayers(dxfReflectPictureNameList)!=-1) { //float[] upOrDownHeightOrViewHieght = new float[3]; double[] upOrDownHeightOrViewHieght = new double[3]; upOrDownHeightOrViewHieght = TotalWidthAndHeight.getEachLayerHight(dxfReflectPictureNameList); dataCenter.BoxEntity = new BoxEntity { DownHeight = upOrDownHeightOrViewHieght[0], UpHeight = upOrDownHeightOrViewHieght[1], Width = totalWidth, TopViewHeight = upOrDownHeightOrViewHieght[2], IsLeft =FrontPhotoService.mirrorDirection.Equals("mirrorRight")?true:false }; } else { //float[] upOrDownHeightOrViewHieght = new float[3]; double[] upOrDownHeightOrViewHieght = new double[3]; upOrDownHeightOrViewHieght = TotalWidthAndHeight.getEachLayerHight(dxfReflectPictureNameList); dataCenter.BoxEntity = new BoxEntity { DownHeight = upOrDownHeightOrViewHieght[0], UpHeight = 0, Width = totalWidth, TopViewHeight = upOrDownHeightOrViewHieght[2], IsLeft = FrontPhotoService.mirrorDirection.Equals("mirrorRight") ? true : false }; } OuterBox outerBox = new OuterBox(); outerBox.dataCenter = dataCenter; //outerBox.Draw(dxf, new Location(500, 500), 306, 188, dxfReflectPictureNameList,5); outerBox.Draw(dxf, new DLocation(FrontPhotoService.leftStartX, FrontPhotoService.leftStartY), 306, 188, dxfReflectPictureNameList, 5); //dxf.Save("AutoCad2007.dxf", DxfVersion.AutoCad2007); //dxf.Save("AutoCad2004.dxf", DxfVersion.AutoCad2004); //dxf.Save("AutoCad2000.dxf", DxfVersion.AutoCad2000); //dxf.Save("AutoCad12.dxf", DxfVersion.AutoCad12); DxfWriter.Write("DxfWriteExample-R15-ascii.dxf", dxf, false); DxfWriter.Write("DxfWriteExample-R15-bin.dxf", dxf, true); DxfViewer dv = new DxfViewer(); dv.setDxfFile("DxfWriteExample-R15-ascii.dxf"); dv.Show(); //MessageBox.Show("图纸生成成功!"); }
private void button1_Click(object sender, EventArgs e) { DxfViewer dv = new DxfViewer(); dv.setDxfFile("cloneTest.dxf"); dv.SetDesktopLocation(100, 100); dv.Show(); }