Skip to content

Commit 6817787

Browse files
committed
Initial commit
0 parents  commit 6817787

31 files changed

+1118
-0
lines changed

AssemblyInfo.cs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
//
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
//
9+
[assembly: AssemblyTitle("")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("")]
14+
[assembly: AssemblyCopyright("")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
18+
//
19+
// Version information for an assembly consists of the following four values:
20+
//
21+
// Major Version
22+
// Minor Version
23+
// Build Number
24+
// Revision
25+
//
26+
// You can specify all the values or you can default the Revision and Build Numbers
27+
// by using the '*' as shown below:
28+
29+
[assembly: AssemblyVersion("1.0.*")]
30+
31+
//
32+
// In order to sign your assembly you must specify a key to use. Refer to the
33+
// Microsoft .NET Framework documentation for more information on assembly signing.
34+
//
35+
// Use the attributes below to control which key is used for signing.
36+
//
37+
// Notes:
38+
// (*) If no key is specified, the assembly is not signed.
39+
// (*) KeyName refers to a key that has been installed in the Crypto Service
40+
// Provider (CSP) on your machine. KeyFile refers to a file which contains
41+
// a key.
42+
// (*) If the KeyFile and the KeyName values are both specified, the
43+
// following processing occurs:
44+
// (1) If the KeyName can be found in the CSP, that key is used.
45+
// (2) If the KeyName does not exist and the KeyFile does exist, the key
46+
// in the KeyFile is installed into the CSP and used.
47+
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
48+
// When specifying the KeyFile, the location of the KeyFile should be
49+
// relative to the project output directory which is
50+
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
51+
// located in the project directory, you would specify the AssemblyKeyFile
52+
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
53+
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
54+
// documentation for more information on this.
55+
//
56+
[assembly: AssemblyDelaySign(false)]
57+
[assembly: AssemblyKeyFile("")]
58+
[assembly: AssemblyKeyName("")]

Block.cs

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
using System;
2+
3+
namespace DXFLibrary
4+
{
5+
/// <summary>
6+
/// A dxf BLOCK element.
7+
/// </summary>
8+
public class Block : DXFLibrary.Element
9+
{
10+
/// <summary>
11+
/// Constructor for block
12+
/// </summary>
13+
public Block():base()
14+
{
15+
this.dataAcceptanceList.AddRange(new int[14]
16+
{ 0, 5, 102, 330, 100, 8, 70,10 ,20 ,30 ,3, 1, 4, 2});
17+
this.startTag = new Data(0,"BLOCK");
18+
}
19+
/// <summary>
20+
/// Used to create an BLOCK with user dxf code.
21+
/// </summary>
22+
/// <param name="s">Contains the DXF code that will be writen directly to the dxf file</param>
23+
public Block(string s):base(s)
24+
{
25+
}
26+
public void SetEndBlk(EndBlk eb)
27+
{
28+
if(this.elements.Count>0&&((Element)this.elements[this.elements.Count-1]).Name == "ENDBLK")
29+
{
30+
this.elements.RemoveAt(this.data.Count-1);
31+
}
32+
this.elements.Add(eb);
33+
}
34+
/// <summary>
35+
/// Add an dxf entity to a BLOCK
36+
/// </summary>
37+
/// <param name="e">The added entity</param>
38+
public void AddEntity(Entity e)
39+
{
40+
if(this.data.Count==0) this.elements.Add(e);
41+
else this.elements.Insert(this.elements.Count-1,e);
42+
}
43+
/// <summary>
44+
/// Specifies the layer for the block.
45+
/// </summary>
46+
/// <param name="l"></param>
47+
public void SetLayer(string l)
48+
{
49+
int ind = this.GetIndexFor(8);
50+
if(ind>-1)
51+
{
52+
this.data.RemoveAt(ind);
53+
this.data.Insert(ind,new Data(8,l));
54+
}
55+
else
56+
this.data.Add(new Data(8,l));
57+
}
58+
public void SetPosition(double x, double y, double z)
59+
{
60+
Data dx,dy,dz;
61+
bool swx = false,swy = false,swz = false;
62+
foreach(Data d in this.data)
63+
{
64+
if(d.code==10)
65+
{
66+
dx = d;
67+
swx = true;
68+
}
69+
if(d.code==20)
70+
{
71+
dy = d;
72+
swy=true;
73+
}
74+
if(d.code==30)
75+
{
76+
dz = d;
77+
swz = true;
78+
}
79+
}
80+
if(swx) dx.data = x;
81+
else
82+
{
83+
dx.code = 10;
84+
dx.data = x;
85+
this.data.Add(dx);
86+
}
87+
if(swy) dy.data = y;
88+
else
89+
{
90+
dy.code = 20;
91+
dy.data = y;
92+
this.data.Add(dy);
93+
}
94+
if(swz) dz.data = z;
95+
else
96+
{
97+
dy.code = 30;
98+
dy.data = y;
99+
this.data.Add(dy);
100+
}
101+
}
102+
/// <summary>
103+
/// Sets the block name.
104+
/// </summary>
105+
/// <param name="name">Contains the name.</param>
106+
public void SetName(string name)
107+
{
108+
this.AddReplace(2,name);
109+
}
110+
/// <summary>
111+
/// Sets the handle for the block.
112+
/// </summary>
113+
/// <param name="handle">The handle value</param>
114+
public void SetHandle(string handle)
115+
{
116+
this.AddReplace(5,handle);
117+
}
118+
public void SetFlag(short flag)
119+
{
120+
this.AddReplace(70,flag);
121+
}
122+
}
123+
}

Blocks.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
3+
namespace DXFLibrary
4+
{
5+
/// <summary>
6+
/// The representation of BLOCKS section
7+
/// </summary>
8+
public class Blocks : DXFLibrary.Section
9+
{
10+
public Blocks():base("BLOCKS")
11+
{
12+
//
13+
// TODO: Add constructor logic here
14+
//
15+
}
16+
public Blocks(string s):base(s,true)
17+
{
18+
}
19+
public void addBlock(Block b)
20+
{
21+
this.elements.Add(b);
22+
}
23+
}
24+
}

Circle.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
3+
namespace DXFLibrary
4+
{
5+
/// <summary>
6+
///
7+
/// </summary>
8+
public class Circle : DXFLibrary.Entity
9+
{
10+
public Circle(double x, double y, double radius, string layer):base("CIRCLE",layer)
11+
{
12+
this.dataAcceptanceList.AddRange(new int[] { 39, 10, 20, 30, 40, 210, 220, 230 });
13+
this.AddReplace(10,x);
14+
this.AddReplace(20,y);
15+
this.AddReplace(40,radius);
16+
}
17+
}
18+
}

Data.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace DXFLibrary
2+
{
3+
/// <summary>
4+
/// The smallest but the most used part of C#DXFLibrary. It represents a piece of data in a dxf file.
5+
/// It contains a dxf code and an information ( string, int,... )
6+
/// </summary>
7+
public struct Data
8+
{
9+
public int code;
10+
public object data;
11+
public Data(int code, object data)
12+
{
13+
this.code = code;
14+
this.data = data;
15+
}
16+
}
17+
}

Document.cs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections;
3+
4+
namespace DXFLibrary
5+
{
6+
/// <summary>
7+
/// The representation of a dxf document.
8+
/// </summary>
9+
public class Document
10+
{
11+
internal Header header;
12+
internal Entities entities;
13+
internal Blocks blocks;
14+
internal Tables tables;
15+
public Document()
16+
{
17+
this.entities = new Entities();
18+
}
19+
public void SetHeader(Header h)
20+
{
21+
this.header = h;
22+
}
23+
public void SetEntities(Entities e)
24+
{
25+
this.entities = e;
26+
}
27+
public void SetBlocks(Blocks b)
28+
{
29+
this.blocks = b;
30+
}
31+
public void SetTables(Tables t)
32+
{
33+
this.tables = t;
34+
}
35+
public void add(Entity e)
36+
{
37+
this.entities.AddEntity(e);
38+
}
39+
public void add(Block b)
40+
{
41+
this.blocks.addBlock(b);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)