C#讀取DXF文件_第1頁(yè)
C#讀取DXF文件_第2頁(yè)
C#讀取DXF文件_第3頁(yè)
C#讀取DXF文件_第4頁(yè)
C#讀取DXF文件_第5頁(yè)
已閱讀5頁(yè),還剩18頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Collections;namespaceDXF(publicpartialclassForml:Form(privateFileStreamfs;privateStreamReadersr;privateArrayListLayerList=

2、newArrayList();privateArrayListLineList=newArrayList();privateArrayListArcList=newArrayList();privateArrayListEllipseList=newArrayList();privateArrayListLwopolylineList=newArrayListprivateArrayListSplineList=newArrayList();privatestringstr=newstring2;privateintcount;privatedoubleleftx;privatedoublel

3、efty;0;privatedoublerightx;privatedoublerighty;publicForm1()(lnitializeComponent();)privatestringReadPair()(stringcode=sr.ReadLine().Trim();stringcodedata=sr.ReadLine().Trim();count+=2;stringresult=newstring2code,codedata;returnresult;)privatevoidRead()while(sr.Peek()!=-1)str=ReadPair();if(str1=&quo

4、t;SECTION)(str=ReadPair();switch(str1)case"HEADER"ReadHeader();break;case"TABLES'!ReadTable();break;case"ENTITIES":ReadEntities();break;)sr.Close();fs.Close();btDraw.Enabled=true;label1.Text=count.ToString();count=0;)privatevoidReadTable()(while(str1!="ENDSEQ"(

5、while(strO!="2"|str1!="LAYER')(str=ReadPairQ;while(strO!="LAYER')str=ReadPair();)while(strO=(ReadLAYER();)while(str1!=(str=ReadPair();)"0"&&str1="LAYER')"ENDSEQ"privatevoidReadLAYER()LAYEFbewlayer=newLAYEI0;while(str1!="ENDTAB)

6、9;str=ReadPair();switch(strO)(case"2":=str1;break;case"62":newlayer.colornum=str1;break;case"6":newlayer.lstyle=str1;break;case"370":newlayer.lwidth=str1;break;)if(str0="0"&&str1="LAYER')(LayerList.Add(newlayer);return;)

7、LayerList.Add(newlayer);)privatevoidReadEntities()(while(str1!="ENDSEQ"(switch(str1)(case"LINE":ReadLine();break;case"ARC"ReadArc();break;case"CIRCLE":ReadArcQ;break;case"ELLIPSE":ReadEllipse();break;case"LWPOLYLINE:"ReadLwpolyline();break;

8、case"SPLINE":ReadSpline();break;default:str=ReadPair();break;privatevoidReadArc()ARCnewarc=newARC();while(str1!="ENDSEC)"str=ReadPair();switch(str0)case"8":newarc.LName=str1;break;case"10":newarc.CenterX=Double.Parse(str1);break;Double.Parse(str1);Double.Parse

9、(str1);Double.Parse(str1);Double.Parse(str1);case"20":newarc.CenterY=break;case"40":newarc.Radiu=break;case"50":newarc.SAngle=break;case"51":newarc.EAngle=break;case"370":newarc.lwidth=str1;break;case"0":ArcList.Add(newarc);return;privatevo

10、idReadLine()LINEnewline=newLINE();while(str1!="ENDSEC)"str=ReadPair();switch(str0)case"8":newline.LName=str1;break;Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);case"10":newline.StartX=break;case"20":newline.StartY=break;case"

11、;11":newline.EndX=break;case"21":newline.EndY=break;case"62":newline.colornum=str1;break;case"370":newline.lwidth=str1;break;case"0":LineList.Add(newline);return;privatevoidReadEllipse()ELLIPSEnewellipse=newELLIPSE();while(str1!="ENDSEC)"str=Rea

12、dPair();switch(str0)case"8":newellipse.LName=str1;break;case"10":newellipse.CenterX=break;case"20":newellipse.CenterY=break;case"11":newellipse.DeltaX=break;case"21":newellipse.DeltaY=break;case"40":newellipse.Radio=break;case"41"

13、:newellipse.PSAngle=break;case"42":newellipse.PEAngle=break;Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);case"370":newellipse.lwidth=str1;break;case"0":EllipseList.Add(newellipse);re

14、turn;privatevoidReadLwpolyline()LWPOLYLINnEewlw=newLWPOLYLIN()E;while(str1!="ENDSEC)"str=ReadPair();switch(str0)case"8":newlw.LName=str1;break;case"370":newlw.lwidth=str1;break;case"62":newlw.colornum=str1;break;case"90":newlw.PointCount=Int32.Parse(

15、str1);break;case"70":newlw.Flag=Int32.Parse(str1);break;case"10":newlw.pointx=newdoublenewlw.PointCount;newlw.pointy=newdoublenewlw.PointCount;/if(newlw.Flag=1)newlw.converxity=newdoublenewlw.PointCount;/else/newlw.converxity=newdoublenewlw.PointCount-1;newlw.pointx0=Double.Parse

16、(str1);str=ReadPair();newlw.pointy0=Double.Parse(str1);for(inti=1;i<newlw.PointCount;i+)stringtemp=sr.ReadLine().Trim();if(temp="42")newlw.converxityi-1=Double.Parse(sr.ReadLine().Trim();i-;elseif(temp="20")stringr=sr.ReadLine().Trim();newlw.pointyi=Double.Parse(r);elsestringr

17、=sr.ReadLine().Trim();newlw.pointxi=Double.Parse(r);i-;strings=sr.ReadLine().Trim();if(s="42")newlw.converxitynewlw.PointCount-1=Double.Parse(sr.ReadLine().Trim();elseif(s="0")sr.ReadLine();LwopolylineList.Add(newlw);returnelsesr.ReadLine();break;case"0":LwopolylineList

18、.Add(newlw);return;publicvoidReadSpline()SPLINEnewspline=newSPLINE();while(str1!="ENDSEC)"str=ReadPair();switch(str0)case"8":newspline.LName=str1;break;case"370":newspline.lwidth=str1;break;case"62":newspline.colornum=str1;break;case"70":newspline.Fl

19、ag=Int32.Parse(str1);break;case"74":newspline.Count=Int32.Parse(str1);newspline.throughpx=newdoubleInt32.Parse(str1);newspline.throughpy=break;newdoubleInt32.Parse(str1);case"12":newspline.SVertorX=break;case"22":newspline.SVertorY=break;case"13":newspline.EVe

20、rtorX=break;case"23":newspline.EVertorY=break;Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);Double.Parse(str1);case"11":newspline.throughpx0=Double.Parse(str1);str=ReadPair();newspline.throughpy0=str=ReadPair();Double.Parse(str1);for(inti=1;i<newspline.throughpx.Len

21、gth;i+)str=ReadPair();if(str0="11")newspline.throughpxi=Double.Parse(str1);i-;elseif(str0="21")newspline.throughpyi=i-;)if(newspline.Flag=11)(for(inti=0;i<3;i+)(str=ReadPair();)break;case"0":SplineList.Add(newspline);return;)publicvoidReadHeader()(while(str1!="E

22、NDSEQ"(str=ReadPair();switch(str1)(case"$EXTMINnstr=ReadPairQ;Double.Parse(str1);Double.Parse(str1);leftx=str=ReadPair();lefty=Double.Parse(str1);break;case"$EXTMAX"str=ReadPair();rightx=Double.Parse(str1);str=ReadPair();righty=Double.Parse(str1);break;)/打開(kāi)DX改件privatevoidbtOpen_C

23、lick(objectsender,EventArgse)btDraw.Enabled=false;LayerList.Clear();LineList.Clear();ArcList.Clear();EllipseList.Clear();LwopolylineList.Clear();SplineList.Clear();this.openFileDialogl.ShowDialogO;if(this.openFileDialogl.FileName.Trim()!="")fs =sr =Read();stringpath=this.openFileDialog1.FileName;newFileStream(path,FileMode.Open,FileAccess.Read);newStreamReader(fs);privatevoidbtDraw_Click(objectsender,EventArgse)Math.Ceiling(leftx) + 40;Math.Ceiling(lefty) + 40; int )height);doublewi

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論