C#讀取DXF文件_第1頁(yè)
C#讀取DXF文件_第2頁(yè)
C#讀取DXF文件_第3頁(yè)
C#讀取DXF文件_第4頁(yè)
C#讀取DXF文件_第5頁(yè)
已閱讀5頁(yè),還剩35頁(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、using System;using System.Collections.Generic;using System.ComponentModel;usingSystem.Data;using System.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;using System.Collections;namespacd)XFpublic partial classForml : Form精選范本privateFileStreamfs;privateStreamReadesr;privateArrayList

2、 LayerList = new Array List();privateArrayList LineList = new ArrayList();privateArrayList ArcList= new Array Li st();privateArrayList EllipseList = new ArrayList();privateArrayList LwopolylineList = new ArrayList();privateArrayList SplineList=new Array List();privatestring str = new string2;private

3、int count;privatedouble leftx;privatedouble lefty;privatedouble rightx;精選范本privatedouble righty;public Form 1()(lnitializeComponent();)privatestring ReadPair()(string code = sr.ReadLine().Trim();string codedata = sr.ReadLine().Trim();count += 2;string result = new string2 code, codedata;return resul

4、t;privatevoid Read()(while (sr.Peek() != -1)(str = ReadPair();if (str1 = SECTION)(str = ReadPair();switch (str1)(casdHEADER : ReadHeader();breaKcasdTABLES: ReadTable();breaKcasdENTITIES : ReadEntities();breaK)sr.Close();fs.Close();btDraw. Enabled =true;label 1.Text = count.ToString();count = 0;priva

5、tevoid ReadTableQ while (str1 != ENDSEC)(while (strO != 2 | str1 != LAYER)(str = ReadPair();)while (strO != 0 | str1 != LAYER)(str = ReadPair();)while (strO = 0 & str1 = LAYER)ReadLAYERQ;)while(str1 != ENDSEC)(str = ReadPair();)privatevoid ReadLAYER()(LAYER newlayer = new LAYER ();while (str1 != END

6、TAB)str = ReadPair();switch (strO)(case2: = str1;breaKcase62: newlayer.colornum = str1;breaKcase6: newlayer.lstyle = str1;breaKcase370: newlayer.lwidth = str1;breaK)if (strO = 0 & str1 = LAYER)LayerList.Add(newlayer);return;)LayerList.Add(newlayer);)privatevoid ReadEntities()(while (st

7、r1 != ENDSEC)caseLINE : ReadLine();breaKcaseARC: ReadArc();breaKcaseCIRCLE: ReadArc();breaKcaseELLIPSE: ReadEllipse();breaKcaseLWPOLYLINE : ReadLwpolyline();breaKcaseSPLINE: ReadSpline();breaKdefault str = ReadPair();breaK)privatevoid ReadArc()(ARC newarc =newARC();while (str1 != ENDSEC)(str = ReadP

8、air();switch (strO)case8: newarc.LName = str1;breaKcase 10: newarc.CenterX =Double. Parse(str1 );breaKcase20: newarc.CenterY =Double.Parse(str1);breaKcase40: newarc.Radiu =Double.Parse(str1);breaKcase50: newarc.SAngle =Double.Parse(str1);breaKcase51: newarc.EAngle =Double.Parse(str1);breaKcase370: n

9、ewarc.lwidth = str1;breaKcaseO: ArcList.Add(newarc);return;)privatevoid ReadLine()(LINE newline = new LINE ();while (str1 != ENDSEC)str = ReadPairQ;switch (strO) case8: newline.LName = str1;breaKcase 10: newline.StartX =Double.Parse(str1);breaKcase20: newline.StartY =Double.Parse(str1);breaKcase 11:

10、 newline.EndX = Double.Parse(str1);breaKcase21: newline.EndY = Double.Parse(str1 );breaKcase62: newline.colornum = str1;breaKcase370: newline.Iwidth = str1;breaKcaseO: LineList.Add(newline);return;)privatevoid ReadEllipse()(ELLIPSE newellipse =new ELLIPSE();while (str1 != ENDSEC)str = ReadPair();swi

11、tch (str0)case8: newellipse.LName = str1;break;case10: newellipse.CenterX =Double.Parse(str1);break;case20: newellipse.CenterY =Double.Parse(str1);break;case11: newellipse.DeltaX =Double.Parse(str1);break;case21: newellipse.DeltaY =Double.Parse(str1);break;case40: newellipse.Radio =Double.Parse(str1

12、);break;case41: newellipse.PSAngle =Double.Parse(str1);break;case42: newellipse.PEAngle =Double.Parse(str1);break;case370: newellipse.lwidth = str1;break;case0: EllipseList.Add(newellipse);return;精選范本privatevoid ReadLwpolylineQLWPOLYLINE newlw = newLWPOLYLINE ();while (str1 != ENDSEC)(str = ReadPair

13、();switch (strO)(case8: newlw.LName = str1;breaKcase370: newlw.Iwidth = str1;breaKcase62: newlw.colornum = str1;精選范本break;case90: newlw.PointCount =Int32.Parse(str1);break;case70: newlw.Flag =Int32.Parse(str1);break;case10: newlw.pointx = new doublenewlw.PointCount;newlw.pointy = new doublenewlw.Poi

14、ntCount;/if (newlw.Flag = 1)newlw.converxity =new doublenewlw.PointCount;/else/newlw.converxity = new doublenewlw.PointCount - 1;newlw.pointx0 = Double.Parse(str1);str=ReadPair();精選范本newlw.pointy0 = Double.Parse(str1);for (int i = 1; i newlw.PointCount; i+)string temp = sr.ReadLine().Trim();if (temp

15、 = 42)newlw.converxityi - 1 =Double.Parse(sr.ReadLine().Trim();i-;elseif (temp = 20)string r = sr.ReadLine().Trim();newlw.pointyi = Double.Parse(r);elsestring r = sr.ReadLine().Trim();newlw.pointxi = Double.Parse(r);i-;string s = sr.ReadLine().Trim();if (s = 42)newlw.converxitynewlw.PointCount - 1 =

16、Double.Parse(sr.ReadLine().Trim();elseif (s = 0)精選范本sr.ReadLine();LwopolylineList.Add(newlw);return;)elsesr.ReadLine();breaKcase0: LwopolylineList.Add(newlw);return;)publicvoid ReadSplineQ精選范本SPLINE newspline =newSPLINE();while (str1 != ENDSEC)(str = ReadPair();switch (strO)(case8: newspline.LName =

17、 str1;breaKcase370: newspline.Iwidth = str1;breaKcase62: newspline.colornum = str1;breaKcase70: newspline.Flag =lnt32.Parse(str1);break;case74: newspline.Count =Int32.Parse(str1);newspline.throughpx =newdoubleInt32.Parse(str1);newspline.throughpy =new doubleInt32.Parse(str1);break;case12: newspline.

18、SVertorX =Double.Parse(str1);break;case22: newspline.SVertorY =Double.Parse(str1);break;case13: newspline.EVertorX = Double.Parse(str1);break;case23: newspline.EVertorY =Double.Parse(str1);break;case11: newspline.throughpx0 =Double.Parse(str1);str = ReadPair();newspline.throughpy0 =Double.Parse(str1

19、);str = ReadPair();for(int i=1;inewspline.throughpx.Length;i+)str=ReadPair();if(str0= 11)newspline.throughpxi=Double.Parse(str1);i-;elseif(str0=21)newspline.throughpyi=Double.Parse(str1);i-;if(newspline.Flag=11)for(int i=0;i3;i+)str=ReadPair();break;精選范本caseO: SplineList.Add(newspline);return;)publi

20、cvoid ReadHeader()(while (str1 != ENDSEC)(str = ReadPair();switch (str1)case$EXTMIN : str = ReadPairQ;精選范本leftx = Double.Parse(str1);str = ReadPair();lefty = Double.Parse(str1);breaKcase$EXTMAX : str = ReadPair();rightx = Double.Parse(str1);str = ReadPair();righty = Double.Parse(str1);breaK)/打開(kāi)DXF文件

21、privatevoid btOpen_Click(objectsender,EventArgse) btDraw.Enabled 二 falseLayerList.Clear();LineList.Clear();ArcList.Clear();EllipseList.Clear();LwopolylineList.Clear();SplineList.Clear();this.openFileDialogl .ShowDialogO;if (this.openFileDialog1 .FileName.Trim() !-)(string path = this.openFileDialogl

22、 .FileName;fs = new FileStream(path, FileMode.Open, FileAccess.Read);sr = new StreamReade(frs);Read();privatevoid btDraw_Click(object sender,EventArgs e) double width = Math.Ceiling(rightx) -Math.Ceiling(leftx) + 40;double height = Math.Ceiling(righty) -Math.Ceiling(lefty) + 40;Bitmap bmp = newBitmap(int)width, (int)height);Graphics gx = Graphics.FromImage(bmp);double pw = width / ( dou

溫馨提示

  • 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)論