-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathBlock.cs
57 lines (49 loc) · 1.79 KB
/
Block.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
namespace BppLib.CIDFile
{
///<summary>Class <c>Block</c> represents the block of the CID program.</summary>
public class Block : IBlock
{
/// <value>Property <c>Name</c> represents the name of the block.</value>
public string Name {get; set;} = "WRK";
/// <value>Property <c>Side</c> represents the piece side.</value>
public int Side {get; set;} = 0;
public string Color {get; set;} = "LIGHT_GREEN";
public bool Visibility = true;
public List<IBlock> Operations = new List<IBlock>();
/// <summary>This method serializes an object as Cid code.</summary>
/// <returns>A string is coded as Cid code.</returns>
public string AsCidCode()
{
StringBuilder sb = new StringBuilder();
foreach(var item in Operations)
{
sb.AppendLine(item.AsCidCode());
}
return sb.ToString();
}
/// <summary>This method serializes an object as Cid block.</summary>
/// <returns>A string is coded as Cid block.</returns>
public string AsCidBlock()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("BEGIN BLOCK");
sb.AppendLine(" NAME=" + Name);
sb.AppendLine(" SIDE=" + Side.ToString());
sb.AppendLine(" COLOR=" + Color);
if (Visibility)
{sb.AppendLine(" VISIBILITY=YES");}
else
{sb.AppendLine(" VISIBILITY=NO");}
foreach(var item in Operations)
{
sb.AppendLine(item.AsCidCode());
}
sb.Append("END BLOCK");
return sb.ToString();
}
}
}