Skip to content

Commit fe443af

Browse files
authored
Merge pull request #306 from BinaryKits/develop
Merge develop into master
2 parents a11ccd5 + da996ee commit fe443af

File tree

186 files changed

+4888
-1375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+4888
-1375
lines changed

.gitattributes

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# 2011
2-
src/BinaryKits.Zpl.Label.UnitTest/ZplData/*.txt text eol=lf
1+
* text=auto
2+
src/BinaryKits.Zpl.Label.UnitTest/ZplData/*.txt text eol=lf
3+
*.png binary

.github/workflows/deploy_binarykits-zpl-viewer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up .NET Core
2323
uses: actions/setup-dotnet@v1
2424
with:
25-
dotnet-version: '6.0.x'
25+
dotnet-version: '8.0.x'
2626

2727
- name: Build with dotnet
2828
working-directory: ./src/BinaryKits.Zpl.Viewer.WebApi

.github/workflows/dotnet - test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Setup .NET 6.0
16+
- name: Setup .NET 8.0
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 6.0.x
19+
dotnet-version: 8.0.x
2020
- name: Restore dependencies
2121
working-directory: ./src
2222
run: dotnet restore
@@ -33,10 +33,10 @@ jobs:
3333

3434
steps:
3535
- uses: actions/checkout@v2
36-
- name: Setup .NET 6.0
36+
- name: Setup .NET 8.0
3737
uses: actions/setup-dotnet@v1
3838
with:
39-
dotnet-version: 6.0.x
39+
dotnet-version: 8.0.x
4040
- name: Restore dependencies
4141
working-directory: ./src
4242
run: dotnet restore

.github/workflows/dotnet.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Setup .NET 6.0
16+
- name: Setup .NET 8.0
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 6.0.x
19+
dotnet-version: 8.0.x
2020
- name: Restore dependencies
2121
working-directory: ./src
2222
run: dotnet restore
@@ -33,10 +33,10 @@ jobs:
3333

3434
steps:
3535
- uses: actions/checkout@v2
36-
- name: Setup .NET 6.0
36+
- name: Setup .NET 8.0
3737
uses: actions/setup-dotnet@v1
3838
with:
39-
dotnet-version: 6.0.x
39+
dotnet-version: 8.0.x
4040
- name: Restore dependencies
4141
working-directory: ./src
4242
run: dotnet restore

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,4 @@ foreach (var labelInfo in analyzeInfo.LabelInfos)
307307
| JavaScript | [JSZPL](https://github.com/DanieLeeuwner/JSZPL) |
308308
| .NET | [sharpzebra](https://github.com/rkone/sharpzebra) |
309309
| .NET | [PDFtoZPL](https://github.com/sungaila/PDFtoZPL) |
310+
| .NET | [ZPL2PDF](https://github.com/brunoleocam/ZPL2PDF) |

src/.editorconfig

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ csharp_new_line_before_else = true
2828
csharp_new_line_before_members_in_object_initializers = true
2929
#require braces to be on a new line for methods, object_collection_array_initializers, control_blocks, and types (also known as "Allman" style)
3030
csharp_new_line_before_open_brace = methods, object_collection_array_initializers, control_blocks, types
31+
dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion
32+
dotnet_style_allow_statement_immediately_after_block_experimental = false:suggestion
3133

3234
#Formatting - organize using options
3335

@@ -81,15 +83,16 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
8183

8284
#prefer objects to be initialized using object initializers when possible
8385
dotnet_style_object_initializer = true:suggestion
86+
dotnet_style_prefer_collection_expression = when_types_exactly_match
8487

8588
#Style - implicit and explicit types
8689

8790
#prefer var over explicit type in all cases, unless overridden by another code style rule
88-
csharp_style_var_elsewhere = true:suggestion
91+
csharp_style_var_elsewhere = false:warning
8992
#prefer var is used to declare variables with built-in system types such as int
90-
csharp_style_var_for_built_in_types = true:suggestion
93+
csharp_style_var_for_built_in_types = false:warning
9194
#prefer var when the type is already mentioned on the right-hand side of a declaration expression
92-
csharp_style_var_when_type_is_apparent = true:suggestion
95+
csharp_style_var_when_type_is_apparent = false:warning
9396

9497
#Style - language keyword and framework type options
9598

@@ -104,7 +107,7 @@ dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggest
104107
#Style - Modifier preferences
105108

106109
#when this rule is set to a list of modifiers, prefer the specified ordering.
107-
csharp_preferred_modifier_order = public,private,protected,override,readonly,static,abstract:suggestion
110+
csharp_preferred_modifier_order = public,private,protected,internal,override,static,abstract,readonly:suggestion
108111

109112
#Style - Pattern matching
110113

@@ -113,9 +116,11 @@ csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
113116

114117
#Style - qualification options
115118

116-
#prefer fields not to be prefaced with this. or Me. in Visual Basic
117-
dotnet_style_qualification_for_field = false:suggestion
119+
#prefer fields to be prefaced with this. or Me. in Visual Basic
120+
dotnet_style_qualification_for_field = true:suggestion
118121
#prefer methods to be prefaced with this. in C# or Me. in Visual Basic
119122
dotnet_style_qualification_for_method = true:suggestion
120123
#prefer properties to be prefaced with this. in C# or Me. in Visual Basic
121124
dotnet_style_qualification_for_property = true:suggestion
125+
126+
csharp_style_prefer_primary_constructors = false:suggestion

src/BinaryKits.Zpl.Label.UnitTest/BarcodeTest.cs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void Barcode39()
2121

2222
Debug.WriteLine(output);
2323
Assert.IsNotNull(output);
24-
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,100\n^BY2,3\n^B3N,N,100,Y,N\n^FD123ABC^FS\n^XZ", output);
24+
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,100\n^BY2,3\n^B3N,N,100,Y,N\n^FD123ABC^FS\n^XZ", output);
2525
}
2626

2727
[TestMethod]
@@ -37,7 +37,7 @@ public void Barcode93()
3737

3838
Debug.WriteLine(output);
3939
Assert.IsNotNull(output);
40-
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,300\n^BY2,3\n^BAN,100,Y,N,N\n^FD123ABC^FS\n^XZ", output);
40+
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BY2,3\n^BAN,100,Y,N,N\n^FD123ABC^FS\n^XZ", output);
4141
}
4242

4343
[TestMethod]
@@ -53,7 +53,7 @@ public void Barcode128()
5353

5454
Debug.WriteLine(output);
5555
Assert.IsNotNull(output);
56-
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,300\n^BY2,3\n^BCN,100,Y,N\n^FD123ABC^FS\n^XZ", output);
56+
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BY2,3\n^BCN,100,Y,N\n^FD123ABC^FS\n^XZ", output);
5757
}
5858

5959
[TestMethod]
@@ -69,7 +69,39 @@ public void BarcodeEan13()
6969

7070
Debug.WriteLine(output);
7171
Assert.IsNotNull(output);
72-
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n\n^FO100,300\n^BY2,3\n^BEN,100,Y,N\n^FD123456^FS\n^XZ", output);
72+
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BY2,3\n^BEN,100,Y,N\n^FD123456^FS\n^XZ", output);
73+
}
74+
75+
[TestMethod]
76+
public void DataMatrixDefault()
77+
{
78+
var elements = new List<ZplElementBase>
79+
{
80+
new ZplDataMatrix("123ABC", 100, 300)
81+
};
82+
83+
var renderEngine = new ZplEngine(elements);
84+
var output = renderEngine.ToZplString(new ZplRenderOptions { AddEmptyLineBeforeElementStart = true });
85+
86+
Debug.WriteLine(output);
87+
Assert.IsNotNull(output);
88+
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BXN,100,0\n^FD123ABC^FS\n^XZ", output);
89+
}
90+
91+
[TestMethod]
92+
public void DataMatrix200()
93+
{
94+
var elements = new List<ZplElementBase>
95+
{
96+
new ZplDataMatrix("123ABC", 100, 300, qualityLevel: QualityLevel.ECC200)
97+
};
98+
99+
var renderEngine = new ZplEngine(elements);
100+
var output = renderEngine.ToZplString(new ZplRenderOptions { AddEmptyLineBeforeElementStart = true });
101+
102+
Debug.WriteLine(output);
103+
Assert.IsNotNull(output);
104+
Assert.AreEqual("^XA\n^LH0,0\n\n^FO100,300\n^BXN,100,200\n^FD123ABC^FS\n^XZ", output);
73105
}
74106
}
75107
}

src/BinaryKits.Zpl.Label.UnitTest/BinaryKits.Zpl.Label.UnitTest.csproj

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
5-
4+
<TargetFramework Condition="$([MSBuild]::IsOSPlatform('Linux'))">net8.0</TargetFramework>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">net472;net8.0</TargetFrameworks>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
13-
<PackageReference Include="coverlet.collector" Version="3.1.2">
14-
<PrivateAssets>all</PrivateAssets>
15-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16-
</PackageReference>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="4.0.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="4.0.1" />
1713
</ItemGroup>
1814

1915
<ItemGroup>
@@ -27,6 +23,9 @@
2723
<None Update="ZplData\DownloadGraphicsB64.txt">
2824
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2925
</None>
26+
<None Update="ZplData\DownloadGraphicsZ64_net472.txt">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</None>
3029
<None Update="ZplData\DownloadGraphicsZ64.txt">
3130
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3231
</None>

src/BinaryKits.Zpl.Label.UnitTest/DownloadTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void DownloadGraphicsACS()
4141
[TestMethod]
4242
[DeploymentItem(@"ZplData/Zpl.png")]
4343
[DeploymentItem(@"ZplData/DownloadGraphicsZ64.txt")]
44+
[DeploymentItem(@"ZplData/DownloadGraphicsZ64_net472.txt")]
4445
public void DownloadGraphicsZ64()
4546
{
4647
var imageData = File.ReadAllBytes("Zpl.png");
@@ -63,7 +64,11 @@ public void DownloadGraphicsZ64()
6364
Debug.WriteLine(output);
6465
Assert.IsNotNull(output);
6566

67+
#if NET5_0_OR_GREATER
6668
var zplData = File.ReadAllText("DownloadGraphicsZ64.txt");
69+
#else
70+
var zplData = File.ReadAllText("DownloadGraphicsZ64_net472.txt");
71+
#endif
6772
Assert.AreEqual(zplData, output);
6873
}
6974
[TestMethod]

src/BinaryKits.Zpl.Label.UnitTest/EngineTest.cs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void ChangeDPI()
5454

5555
Debug.WriteLine(output);
5656
Assert.IsNotNull(output);
57-
Assert.AreEqual("^XA\n^LH0,0\n^CI28\n^FO591,1034\n^GB147,147,7,B,0^FS\n^XZ", output);
57+
Assert.AreEqual("^XA\n^LH0,0\n^FO591,1034\n^GB147,147,7,B,0^FS\n^XZ", output);
5858
}
5959

6060
[TestMethod]
@@ -102,9 +102,9 @@ public void TextFieldVariations()
102102

103103
var elements = new List<ZplElementBase>();
104104
//Specail character is repalced with space
105-
elements.Add(new ZplTextField(sampleText, 10, 10, font, useHexadecimalIndicator: false));
105+
elements.Add(new ZplTextField(sampleText, 10, 10, font, hexadecimalIndicator: null));
106106
//Specail character is using Hex value ^FH
107-
elements.Add(new ZplTextField(sampleText, 10, 50, font, useHexadecimalIndicator: true));
107+
elements.Add(new ZplTextField(sampleText, 10, 50, font, hexadecimalIndicator: '_'));
108108
//Only the first line is displayed
109109
elements.Add(new ZplSingleLineFieldBlock(sampleText, 10, 150, 500, font));
110110
//Max 2 lines, text exceeding the maximum number of lines overwrites the last line.
@@ -132,7 +132,41 @@ public void WithoutAutoElements()
132132

133133
Debug.WriteLine(output);
134134
Assert.IsNotNull(output);
135-
Assert.AreEqual("^CI28\n^FX\n//A important field\n^A0N,30,30\n^FO50,100\n^FH^FDPure element zpl only^FS", output);
135+
Assert.AreEqual("^FX\n//A important field\n^A0N,30,30\n^FO50,100\n^FDPure element zpl only^FS", output);
136+
}
137+
138+
[TestMethod]
139+
public void ChangeInternationalFont()
140+
{
141+
var elements = new List<ZplElementBase>() {
142+
new ZplChangeInternationalFont(InternationalFont.ZCP1252),
143+
new ZplTextField("Straße", 10, 10, ZplConstants.Font.Default, hexadecimalIndicator: '_'),
144+
};
145+
146+
var renderEngine = new ZplEngine(elements);
147+
var output = renderEngine.ToZplString(new ZplRenderOptions());
148+
149+
Debug.WriteLine(output);
150+
Assert.IsNotNull(output);
151+
//TODO: escape non-ascii characters according to current charset if hexIndicator is given
152+
Assert.AreEqual("^XA\n^LH0,0\n^CI27\n^A0N,30,30\n^FO10,10\n^FH^FDStraße^FS\n^XZ", output);
153+
}
154+
155+
[TestMethod]
156+
public void FieldTypesetDefaultPosition()
157+
{
158+
var elements = new List<ZplElementBase>() {
159+
new ZplTextField("ACME ", 10, 200, new ZplFont(30, 20, "0"), bottomToTop: true),
160+
new ZplTextField("Summer ", 0, 0, new ZplFont(30, 20, "0"), bottomToTop: true, useDefaultPosition: true),
161+
new ZplTextField("Clearance ", 0, 0, new ZplFont(60, 50, "0"), bottomToTop: true, useDefaultPosition: true),
162+
new ZplTextField("Sale ", 0, 0, new ZplFont(120, 100, "0"), bottomToTop: true, useDefaultPosition: true)
163+
};
164+
165+
var renderEngine = new ZplEngine(elements);
166+
var output = renderEngine.ToZplString(new ZplRenderOptions());
167+
168+
Debug.WriteLine(output);
169+
Assert.AreEqual("^XA\n^LH0,0\n^A0N,20,30\n^FT10,200\n^FDACME ^FS\n^A0N,20,30\n^FT\n^FDSummer ^FS\n^A0N,50,60\n^FT\n^FDClearance ^FS\n^A0N,100,120\n^FT\n^FDSale ^FS\n^XZ", output);
136170
}
137171
}
138172
}

0 commit comments

Comments
 (0)