Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
PrintLabel
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 9a23782e
由
刘韬
编写于
2023-12-01 13:10:26 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
添加TSC打印参数设置
1 个父辈
31f50a5d
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
125 行增加
和
48 行删除
PrintLabel/LabelPrint.cs
PrintLabel/Model.cs
PrintLabel/PrintLabel.cs
PrintLabel/PrintLabel.csproj
PrintLabel/packages.config
PrintLabel_Test/Form1.Designer.cs
PrintLabel_Test/Form1.cs
PrintLabel/LabelPrint.cs
查看文件 @
9a23782
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Drawing.Printing
;
using
System.Drawing.Printing
;
using
System.Threading
;
using
System.Threading
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
...
@@ -245,6 +246,7 @@ namespace BLL
...
@@ -245,6 +246,7 @@ namespace BLL
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
throw
ex
;
}
}
}
}
}
}
...
@@ -467,13 +469,14 @@ namespace BLL
...
@@ -467,13 +469,14 @@ namespace BLL
using
(
PrintDialog
dlg
=
new
PrintDialog
())
using
(
PrintDialog
dlg
=
new
PrintDialog
())
{
{
PrinterSettings
printerSettings
=
new
PrinterSettings
();
PrinterSettings
printerSettings
=
new
PrinterSettings
();
dlg
.
PrinterSettings
.
DefaultPageSettings
.
PaperSize
=
new
PaperSize
(
"C"
,
236
,
157
);
dlg
.
PrinterSettings
.
DefaultPageSettings
.
PaperSize
=
new
PaperSize
(
"C"
,
(
int
)(
Common
.
Label
[
labelIdx
].
Size_mm
.
Width
*
4.11
),
(
int
)(
Common
.
Label
[
labelIdx
].
Size_mm
.
Height
*
4.11
));
if
(
dlg
.
ShowDialog
()
!=
DialogResult
.
OK
)
return
;
//dlg.PrinterSettings.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
System
.
Drawing
.
Printing
.
PrintDocument
print
=
new
System
.
Drawing
.
Printing
.
PrintDocument
{
dlg
.
PrinterSettings
.
DefaultPageSettings
.
PrinterSettings
.
PrinterResolutions
.
Add
(
new
PrinterResolution
{
Kind
=
PrinterResolutionKind
.
High
});
if
(
dlg
.
ShowDialog
()
!=
DialogResult
.
OK
)
return
;
PrintDocument
print
=
new
PrintDocument
{
PrinterSettings
=
dlg
.
PrinterSettings
PrinterSettings
=
dlg
.
PrinterSettings
};
};
//print.PrinterSettings.DefaultPageSettings.Color = false;
print
.
PrintPage
+=
PrintTest_PrintPage
;
print
.
PrintPage
+=
PrintTest_PrintPage
;
print
.
DefaultPageSettings
.
Landscape
=
dlg
.
PrinterSettings
.
DefaultPageSettings
.
Landscape
;
print
.
DefaultPageSettings
.
Landscape
=
dlg
.
PrinterSettings
.
DefaultPageSettings
.
Landscape
;
print
.
Print
();
print
.
Print
();
...
@@ -889,6 +892,8 @@ namespace BLL
...
@@ -889,6 +892,8 @@ namespace BLL
private
void
PrintTest_PrintPage
(
object
sender
,
System
.
Drawing
.
Printing
.
PrintPageEventArgs
e
)
private
void
PrintTest_PrintPage
(
object
sender
,
System
.
Drawing
.
Printing
.
PrintPageEventArgs
e
)
{
{
e
.
Graphics
.
SmoothingMode
=
System
.
Drawing
.
Drawing2D
.
SmoothingMode
.
None
;
e
.
Graphics
.
InterpolationMode
=
InterpolationMode
.
NearestNeighbor
;
for
(
int
i
=
0
;
i
<
Common
.
Label
[
labelIdx
].
Field
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
Common
.
Label
[
labelIdx
].
Field
.
Count
;
i
++)
{
{
Model
.
ClsLabelField
field
=
Common
.
Label
[
labelIdx
].
Field
[
i
];
Model
.
ClsLabelField
field
=
Common
.
Label
[
labelIdx
].
Field
[
i
];
...
...
PrintLabel/Model.cs
查看文件 @
9a23782
...
@@ -267,6 +267,7 @@ namespace Model
...
@@ -267,6 +267,7 @@ namespace Model
if
(
Type
==
LabelFieldType
.
Text
)
return
;
if
(
Type
==
LabelFieldType
.
Text
)
return
;
ZXing
.
BarcodeWriter
writer
=
new
ZXing
.
BarcodeWriter
();
ZXing
.
BarcodeWriter
writer
=
new
ZXing
.
BarcodeWriter
();
writer
.
Options
.
Height
=
(
int
)
300
/
2
;
ZXing
.
QrCode
.
QrCodeEncodingOptions
qrCodeEncodingOptions
=
new
ZXing
.
QrCode
.
QrCodeEncodingOptions
()
ZXing
.
QrCode
.
QrCodeEncodingOptions
qrCodeEncodingOptions
=
new
ZXing
.
QrCode
.
QrCodeEncodingOptions
()
{
{
DisableECI
=
true
,
DisableECI
=
true
,
...
@@ -340,6 +341,10 @@ namespace Model
...
@@ -340,6 +341,10 @@ namespace Model
if
(
Type
==
LabelFieldType
.
Text
)
return
;
if
(
Type
==
LabelFieldType
.
Text
)
return
;
ZXing
.
BarcodeWriter
writer
=
new
ZXing
.
BarcodeWriter
();
ZXing
.
BarcodeWriter
writer
=
new
ZXing
.
BarcodeWriter
();
writer
.
Options
.
Height
=
(
int
)
size
.
Height
*
1
;
writer
.
Options
.
Width
=
(
int
)
size
.
Width
*
1
;
writer
.
Options
.
NoPadding
=
true
;
writer
.
Options
.
Margin
=
0
;
ZXing
.
QrCode
.
QrCodeEncodingOptions
qrCodeEncodingOptions
=
new
ZXing
.
QrCode
.
QrCodeEncodingOptions
()
ZXing
.
QrCode
.
QrCodeEncodingOptions
qrCodeEncodingOptions
=
new
ZXing
.
QrCode
.
QrCodeEncodingOptions
()
{
{
DisableECI
=
true
,
DisableECI
=
true
,
...
@@ -347,6 +352,7 @@ namespace Model
...
@@ -347,6 +352,7 @@ namespace Model
Width
=
(
int
)
size
.
Width
,
Width
=
(
int
)
size
.
Width
,
Height
=
(
int
)
size
.
Width
,
Height
=
(
int
)
size
.
Width
,
Margin
=
1
,
Margin
=
1
,
NoPadding
=
true
,
PureBarcode
=
true
PureBarcode
=
true
};
};
ZXing
.
PDF417
.
PDF417EncodingOptions
pDF417EncodingOptions
=
new
ZXing
.
PDF417
.
PDF417EncodingOptions
()
ZXing
.
PDF417
.
PDF417EncodingOptions
pDF417EncodingOptions
=
new
ZXing
.
PDF417
.
PDF417EncodingOptions
()
...
@@ -366,20 +372,22 @@ namespace Model
...
@@ -366,20 +372,22 @@ namespace Model
writer
.
Options
.
PureBarcode
=
true
;
writer
.
Options
.
PureBarcode
=
true
;
//writer.Options.Margin = 0;
//writer.Options.Margin = 0;
//writer.Options.Height = (int)size.Height;
//writer.Options.Height = (int)size.Height;
writer
.
Options
.
Width
=
(
int
)
size
.
Width
;
switch
(
Type
)
switch
(
Type
)
{
{
case
LabelFieldType
.
Code39
:
case
LabelFieldType
.
Code39
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_39
;
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_39
;
writer
.
Options
.
NoPadding
=
true
;
Image
=
writer
.
Write
(
content
);
Image
=
writer
.
Write
(
content
);
break
;
break
;
case
LabelFieldType
.
Code93
:
case
LabelFieldType
.
Code93
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_93
;
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_93
;
writer
.
Options
.
NoPadding
=
true
;
Image
=
writer
.
Write
(
content
);
Image
=
writer
.
Write
(
content
);
break
;
break
;
case
LabelFieldType
.
Code128
:
case
LabelFieldType
.
Code128
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_128
;
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_128
;
writer
.
Options
.
NoPadding
=
true
;
Image
=
writer
.
Write
(
content
);
Image
=
writer
.
Write
(
content
);
break
;
break
;
case
LabelFieldType
.
DataMatrix
:
case
LabelFieldType
.
DataMatrix
:
...
...
PrintLabel/PrintLabel.cs
查看文件 @
9a23782
...
@@ -28,7 +28,6 @@ namespace Asa
...
@@ -28,7 +28,6 @@ namespace Asa
Common
.
LabelPrint
=
new
BLL
.
LabelPrint
();
Common
.
LabelPrint
=
new
BLL
.
LabelPrint
();
this
.
dir
=
dir
;
this
.
dir
=
dir
;
Common
.
LabelPrint
.
Load
(
dir
);
Common
.
LabelPrint
.
Load
(
dir
);
}
}
/// <summary>
/// <summary>
...
@@ -309,15 +308,15 @@ namespace Asa
...
@@ -309,15 +308,15 @@ namespace Asa
/// </summary>
/// </summary>
/// <param name="key"></param>
/// <param name="key"></param>
/// <returns>是否打印成功</returns>
/// <returns>是否打印成功</returns>
public
bool
PrintToTsc1
(
Dictionary
<
string
,
string
>
key
,
out
TscStauts
tscStauts
)
public
bool
PrintToTsc1
(
Dictionary
<
string
,
string
>
key
,
TscConfig
tscConfig
,
out
TscStauts
tscStauts
)
{
{
tscStauts
=
CheckTscStatus
();
//
tscStauts = CheckTscStatus();
if
(
tscStauts
!=
0
)
//
if (tscStauts != 0)
{
//
{
var
err
=
(
TscStauts
)
tscStauts
;
//
var err = (TscStauts)tscStauts;
Console
.
WriteLine
(
$
"Error: {err}"
);
//
Console.WriteLine($"Error: {err}");
return
false
;
//
return false;
}
//
}
var
t
=
Task
.
Run
(()
=>
var
t
=
Task
.
Run
(()
=>
{
{
Bitmap
bmp
=
null
;
Bitmap
bmp
=
null
;
...
@@ -328,26 +327,26 @@ namespace Asa
...
@@ -328,26 +327,26 @@ namespace Asa
var
nn
=
Common
.
PxToMM
(
bmp
.
Height
);
var
nn
=
Common
.
PxToMM
(
bmp
.
Height
);
TSCSDK
.
driver
TSCLIB_DLL
=
new
TSCSDK
.
driver
();
TSCSDK
.
driver
TSCLIB_DLL
=
new
TSCSDK
.
driver
();
TSCLIB_DLL
.
openport
(
"TSC TTP-342 Pro"
);
TSCLIB_DLL
.
openport
(
tscConfig
.
PrinterName
);
//TSCLIB_DLL.sendcommand("GETSENSOR(\"PEEL\")");
//TSCLIB_DLL.sendcommand("GETSENSOR(\"PEEL\")");
TSCLIB_DLL
.
sendcommand
(
"\0x27!?"
);
//
TSCLIB_DLL.sendcommand("\0x27!?");
Task
.
Delay
(
1000
).
Wait
();
//
Task.Delay(1000).Wait();
///IntPtr aaa = Marshal.AllocHGlobal(256);
///IntPtr aaa = Marshal.AllocHGlobal(256);
byte
[]
b
=
new
byte
[
256
];
//
byte[] b = new byte[256];
IntPtr
aaa
=
System
.
Runtime
.
InteropServices
.
Marshal
.
UnsafeAddrOfPinnedArrayElement
(
b
,
0
);
//
IntPtr aaa = System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(b, 0);
TSCSDK
.
driver
.
ReadPrinter
(
TSCLIB_DLL
.
hPrinter
,
aaa
,
255
,
out
int
reby
);
//
TSCSDK.driver.ReadPrinter(TSCLIB_DLL.hPrinter, aaa, 255, out int reby);
//Marshal.Copy(aaa, b, 0, 256);
//Marshal.Copy(aaa, b, 0, 256);
//Marshal.FreeHGlobal(aaa);
//Marshal.FreeHGlobal(aaa);
var
bbbb
=
Encoding
.
Unicode
.
GetString
(
b
);
//
var bbbb = Encoding.Unicode.GetString(b);
TSCLIB_DLL
.
sendcommand
(
$
"SIZE {mm:0.00} mm, {nn:0.00} mm"
);
TSCLIB_DLL
.
sendcommand
(
$
"SIZE {mm:0.00} mm, {nn:0.00} mm"
);
TSCLIB_DLL
.
sendcommand
(
"GAP 3 mm,0.3
mm"
);
TSCLIB_DLL
.
sendcommand
(
$
"GAP {tscConfig.Gap} mm,{tscConfig.GapOffset}
mm"
);
TSCLIB_DLL
.
sendcommand
(
"SET CUTTER O
FF
"
);
TSCLIB_DLL
.
sendcommand
(
"SET CUTTER O
N
"
);
TSCLIB_DLL
.
sendcommand
(
"SET RIBBON OFF"
);
//使用碳带
TSCLIB_DLL
.
sendcommand
(
"SET RIBBON OFF"
);
//使用碳带
TSCLIB_DLL
.
sendcommand
(
"SET ENCODER OFF"
);
//碳带编码器检测
TSCLIB_DLL
.
sendcommand
(
"SET ENCODER OFF"
);
//碳带编码器检测
TSCLIB_DLL
.
sendcommand
(
"OFFSET -10
mm"
);
//出纸偏移
TSCLIB_DLL
.
sendcommand
(
$
"OFFSET {tscConfig.Offset}
mm"
);
//出纸偏移
TSCLIB_DLL
.
sendcommand
(
"SPEED 9
"
);
//速度最大15
TSCLIB_DLL
.
sendcommand
(
$
"SPEED {tscConfig.Speed}
"
);
//速度最大15
TSCLIB_DLL
.
sendcommand
(
"DENSITY 12"
);
//浓度
TSCLIB_DLL
.
sendcommand
(
$
"DENSITY {tscConfig.Density}"
);
//浓度最大15
TSCLIB_DLL
.
sendcommand
(
"DIRECTION 1
"
);
TSCLIB_DLL
.
sendcommand
(
$
"DIRECTION {tscConfig.Direction}
"
);
TSCLIB_DLL
.
sendcommand
(
"SET PEEL OFF"
);
TSCLIB_DLL
.
sendcommand
(
"SET PEEL OFF"
);
TSCLIB_DLL
.
clearbuffer
();
TSCLIB_DLL
.
clearbuffer
();
TSCLIB_DLL
.
sendpicture
(
0
,
0
,
bmp
);
TSCLIB_DLL
.
sendpicture
(
0
,
0
,
bmp
);
...
@@ -415,5 +414,36 @@ namespace Asa
...
@@ -415,5 +414,36 @@ namespace Asa
b
=
1
<<
1
,
b
=
1
<<
1
,
c
=
1
<<
2
,
c
=
1
<<
2
,
}
}
public
class
TscConfig
{
/// <summary>
/// 打印机名称
/// </summary>
public
string
PrinterName
=
"TSC TTP-342 Pro"
;
/// <summary>
/// 纸张间隙mm,默认3mm
/// </summary>
public
double
Gap
=
3
;
/// <summary>
/// 纸张间隙偏移量mm,默认0.3mm
/// </summary>
public
double
GapOffset
=
0.3
;
/// <summary>
/// 打印方向 1横向,0纵向,默认1
/// </summary>
public
int
Direction
=
1
;
/// <summary>
/// 出纸偏移量mm,默认-10mm
/// </summary>
public
double
Offset
=
-
10
;
/// <summary>
/// 打印速度1-15,默认9
/// </summary>
public
int
Speed
=
9
;
/// <summary>
/// 打印浓度 1-15,默认12
/// </summary>
public
int
Density
=
12
;
}
}
}
PrintLabel/PrintLabel.csproj
查看文件 @
9a23782
...
@@ -47,11 +47,11 @@
...
@@ -47,11 +47,11 @@
<Reference Include="System.Data" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml" />
<Reference Include="zxing, Version=0.16.
5
.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
<Reference Include="zxing, Version=0.16.
9
.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
<HintPath>..\packages\ZXing.Net.0.16.
5
\lib\net461\zxing.dll</HintPath>
<HintPath>..\packages\ZXing.Net.0.16.
9
\lib\net461\zxing.dll</HintPath>
</Reference>
</Reference>
<Reference Include="zxing.presentation, Version=0.16.
5
.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
<Reference Include="zxing.presentation, Version=0.16.
9
.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
<HintPath>..\packages\ZXing.Net.0.16.
5
\lib\net461\zxing.presentation.dll</HintPath>
<HintPath>..\packages\ZXing.Net.0.16.
9
\lib\net461\zxing.presentation.dll</HintPath>
</Reference>
</Reference>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
PrintLabel/packages.config
查看文件 @
9a23782
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"ZXing.Net"
version
=
"0.16.
5"
targetFramework
=
"net461
"
/>
<
package
id
=
"ZXing.Net"
version
=
"0.16.
9"
targetFramework
=
"net462
"
/>
</
packages
>
</
packages
>
\ No newline at end of file
\ No newline at end of file
PrintLabel_Test/Form1.Designer.cs
查看文件 @
9a23782
...
@@ -37,12 +37,14 @@
...
@@ -37,12 +37,14 @@
this
.
pictureBox1
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
pictureBox1
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
button5
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button5
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_tsc
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn_tsc
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
cb_labelname
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
advanceConfigEdit1
=
new
ConfigHelper
.
AdvanceConfigEdit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
this
.
SuspendLayout
();
this
.
SuspendLayout
();
//
//
// button1
// button1
//
//
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
1
54
,
127
);
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
1
42
,
68
);
this
.
button1
.
Name
=
"button1"
;
this
.
button1
.
Name
=
"button1"
;
this
.
button1
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
49
);
this
.
button1
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
49
);
this
.
button1
.
TabIndex
=
0
;
this
.
button1
.
TabIndex
=
0
;
...
@@ -52,7 +54,7 @@
...
@@ -52,7 +54,7 @@
//
//
// textBox1
// textBox1
//
//
this
.
textBox1
.
Location
=
new
System
.
Drawing
.
Point
(
3
74
,
127
);
this
.
textBox1
.
Location
=
new
System
.
Drawing
.
Point
(
3
62
,
68
);
this
.
textBox1
.
Name
=
"textBox1"
;
this
.
textBox1
.
Name
=
"textBox1"
;
this
.
textBox1
.
Size
=
new
System
.
Drawing
.
Size
(
162
,
21
);
this
.
textBox1
.
Size
=
new
System
.
Drawing
.
Size
(
162
,
21
);
this
.
textBox1
.
TabIndex
=
1
;
this
.
textBox1
.
TabIndex
=
1
;
...
@@ -60,7 +62,7 @@
...
@@ -60,7 +62,7 @@
//
//
// button2
// button2
//
//
this
.
button2
.
Location
=
new
System
.
Drawing
.
Point
(
3
74
,
181
);
this
.
button2
.
Location
=
new
System
.
Drawing
.
Point
(
3
62
,
122
);
this
.
button2
.
Name
=
"button2"
;
this
.
button2
.
Name
=
"button2"
;
this
.
button2
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
23
);
this
.
button2
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
23
);
this
.
button2
.
TabIndex
=
2
;
this
.
button2
.
TabIndex
=
2
;
...
@@ -70,7 +72,7 @@
...
@@ -70,7 +72,7 @@
//
//
// button3
// button3
//
//
this
.
button3
.
Location
=
new
System
.
Drawing
.
Point
(
1
54
,
182
);
this
.
button3
.
Location
=
new
System
.
Drawing
.
Point
(
1
42
,
123
);
this
.
button3
.
Name
=
"button3"
;
this
.
button3
.
Name
=
"button3"
;
this
.
button3
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
49
);
this
.
button3
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
49
);
this
.
button3
.
TabIndex
=
3
;
this
.
button3
.
TabIndex
=
3
;
...
@@ -80,7 +82,7 @@
...
@@ -80,7 +82,7 @@
//
//
// textBox2
// textBox2
//
//
this
.
textBox2
.
Location
=
new
System
.
Drawing
.
Point
(
3
74
,
154
);
this
.
textBox2
.
Location
=
new
System
.
Drawing
.
Point
(
3
62
,
95
);
this
.
textBox2
.
Name
=
"textBox2"
;
this
.
textBox2
.
Name
=
"textBox2"
;
this
.
textBox2
.
Size
=
new
System
.
Drawing
.
Size
(
162
,
21
);
this
.
textBox2
.
Size
=
new
System
.
Drawing
.
Size
(
162
,
21
);
this
.
textBox2
.
TabIndex
=
4
;
this
.
textBox2
.
TabIndex
=
4
;
...
@@ -88,7 +90,7 @@
...
@@ -88,7 +90,7 @@
//
//
// button4
// button4
//
//
this
.
button4
.
Location
=
new
System
.
Drawing
.
Point
(
3
74
,
276
);
this
.
button4
.
Location
=
new
System
.
Drawing
.
Point
(
3
62
,
217
);
this
.
button4
.
Name
=
"button4"
;
this
.
button4
.
Name
=
"button4"
;
this
.
button4
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
23
);
this
.
button4
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
23
);
this
.
button4
.
TabIndex
=
5
;
this
.
button4
.
TabIndex
=
5
;
...
@@ -98,7 +100,7 @@
...
@@ -98,7 +100,7 @@
//
//
// pictureBox1
// pictureBox1
//
//
this
.
pictureBox1
.
Location
=
new
System
.
Drawing
.
Point
(
50
2
,
224
);
this
.
pictureBox1
.
Location
=
new
System
.
Drawing
.
Point
(
50
9
,
123
);
this
.
pictureBox1
.
Name
=
"pictureBox1"
;
this
.
pictureBox1
.
Name
=
"pictureBox1"
;
this
.
pictureBox1
.
Size
=
new
System
.
Drawing
.
Size
(
251
,
163
);
this
.
pictureBox1
.
Size
=
new
System
.
Drawing
.
Size
(
251
,
163
);
this
.
pictureBox1
.
TabIndex
=
6
;
this
.
pictureBox1
.
TabIndex
=
6
;
...
@@ -106,7 +108,7 @@
...
@@ -106,7 +108,7 @@
//
//
// button5
// button5
//
//
this
.
button5
.
Location
=
new
System
.
Drawing
.
Point
(
1
54
,
237
);
this
.
button5
.
Location
=
new
System
.
Drawing
.
Point
(
1
42
,
178
);
this
.
button5
.
Name
=
"button5"
;
this
.
button5
.
Name
=
"button5"
;
this
.
button5
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
47
);
this
.
button5
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
47
);
this
.
button5
.
TabIndex
=
7
;
this
.
button5
.
TabIndex
=
7
;
...
@@ -116,7 +118,7 @@
...
@@ -116,7 +118,7 @@
//
//
// btn_tsc
// btn_tsc
//
//
this
.
btn_tsc
.
Location
=
new
System
.
Drawing
.
Point
(
154
,
322
);
this
.
btn_tsc
.
Location
=
new
System
.
Drawing
.
Point
(
82
,
377
);
this
.
btn_tsc
.
Name
=
"btn_tsc"
;
this
.
btn_tsc
.
Name
=
"btn_tsc"
;
this
.
btn_tsc
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
42
);
this
.
btn_tsc
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
42
);
this
.
btn_tsc
.
TabIndex
=
8
;
this
.
btn_tsc
.
TabIndex
=
8
;
...
@@ -124,11 +126,28 @@
...
@@ -124,11 +126,28 @@
this
.
btn_tsc
.
UseVisualStyleBackColor
=
true
;
this
.
btn_tsc
.
UseVisualStyleBackColor
=
true
;
this
.
btn_tsc
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_tsc_Click
);
this
.
btn_tsc
.
Click
+=
new
System
.
EventHandler
(
this
.
btn_tsc_Click
);
//
//
// cb_labelname
//
this
.
cb_labelname
.
FormattingEnabled
=
true
;
this
.
cb_labelname
.
Location
=
new
System
.
Drawing
.
Point
(
82
,
351
);
this
.
cb_labelname
.
Name
=
"cb_labelname"
;
this
.
cb_labelname
.
Size
=
new
System
.
Drawing
.
Size
(
160
,
20
);
this
.
cb_labelname
.
TabIndex
=
9
;
//
// advanceConfigEdit1
//
this
.
advanceConfigEdit1
.
Location
=
new
System
.
Drawing
.
Point
(
283
,
303
);
this
.
advanceConfigEdit1
.
Name
=
"advanceConfigEdit1"
;
this
.
advanceConfigEdit1
.
Size
=
new
System
.
Drawing
.
Size
(
404
,
273
);
this
.
advanceConfigEdit1
.
TabIndex
=
10
;
//
// Form1
// Form1
//
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
800
,
450
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
885
,
588
);
this
.
Controls
.
Add
(
this
.
advanceConfigEdit1
);
this
.
Controls
.
Add
(
this
.
cb_labelname
);
this
.
Controls
.
Add
(
this
.
btn_tsc
);
this
.
Controls
.
Add
(
this
.
btn_tsc
);
this
.
Controls
.
Add
(
this
.
button5
);
this
.
Controls
.
Add
(
this
.
button5
);
this
.
Controls
.
Add
(
this
.
pictureBox1
);
this
.
Controls
.
Add
(
this
.
pictureBox1
);
...
@@ -159,6 +178,8 @@
...
@@ -159,6 +178,8 @@
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
private
System
.
Windows
.
Forms
.
Button
button5
;
private
System
.
Windows
.
Forms
.
Button
button5
;
private
System
.
Windows
.
Forms
.
Button
btn_tsc
;
private
System
.
Windows
.
Forms
.
Button
btn_tsc
;
private
System
.
Windows
.
Forms
.
ComboBox
cb_labelname
;
private
ConfigHelper
.
AdvanceConfigEdit
advanceConfigEdit1
;
}
}
}
}
PrintLabel_Test/Form1.cs
查看文件 @
9a23782
...
@@ -23,9 +23,10 @@ namespace PrintLabel_Test
...
@@ -23,9 +23,10 @@ namespace PrintLabel_Test
private
void
Form1_Load
(
object
sender
,
EventArgs
e
)
private
void
Form1_Load
(
object
sender
,
EventArgs
e
)
{
{
print
=
new
Asa
.
PrintLabel
(
Application
.
StartupPath
+
"\\Label"
,
1
00
);
print
=
new
Asa
.
PrintLabel
(
Application
.
StartupPath
+
"\\Label"
,
3
00
);
print
.
PrintStatusChanged
+=
Print_PrintStatusChanged
;
print
.
PrintStatusChanged
+=
Print_PrintStatusChanged
;
loadlabelname
();
}
}
private
void
Print_PrintStatusChanged
(
Asa
.
PrintLabel
.
PrinterStatus
sta
,
string
msg
)
private
void
Print_PrintStatusChanged
(
Asa
.
PrintLabel
.
PrinterStatus
sta
,
string
msg
)
...
@@ -36,6 +37,7 @@ namespace PrintLabel_Test
...
@@ -36,6 +37,7 @@ namespace PrintLabel_Test
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
{
{
print
.
EditLabel
();
print
.
EditLabel
();
loadlabelname
();
}
}
private
void
button2_Click
(
object
sender
,
EventArgs
e
)
private
void
button2_Click
(
object
sender
,
EventArgs
e
)
...
@@ -74,10 +76,21 @@ namespace PrintLabel_Test
...
@@ -74,10 +76,21 @@ namespace PrintLabel_Test
print
.
SetResolution
(
300
);
print
.
SetResolution
(
300
);
print
.
GetLabelName
();
print
.
GetLabelName
();
print
.
LoadLabel
(
textBox1
.
Text
);
print
.
LoadLabel
(
cb_labelname
.
SelectedItem
.
ToString
());
print
.
PrintToTsc1
(
text
,
out
TscStauts
tscStauts
);
TscConfig
tscConfig
=
new
TscConfig
();
tscConfig
.
Offset
=
ConfigHelper
.
Config
.
Get
(
"Tsc_Offset"
,
-
17D
);
tscConfig
.
Speed
=
ConfigHelper
.
Config
.
Get
(
"Tsc_Speed"
,
9
);
tscConfig
.
Density
=
ConfigHelper
.
Config
.
Get
(
"Tsc_Density"
,
12
);
print
.
PrintToTsc1
(
text
,
tscConfig
,
out
TscStauts
tscStauts
);
return
;
return
;
}
}
void
loadlabelname
()
{
cb_labelname
.
Items
.
Clear
();
cb_labelname
.
Items
.
AddRange
(
print
.
GetLabelName
());
if
(
cb_labelname
.
Items
.
Count
>
0
)
cb_labelname
.
SelectedIndex
=
0
;
}
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论