Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Quality Level to DataMatrix #268

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/BinaryKits.Zpl.Label/Elements/ZplDataMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,42 @@ public class ZplDataMatrix : ZplPositionedElementBase, IFormatElement
/// <param name="height"></param>
/// <param name="fieldOrientation"></param>
/// <param name="bottomToTop"></param>
/// <param name="qualityLevel"></param>
public ZplDataMatrix(
string content,
int positionX,
int positionY,
int height = 100,
FieldOrientation fieldOrientation = FieldOrientation.Normal,
bool bottomToTop = false
bool bottomToTop = false,
QualityLevel qualityLevel = QualityLevel.ECC0
)
: base(positionX, positionY, bottomToTop)
{
Content = content;
FieldOrientation = fieldOrientation;
Height = height;
QualityLevel = qualityLevel;
}

public int Height { get; protected set; }

public FieldOrientation FieldOrientation { get; protected set; }

public QualityLevel QualityLevel { get; protected set; }

public string Content { get; protected set; }

protected string RenderFieldOrientation()
{
return RenderFieldOrientation(FieldOrientation);
}

protected string RenderQualityLevel()
{
return RenderQualityLevel(QualityLevel);
}

///<inheritdoc/>
public override IEnumerable<string> Render(ZplRenderOptions context)
{
Expand All @@ -50,7 +60,7 @@ public override IEnumerable<string> Render(ZplRenderOptions context)
//^FDZEBRA TECHNOLOGIES CORPORATION ^ FS
var result = new List<string>();
result.AddRange(RenderPosition(context));
result.Add($"^BX{RenderFieldOrientation()},{context.Scale(Height)}");
result.Add($"^BX{RenderFieldOrientation()},{context.Scale(Height)},{RenderQualityLevel()}");
result.Add($"^FD{Content}^FS");

return result;
Expand Down
21 changes: 21 additions & 0 deletions src/BinaryKits.Zpl.Label/Elements/ZplElementBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ public string RenderFieldOrientation(FieldOrientation fieldOrientation)
throw new NotImplementedException("Unknown Field Orientation");
}

public string RenderQualityLevel(QualityLevel qualityLevel)
{
switch (qualityLevel)
{
case QualityLevel.ECC0:
return "0";
case QualityLevel.ECC50:
return "50";
case QualityLevel.ECC80:
return "80";
case QualityLevel.ECC100:
return "100";
case QualityLevel.ECC140:
return "140";
case QualityLevel.ECC200:
return "200";
}

throw new NotImplementedException("Unknown Quality Level");
}

public string RenderFieldJustification(FieldJustification fieldJustification)
{
switch (fieldJustification)
Expand Down
33 changes: 33 additions & 0 deletions src/BinaryKits.Zpl.Label/QualityLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace BinaryKits.Zpl.Label
{
/// <summary>
/// Quality Level
/// </summary>
public enum QualityLevel
{
/// <summary>
/// ECC Value of 0
/// </summary>
ECC0,
/// <summary>
/// ECC Value of 50
/// </summary>
ECC50,
/// <summary>
/// ECC Value of 80
/// </summary>
ECC80,
/// <summary>
/// ECC Value of 100
/// </summary>
ECC100,
/// <summary>
/// ECC Value of 140
/// </summary>
ECC140,
/// <summary>
/// ECC Value of 200
/// </summary>
ECC200
}
}