Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
PrintLabel
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 21403dfb
由
刘韬
编写于
2023-06-05 15:53:27 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
1afba36f
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
476 行增加
和
88 行删除
PrintLabel/Common.cs
PrintLabel/FrmLabel.Designer.cs
PrintLabel/FrmLabel.cs
PrintLabel/LabelPrint.cs
PrintLabel/Model.cs
PrintLabel/PrintLabel.cs
PrintLabel/PrintLabel.csproj
PrintLabel_Test/Form1.cs
PrintLabel_Test/Form2.cs
PrintLabel_Test/Program.cs
ZebraPrinterHelper/ZebraManger.cs
PrintLabel/Common.cs
查看文件 @
21403df
...
...
@@ -14,11 +14,11 @@ namespace PrintLabel
/// <summary>
/// 像素毫米转换的倍数
/// </summary>
internal
static
float
MULTIPLE
=
203f
;
internal
static
float
MULTIPLE
=
100
;
/// <summary>
/// 添加标签时初始的大小,mm
/// </summary>
internal
const
string
LABEL_SIZE
=
"50,
7
0"
;
internal
const
string
LABEL_SIZE
=
"50,
3
0"
;
/// <summary>
...
...
PrintLabel/FrmLabel.Designer.cs
查看文件 @
21403df
...
...
@@ -50,12 +50,20 @@
this
.
label4
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
label_desc
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
cb_keyword
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
label5
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label6
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
NumLabelH
=
new
System
.
Windows
.
Forms
.
NumericUpDown
();
this
.
NumLabelW
=
new
System
.
Windows
.
Forms
.
NumericUpDown
();
this
.
label_labelsize
=
new
System
.
Windows
.
Forms
.
Label
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumX
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumY
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumW
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumH
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
this
.
groupBox1
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumLabelH
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumLabelW
)).
BeginInit
();
this
.
SuspendLayout
();
//
// LstLabelName
...
...
@@ -71,9 +79,10 @@
//
// BtnLabelNew
//
this
.
BtnLabelNew
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnLabelNew
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
108
);
this
.
BtnLabelNew
.
Name
=
"BtnLabelNew"
;
this
.
BtnLabelNew
.
Size
=
new
System
.
Drawing
.
Size
(
85
,
26
);
this
.
BtnLabelNew
.
Size
=
new
System
.
Drawing
.
Size
(
179
,
26
);
this
.
BtnLabelNew
.
TabIndex
=
1
;
this
.
BtnLabelNew
.
Text
=
"新建"
;
this
.
BtnLabelNew
.
UseVisualStyleBackColor
=
true
;
...
...
@@ -81,7 +90,8 @@
//
// BtnLabelDel
//
this
.
BtnLabelDel
.
Location
=
new
System
.
Drawing
.
Point
(
103
,
108
);
this
.
BtnLabelDel
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnLabelDel
.
Location
=
new
System
.
Drawing
.
Point
(
106
,
140
);
this
.
BtnLabelDel
.
Name
=
"BtnLabelDel"
;
this
.
BtnLabelDel
.
Size
=
new
System
.
Drawing
.
Size
(
85
,
26
);
this
.
BtnLabelDel
.
TabIndex
=
2
;
...
...
@@ -91,7 +101,8 @@
//
// BtnRename
//
this
.
BtnRename
.
Location
=
new
System
.
Drawing
.
Point
(
103
,
140
);
this
.
BtnRename
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnRename
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
140
);
this
.
BtnRename
.
Name
=
"BtnRename"
;
this
.
BtnRename
.
Size
=
new
System
.
Drawing
.
Size
(
85
,
26
);
this
.
BtnRename
.
TabIndex
=
3
;
...
...
@@ -101,9 +112,10 @@
//
// BtnPrintTest
//
this
.
BtnPrintTest
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
236
);
this
.
BtnPrintTest
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnPrintTest
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
256
);
this
.
BtnPrintTest
.
Name
=
"BtnPrintTest"
;
this
.
BtnPrintTest
.
Size
=
new
System
.
Drawing
.
Size
(
1
66
,
26
);
this
.
BtnPrintTest
.
Size
=
new
System
.
Drawing
.
Size
(
1
79
,
26
);
this
.
BtnPrintTest
.
TabIndex
=
4
;
this
.
BtnPrintTest
.
Text
=
"打印测试"
;
this
.
BtnPrintTest
.
UseVisualStyleBackColor
=
true
;
...
...
@@ -111,9 +123,10 @@
//
// BtnSave
//
this
.
BtnSave
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
268
);
this
.
BtnSave
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnSave
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
173
);
this
.
BtnSave
.
Name
=
"BtnSave"
;
this
.
BtnSave
.
Size
=
new
System
.
Drawing
.
Size
(
1
66
,
26
);
this
.
BtnSave
.
Size
=
new
System
.
Drawing
.
Size
(
1
79
,
26
);
this
.
BtnSave
.
TabIndex
=
5
;
this
.
BtnSave
.
Text
=
"保存"
;
this
.
BtnSave
.
UseVisualStyleBackColor
=
true
;
...
...
@@ -121,7 +134,9 @@
//
// BtnFieldAdd
//
this
.
BtnFieldAdd
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
172
);
this
.
BtnFieldAdd
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
BtnFieldAdd
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnFieldAdd
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
14
);
this
.
BtnFieldAdd
.
Name
=
"BtnFieldAdd"
;
this
.
BtnFieldAdd
.
Size
=
new
System
.
Drawing
.
Size
(
85
,
26
);
this
.
BtnFieldAdd
.
TabIndex
=
6
;
...
...
@@ -131,7 +146,9 @@
//
// BtnFieldDel
//
this
.
BtnFieldDel
.
Location
=
new
System
.
Drawing
.
Point
(
103
,
172
);
this
.
BtnFieldDel
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
BtnFieldDel
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnFieldDel
.
Location
=
new
System
.
Drawing
.
Point
(
755
,
14
);
this
.
BtnFieldDel
.
Name
=
"BtnFieldDel"
;
this
.
BtnFieldDel
.
Size
=
new
System
.
Drawing
.
Size
(
85
,
26
);
this
.
BtnFieldDel
.
TabIndex
=
7
;
...
...
@@ -141,7 +158,9 @@
//
// BtnFieldFont
//
this
.
BtnFieldFont
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
204
);
this
.
BtnFieldFont
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
BtnFieldFont
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
BtnFieldFont
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
46
);
this
.
BtnFieldFont
.
Name
=
"BtnFieldFont"
;
this
.
BtnFieldFont
.
Size
=
new
System
.
Drawing
.
Size
(
85
,
26
);
this
.
BtnFieldFont
.
TabIndex
=
8
;
...
...
@@ -151,20 +170,23 @@
//
// CboFieldType
//
this
.
CboFieldType
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
CboFieldType
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
CboFieldType
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
CboFieldType
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
CboFieldType
.
FormattingEnabled
=
true
;
this
.
CboFieldType
.
Location
=
new
System
.
Drawing
.
Point
(
197
,
12
);
this
.
CboFieldType
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
83
);
this
.
CboFieldType
.
Name
=
"CboFieldType"
;
this
.
CboFieldType
.
Size
=
new
System
.
Drawing
.
Size
(
1
20
,
23
);
this
.
CboFieldType
.
Size
=
new
System
.
Drawing
.
Size
(
1
73
,
23
);
this
.
CboFieldType
.
TabIndex
=
9
;
this
.
CboFieldType
.
SelectedIndexChanged
+=
new
System
.
EventHandler
(
this
.
CboFieldType_SelectedIndexChanged
);
//
// NumX
//
this
.
NumX
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
NumX
.
DecimalPlaces
=
2
;
this
.
NumX
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
NumX
.
Location
=
new
System
.
Drawing
.
Point
(
219
,
41
);
this
.
NumX
.
Location
=
new
System
.
Drawing
.
Point
(
689
,
112
);
this
.
NumX
.
Minimum
=
new
decimal
(
new
int
[]
{
100
,
0
,
...
...
@@ -177,9 +199,10 @@
//
// NumY
//
this
.
NumY
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
NumY
.
DecimalPlaces
=
2
;
this
.
NumY
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
NumY
.
Location
=
new
System
.
Drawing
.
Point
(
219
,
71
);
this
.
NumY
.
Location
=
new
System
.
Drawing
.
Point
(
689
,
142
);
this
.
NumY
.
Minimum
=
new
decimal
(
new
int
[]
{
100
,
0
,
...
...
@@ -192,9 +215,10 @@
//
// NumW
//
this
.
NumW
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
NumW
.
DecimalPlaces
=
2
;
this
.
NumW
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
NumW
.
Location
=
new
System
.
Drawing
.
Point
(
219
,
101
);
this
.
NumW
.
Location
=
new
System
.
Drawing
.
Point
(
689
,
172
);
this
.
NumW
.
Minimum
=
new
decimal
(
new
int
[]
{
1
,
0
,
...
...
@@ -212,9 +236,10 @@
//
// NumH
//
this
.
NumH
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
NumH
.
DecimalPlaces
=
2
;
this
.
NumH
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
NumH
.
Location
=
new
System
.
Drawing
.
Point
(
219
,
131
);
this
.
NumH
.
Location
=
new
System
.
Drawing
.
Point
(
689
,
202
);
this
.
NumH
.
Minimum
=
new
decimal
(
new
int
[]
{
1
,
0
,
...
...
@@ -232,11 +257,13 @@
//
// TxtFormatText
//
this
.
TxtFormatText
.
Location
=
new
System
.
Drawing
.
Point
(
197
,
161
);
this
.
TxtFormatText
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
TxtFormatText
.
BorderStyle
=
System
.
Windows
.
Forms
.
BorderStyle
.
FixedSingle
;
this
.
TxtFormatText
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
232
);
this
.
TxtFormatText
.
Multiline
=
true
;
this
.
TxtFormatText
.
Name
=
"TxtFormatText"
;
this
.
TxtFormatText
.
ScrollBars
=
System
.
Windows
.
Forms
.
ScrollBars
.
Both
;
this
.
TxtFormatText
.
Size
=
new
System
.
Drawing
.
Size
(
1
20
,
133
);
this
.
TxtFormatText
.
Size
=
new
System
.
Drawing
.
Size
(
1
76
,
133
);
this
.
TxtFormatText
.
TabIndex
=
14
;
this
.
TxtFormatText
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
TxtFormatText_TextChanged
);
//
...
...
@@ -245,17 +272,18 @@
this
.
pictureBox1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
pictureBox1
.
Location
=
new
System
.
Drawing
.
Point
(
325
,
12
);
this
.
pictureBox1
.
Location
=
new
System
.
Drawing
.
Point
(
208
,
46
);
this
.
pictureBox1
.
Name
=
"pictureBox1"
;
this
.
pictureBox1
.
Size
=
new
System
.
Drawing
.
Size
(
4
63
,
426
);
this
.
pictureBox1
.
Size
=
new
System
.
Drawing
.
Size
(
4
41
,
671
);
this
.
pictureBox1
.
TabIndex
=
15
;
this
.
pictureBox1
.
TabStop
=
false
;
//
// label1
//
this
.
label1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
label1
.
AutoSize
=
true
;
this
.
label1
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
197
,
44
);
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
115
);
this
.
label1
.
Name
=
"label1"
;
this
.
label1
.
Size
=
new
System
.
Drawing
.
Size
(
16
,
16
);
this
.
label1
.
TabIndex
=
16
;
...
...
@@ -263,9 +291,10 @@
//
// label2
//
this
.
label2
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
label2
.
AutoSize
=
true
;
this
.
label2
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
197
,
74
);
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
145
);
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
16
,
16
);
this
.
label2
.
TabIndex
=
17
;
...
...
@@ -273,9 +302,10 @@
//
// label3
//
this
.
label3
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
label3
.
AutoSize
=
true
;
this
.
label3
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
197
,
104
);
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
175
);
this
.
label3
.
Name
=
"label3"
;
this
.
label3
.
Size
=
new
System
.
Drawing
.
Size
(
16
,
16
);
this
.
label3
.
TabIndex
=
18
;
...
...
@@ -283,9 +313,10 @@
//
// label4
//
this
.
label4
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
label4
.
AutoSize
=
true
;
this
.
label4
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label4
.
Location
=
new
System
.
Drawing
.
Point
(
197
,
134
);
this
.
label4
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
205
);
this
.
label4
.
Name
=
"label4"
;
this
.
label4
.
Size
=
new
System
.
Drawing
.
Size
(
16
,
16
);
this
.
label4
.
TabIndex
=
19
;
...
...
@@ -293,10 +324,11 @@
//
// groupBox1
//
this
.
groupBox1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
groupBox1
.
Controls
.
Add
(
this
.
label_desc
);
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
335
);
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
400
);
this
.
groupBox1
.
Name
=
"groupBox1"
;
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
262
,
100
);
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
176
,
167
);
this
.
groupBox1
.
TabIndex
=
20
;
this
.
groupBox1
.
TabStop
=
false
;
this
.
groupBox1
.
Text
=
"字段说明"
;
...
...
@@ -306,15 +338,108 @@
this
.
label_desc
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
label_desc
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
17
);
this
.
label_desc
.
Name
=
"label_desc"
;
this
.
label_desc
.
Size
=
new
System
.
Drawing
.
Size
(
256
,
80
);
this
.
label_desc
.
Size
=
new
System
.
Drawing
.
Size
(
170
,
147
);
this
.
label_desc
.
TabIndex
=
0
;
this
.
label_desc
.
Text
=
" "
;
//
// cb_keyword
//
this
.
cb_keyword
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
cb_keyword
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cb_keyword
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
cb_keyword
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
cb_keyword
.
FormattingEnabled
=
true
;
this
.
cb_keyword
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
371
);
this
.
cb_keyword
.
Name
=
"cb_keyword"
;
this
.
cb_keyword
.
Size
=
new
System
.
Drawing
.
Size
(
176
,
23
);
this
.
cb_keyword
.
TabIndex
=
21
;
this
.
cb_keyword
.
SelectedIndexChanged
+=
new
System
.
EventHandler
(
this
.
cb_keyword_SelectedIndexChanged
);
//
// label5
//
this
.
label5
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
label5
.
AutoSize
=
true
;
this
.
label5
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label5
.
Location
=
new
System
.
Drawing
.
Point
(
481
,
17
);
this
.
label5
.
Name
=
"label5"
;
this
.
label5
.
Size
=
new
System
.
Drawing
.
Size
(
64
,
16
);
this
.
label5
.
TabIndex
=
25
;
this
.
label5
.
Text
=
"Height:"
;
//
// label6
//
this
.
label6
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
label6
.
AutoSize
=
true
;
this
.
label6
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label6
.
Location
=
new
System
.
Drawing
.
Point
(
303
,
17
);
this
.
label6
.
Name
=
"label6"
;
this
.
label6
.
Size
=
new
System
.
Drawing
.
Size
(
56
,
16
);
this
.
label6
.
TabIndex
=
24
;
this
.
label6
.
Text
=
"Width:"
;
//
// NumLabelH
//
this
.
NumLabelH
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
NumLabelH
.
DecimalPlaces
=
2
;
this
.
NumLabelH
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
NumLabelH
.
Location
=
new
System
.
Drawing
.
Point
(
551
,
14
);
this
.
NumLabelH
.
Minimum
=
new
decimal
(
new
int
[]
{
1
,
0
,
0
,
131072
});
this
.
NumLabelH
.
Name
=
"NumLabelH"
;
this
.
NumLabelH
.
Size
=
new
System
.
Drawing
.
Size
(
98
,
24
);
this
.
NumLabelH
.
TabIndex
=
23
;
this
.
NumLabelH
.
Value
=
new
decimal
(
new
int
[]
{
1
,
0
,
0
,
131072
});
this
.
NumLabelH
.
ValueChanged
+=
new
System
.
EventHandler
(
this
.
NumLabelH_ValueChanged
);
//
// NumLabelW
//
this
.
NumLabelW
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
NumLabelW
.
DecimalPlaces
=
2
;
this
.
NumLabelW
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
11F
);
this
.
NumLabelW
.
Location
=
new
System
.
Drawing
.
Point
(
365
,
14
);
this
.
NumLabelW
.
Minimum
=
new
decimal
(
new
int
[]
{
1
,
0
,
0
,
131072
});
this
.
NumLabelW
.
Name
=
"NumLabelW"
;
this
.
NumLabelW
.
Size
=
new
System
.
Drawing
.
Size
(
98
,
24
);
this
.
NumLabelW
.
TabIndex
=
22
;
this
.
NumLabelW
.
Value
=
new
decimal
(
new
int
[]
{
1
,
0
,
0
,
131072
});
this
.
NumLabelW
.
ValueChanged
+=
new
System
.
EventHandler
(
this
.
NumLabelW_ValueChanged
);
//
// label_labelsize
//
this
.
label_labelsize
.
AutoSize
=
true
;
this
.
label_labelsize
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label_labelsize
.
Location
=
new
System
.
Drawing
.
Point
(
205
,
17
);
this
.
label_labelsize
.
Name
=
"label_labelsize"
;
this
.
label_labelsize
.
Size
=
new
System
.
Drawing
.
Size
(
80
,
16
);
this
.
label_labelsize
.
TabIndex
=
26
;
this
.
label_labelsize
.
Text
=
"标签尺寸:"
;
//
// FrmLabel
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
800
,
450
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1008
,
729
);
this
.
Controls
.
Add
(
this
.
label_labelsize
);
this
.
Controls
.
Add
(
this
.
label5
);
this
.
Controls
.
Add
(
this
.
label6
);
this
.
Controls
.
Add
(
this
.
NumLabelH
);
this
.
Controls
.
Add
(
this
.
NumLabelW
);
this
.
Controls
.
Add
(
this
.
cb_keyword
);
this
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
Controls
.
Add
(
this
.
label4
);
this
.
Controls
.
Add
(
this
.
label3
);
...
...
@@ -336,7 +461,9 @@
this
.
Controls
.
Add
(
this
.
BtnLabelDel
);
this
.
Controls
.
Add
(
this
.
BtnLabelNew
);
this
.
Controls
.
Add
(
this
.
LstLabelName
);
this
.
FormBorderStyle
=
System
.
Windows
.
Forms
.
FormBorderStyle
.
FixedSingle
;
this
.
Name
=
"FrmLabel"
;
this
.
ShowIcon
=
false
;
this
.
Text
=
"标签编辑"
;
this
.
FormClosing
+=
new
System
.
Windows
.
Forms
.
FormClosingEventHandler
(
this
.
FrmLabel_FormClosing
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FrmLabel_Load
);
...
...
@@ -346,6 +473,8 @@
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumH
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
EndInit
();
this
.
groupBox1
.
ResumeLayout
(
false
);
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumLabelH
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
NumLabelW
)).
EndInit
();
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
...
...
@@ -375,5 +504,11 @@
private
System
.
Windows
.
Forms
.
Label
label4
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox1
;
private
System
.
Windows
.
Forms
.
Label
label_desc
;
private
System
.
Windows
.
Forms
.
ComboBox
cb_keyword
;
private
System
.
Windows
.
Forms
.
Label
label5
;
private
System
.
Windows
.
Forms
.
Label
label6
;
private
System
.
Windows
.
Forms
.
NumericUpDown
NumLabelH
;
private
System
.
Windows
.
Forms
.
NumericUpDown
NumLabelW
;
private
System
.
Windows
.
Forms
.
Label
label_labelsize
;
}
}
\ No newline at end of file
PrintLabel/FrmLabel.cs
查看文件 @
21403df
...
...
@@ -4,6 +4,7 @@ using System;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -17,9 +18,12 @@ namespace PrintLabel
private
bool
change
=
false
;
private
bool
isLabel
=
false
;
public
string
desc
=
""
;
public
FrmLabel
()
public
List
<
string
>
KeyWord
=
new
List
<
string
>();
public
FrmLabel
(
bool
processui
=
false
)
{
InitializeComponent
();
if
(
processui
)
ProcessUI
(
this
);
}
private
void
LabelPrint_FieldSelected
(
PointF
location
,
SizeF
size
,
Model
.
LabelFieldType
type
)
...
...
@@ -27,6 +31,8 @@ namespace PrintLabel
change
=
true
;
NumX
.
Enabled
=
true
;
NumY
.
Enabled
=
true
;
NumW
.
Enabled
=
true
;
NumH
.
Enabled
=
true
;
NumW
.
Value
=
Convert
.
ToDecimal
(
size
.
Width
<
0.01
?
0.01
:
size
.
Width
);
NumH
.
Value
=
Convert
.
ToDecimal
(
size
.
Height
<
0.01
?
0.01
:
size
.
Height
);
NumX
.
Value
=
Convert
.
ToDecimal
(
location
.
X
);
...
...
@@ -47,12 +53,14 @@ namespace PrintLabel
private
void
LabelPrint_LabelSelected
(
SizeF
size
)
{
change
=
true
;
NumW
.
Value
=
Convert
.
ToDecimal
(
size
.
Width
);
NumH
.
Value
=
Convert
.
ToDecimal
(
size
.
Height
);
Num
Label
W
.
Value
=
Convert
.
ToDecimal
(
size
.
Width
);
Num
Label
H
.
Value
=
Convert
.
ToDecimal
(
size
.
Height
);
NumX
.
Value
=
0
;
NumY
.
Value
=
0
;
NumX
.
Enabled
=
false
;
NumY
.
Enabled
=
false
;
NumW
.
Enabled
=
false
;
NumH
.
Enabled
=
false
;
TxtFormatText
.
Text
=
""
;
CboFieldType
.
SelectedIndex
=
-
1
;
CboFieldType
.
Enabled
=
false
;
...
...
@@ -71,10 +79,20 @@ namespace PrintLabel
Common
.
LabelPrint
.
EditControl
(
pictureBox1
);
CboFieldType
.
Items
.
AddRange
(
Common
.
LabelPrint
.
FieldType
);
groupBox1
.
Visible
=
false
;
cb_keyword
.
Visible
=
false
;
if
(
desc
!=
""
)
{
label_desc
.
Text
=
desc
;
groupBox1
.
Visible
=
true
;
}
if
(
KeyWord
.
Count
>
0
)
{
cb_keyword
.
Visible
=
true
;
cb_keyword
.
Items
.
Add
(
"keyword"
);
cb_keyword
.
Items
.
AddRange
(
KeyWord
.
ToArray
());
cb_keyword
.
SelectedIndex
=
0
;
}
if
(
LstLabelName
.
Items
.
Count
>
0
)
LstLabelName
.
SelectedIndex
=
0
;
}
private
void
FrmLabel_FormClosing
(
object
sender
,
FormClosingEventArgs
e
)
...
...
@@ -88,16 +106,20 @@ namespace PrintLabel
private
void
LstLabelName_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
Common
.
LabelPrint
.
LabelIndex
=
LstLabelName
.
SelectedIndex
;
if
(
LstLabelName
.
SelectedIndex
==
-
1
)
return
;
NumW
.
Value
=
Convert
.
ToDecimal
(
Common
.
Label
[
Common
.
LabelPrint
.
LabelIndex
].
Size_mm
.
Width
);
NumH
.
Value
=
Convert
.
ToDecimal
(
Common
.
Label
[
Common
.
LabelPrint
.
LabelIndex
].
Size_mm
.
Height
);
Common
.
LabelPrint
.
LabelIndex
=
LstLabelName
.
SelectedIndex
;
Num
Label
W
.
Value
=
Convert
.
ToDecimal
(
Common
.
Label
[
Common
.
LabelPrint
.
LabelIndex
].
Size_mm
.
Width
);
Num
Label
H
.
Value
=
Convert
.
ToDecimal
(
Common
.
Label
[
Common
.
LabelPrint
.
LabelIndex
].
Size_mm
.
Height
);
NumX
.
Value
=
0
;
NumY
.
Value
=
0
;
NumX
.
Enabled
=
false
;
NumY
.
Enabled
=
false
;
NumW
.
Enabled
=
false
;
NumH
.
Enabled
=
false
;
CboFieldType
.
Enabled
=
false
;
}
private
void
BtnLabelNew_Click
(
object
sender
,
EventArgs
e
)
...
...
@@ -114,7 +136,7 @@ namespace PrintLabel
private
void
BtnLabelDel_Click
(
object
sender
,
EventArgs
e
)
{
if
(
LstLabelName
.
SelectedIndex
==
-
1
)
return
;
DialogResult
dr
=
MessageBox
.
Show
(
"
确定要删除 "
+
LstLabelName
.
Text
+
" 吗?"
,
"删除
"
,
MessageBoxButtons
.
YesNo
);
DialogResult
dr
=
MessageBox
.
Show
(
"
Delete "
+
LstLabelName
.
Text
+
" ?"
,
"Delete
"
,
MessageBoxButtons
.
YesNo
);
if
(
dr
==
DialogResult
.
No
)
return
;
Common
.
LabelPrint
.
LabelDel
();
LstLabelName
.
Items
.
RemoveAt
(
LstLabelName
.
SelectedIndex
);
...
...
@@ -174,7 +196,7 @@ namespace PrintLabel
{
if
(
change
)
return
;
if
(
isLabel
)
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
W
.
Value
),
Convert
.
ToSingle
(
Num
H
.
Value
));
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
LabelW
.
Value
),
Convert
.
ToSingle
(
NumLabel
H
.
Value
));
else
Common
.
LabelPrint
.
SetFieldSize
(
Convert
.
ToSingle
(
NumX
.
Value
),
Convert
.
ToSingle
(
NumY
.
Value
),
Convert
.
ToSingle
(
NumW
.
Value
),
Convert
.
ToSingle
(
NumH
.
Value
));
}
...
...
@@ -183,7 +205,7 @@ namespace PrintLabel
{
if
(
change
)
return
;
if
(
isLabel
)
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
W
.
Value
),
Convert
.
ToSingle
(
Num
H
.
Value
));
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
LabelW
.
Value
),
Convert
.
ToSingle
(
NumLabel
H
.
Value
));
else
Common
.
LabelPrint
.
SetFieldSize
(
Convert
.
ToSingle
(
NumX
.
Value
),
Convert
.
ToSingle
(
NumY
.
Value
),
Convert
.
ToSingle
(
NumW
.
Value
),
Convert
.
ToSingle
(
NumH
.
Value
));
}
...
...
@@ -192,7 +214,7 @@ namespace PrintLabel
{
if
(
change
)
return
;
if
(
isLabel
)
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
W
.
Value
),
Convert
.
ToSingle
(
Num
H
.
Value
));
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
LabelW
.
Value
),
Convert
.
ToSingle
(
NumLabel
H
.
Value
));
else
Common
.
LabelPrint
.
SetFieldSize
(
Convert
.
ToSingle
(
NumX
.
Value
),
Convert
.
ToSingle
(
NumY
.
Value
),
Convert
.
ToSingle
(
NumW
.
Value
),
Convert
.
ToSingle
(
NumH
.
Value
));
}
...
...
@@ -201,7 +223,7 @@ namespace PrintLabel
{
if
(
change
)
return
;
if
(
isLabel
)
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
W
.
Value
),
Convert
.
ToSingle
(
Num
H
.
Value
));
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Num
LabelW
.
Value
),
Convert
.
ToSingle
(
NumLabel
H
.
Value
));
else
Common
.
LabelPrint
.
SetFieldSize
(
Convert
.
ToSingle
(
NumX
.
Value
),
Convert
.
ToSingle
(
NumY
.
Value
),
Convert
.
ToSingle
(
NumW
.
Value
),
Convert
.
ToSingle
(
NumH
.
Value
));
}
...
...
@@ -212,6 +234,77 @@ namespace PrintLabel
Common
.
LabelPrint
.
SetFieldFormat
(
TxtFormatText
.
Text
);
}
private
void
cb_keyword_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
if
(
cb_keyword
.
SelectedIndex
>
0
)
{
TxtFormatText
.
Text
=
TxtFormatText
.
Text
.
Insert
(
TxtFormatText
.
SelectionStart
,
"{"
+
cb_keyword
.
SelectedItem
.
ToString
()+
"}"
);
cb_keyword
.
SelectedIndex
=
0
;
}
}
public
void
ProcessUI
(
Control
partentControl
)
{
if
(
IsDesignMode
())
return
;
partentControl
.
BackColor
=
Color
.
Black
;
//Color.FromArgb(53, 67, 88);
partentControl
.
ForeColor
=
Color
.
White
;
foreach
(
Control
con
in
partentControl
.
Controls
)
{
con
.
BackColor
=
Color
.
Black
;
//Color.FromArgb(53, 67, 88);
con
.
ForeColor
=
Color
.
White
;
if
(
con
is
ComboBox
)
{
//(con as ComboBox).DrawMode = DrawMode.OwnerDrawVariable;
}
if
(
con
is
ComboBox
||
con
is
TextBox
)
{
con
.
BackColor
=
Color
.
Black
;
//Color.FromArgb(160, 165, 172);
con
.
ForeColor
=
Color
.
White
;
//Color.FromArgb(0, 0, 40); ;
//con.BackColor = Color.White;//Color.FromArgb(160, 165, 172);
//con.ForeColor = Color.Black; //Color.FromArgb(0, 0, 40); ;
}
if
(
con
is
LinkLabel
)
{
(
con
as
LinkLabel
).
LinkColor
=
Color
.
White
;
}
if
(
con
is
DataGridView
)
{
con
.
ForeColor
=
Color
.
Black
;
continue
;
}
if
(
con
.
Controls
.
Count
>
0
)
{
ProcessUI
(
con
);
}
}
}
public
static
bool
IsDesignMode
()
{
bool
returnFlag
=
false
;
if
(
Process
.
GetCurrentProcess
().
ProcessName
==
"devenv"
)
{
returnFlag
=
true
;
}
return
returnFlag
;
}
private
void
NumLabelW_ValueChanged
(
object
sender
,
EventArgs
e
)
{
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
NumLabelW
.
Value
),
Convert
.
ToSingle
(
Common
.
Label
[
Common
.
LabelPrint
.
LabelIndex
].
Size_mm
.
Height
));
}
private
void
NumLabelH_ValueChanged
(
object
sender
,
EventArgs
e
)
{
Common
.
LabelPrint
.
SetLabelSize
(
Convert
.
ToSingle
(
Common
.
Label
[
Common
.
LabelPrint
.
LabelIndex
].
Size_mm
.
Width
),
Convert
.
ToSingle
(
NumLabelH
.
Value
));
}
}
}
PrintLabel/LabelPrint.cs
查看文件 @
21403df
...
...
@@ -80,7 +80,7 @@ namespace BLL
else
{
int
x
=
Convert
.
ToInt32
((
_pic
.
Width
-
Common
.
Label
[
labelIdx
].
Size_px
.
Width
)
/
2
);
int
y
=
Convert
.
ToInt32
((
_pic
.
Height
-
Common
.
Label
[
labelIdx
].
Size_px
.
Height
)
/
2
);
int
y
=
20
;
// Convert.ToInt32((_pic.Height - Common.Label[labelIdx].Size_px.Height) / 4
);
offset
=
new
Point
(
x
,
y
);
}
...
...
@@ -237,7 +237,7 @@ namespace BLL
rect
=
list
[
j
].
Attributes
[
"Rectangle"
].
Value
;
field
.
SetLocationSize
(
rect
);
field
.
SetFont
(
list
[
j
].
Attributes
[
"Font"
].
Value
);
field
.
SetBarQRCode
(
field
.
FormatText
);
field
.
SetBarQRCode
(
field
.
FormatText
,
field
.
Size_px
);
label
.
Field
.
Add
(
field
);
}
Common
.
Label
.
Add
(
label
);
...
...
@@ -340,7 +340,7 @@ namespace BLL
{
if
(
fieldIdx
==
-
1
)
return
;
Common
.
Label
[
labelIdx
].
Field
[
fieldIdx
].
FormatText
=
s
;
Common
.
Label
[
labelIdx
].
Field
[
fieldIdx
].
SetBarQRCode
(
s
);
Common
.
Label
[
labelIdx
].
Field
[
fieldIdx
].
SetBarQRCode
();
if
(
_pic
!=
null
)
_pic
.
Refresh
();
}
...
...
@@ -466,7 +466,11 @@ namespace BLL
using
(
PrintDialog
dlg
=
new
PrintDialog
())
{
if
(
dlg
.
ShowDialog
()
!=
DialogResult
.
OK
)
return
;
System
.
Drawing
.
Printing
.
PrintDocument
print
=
new
System
.
Drawing
.
Printing
.
PrintDocument
{
PrinterSettings
=
dlg
.
PrinterSettings
};
System
.
Drawing
.
Printing
.
PrintDocument
print
=
new
System
.
Drawing
.
Printing
.
PrintDocument
{
PrinterSettings
=
dlg
.
PrinterSettings
};
//print.PrinterSettings.DefaultPageSettings.Color = false;
print
.
PrintPage
+=
PrintTest_PrintPage
;
print
.
DefaultPageSettings
.
Landscape
=
dlg
.
PrinterSettings
.
DefaultPageSettings
.
Landscape
;
print
.
Print
();
...
...
@@ -501,7 +505,7 @@ namespace BLL
}
if
(
field
.
Type
!=
Model
.
LabelFieldType
.
Text
)
{
field
.
SetBarQRCode
(
field
.
PrintText
);
field
.
SetBarQRCode
(
field
.
PrintText
,
field
.
Size_px
);
content
.
Add
(
field
.
PrintText
);
}
}
...
...
@@ -509,12 +513,15 @@ namespace BLL
Bitmap
bmp
=
new
Bitmap
((
int
)
Common
.
Label
[
labelIdx
].
Size_px
.
Width
,
(
int
)
Common
.
Label
[
labelIdx
].
Size_px
.
Height
);
Graphics
g
=
Graphics
.
FromImage
(
bmp
);
g
.
SmoothingMode
=
System
.
Drawing
.
Drawing2D
.
SmoothingMode
.
None
;
g
.
InterpolationMode
=
System
.
Drawing
.
Drawing2D
.
InterpolationMode
.
NearestNeighbor
;
g
.
Clear
(
Color
.
White
);
for
(
int
i
=
0
;
i
<
Common
.
Label
[
labelIdx
].
Field
.
Count
;
i
++)
{
Model
.
ClsLabelField
field
=
Common
.
Label
[
labelIdx
].
Field
[
i
];
if
(
field
.
Type
==
Model
.
LabelFieldType
.
Text
)
{
//StringFormat stringFormat = new StringFormat();
g
.
DrawString
(
field
.
PrintText
,
field
.
Font
,
Brushes
.
Black
,
field
.
GetRectangleF
());
}
else
...
...
@@ -770,6 +777,7 @@ namespace BLL
private
void
PicEdit_MouseUp
(
object
sender
,
MouseEventArgs
e
)
{
}
private
void
PicEdit_MouseMove
(
object
sender
,
MouseEventArgs
e
)
...
...
@@ -797,7 +805,11 @@ namespace BLL
oldPoint
=
e
.
Location
;
if
(
_pic
!=
null
)
{
if
(
fieldIdx
>=
0
)
Common
.
Label
[
labelIdx
].
Field
[
fieldIdx
].
SetBarQRCode
();
_pic
.
Refresh
();
}
}
else
if
(
e
.
Button
==
MouseButtons
.
None
)
{
...
...
PrintLabel/Model.cs
查看文件 @
21403df
...
...
@@ -274,7 +274,7 @@ namespace Model
Width
=
300
,
Height
=
300
,
Margin
=
1
,
PureBarcode
=
true
PureBarcode
=
true
,
};
ZXing
.
PDF417
.
PDF417EncodingOptions
pDF417EncodingOptions
=
new
ZXing
.
PDF417
.
PDF417EncodingOptions
()
{
...
...
@@ -302,7 +302,8 @@ namespace Model
Image
=
writer
.
Write
(
content
);
break
;
case
LabelFieldType
.
Code128
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_128
;
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_128
;
Image
=
writer
.
Write
(
content
);
break
;
case
LabelFieldType
.
DataMatrix
:
...
...
@@ -327,13 +328,88 @@ namespace Model
}
}
/// <summary>
/// 设置条码或二维码图片
/// </summary>
/// <param name="content">内容</param>
public
void
SetBarQRCode
(
string
content
,
SizeF
size
)
{
try
{
Image
=
null
;
if
(
Type
==
LabelFieldType
.
Text
)
return
;
ZXing
.
BarcodeWriter
writer
=
new
ZXing
.
BarcodeWriter
();
ZXing
.
QrCode
.
QrCodeEncodingOptions
qrCodeEncodingOptions
=
new
ZXing
.
QrCode
.
QrCodeEncodingOptions
()
{
DisableECI
=
true
,
CharacterSet
=
"UTF-8"
,
Width
=
(
int
)
size
.
Width
,
Height
=
(
int
)
size
.
Width
,
Margin
=
1
,
PureBarcode
=
true
};
ZXing
.
PDF417
.
PDF417EncodingOptions
pDF417EncodingOptions
=
new
ZXing
.
PDF417
.
PDF417EncodingOptions
()
{
AspectRatio
=
PDF417AspectRatio
.
AUTO
,
Compact
=
false
,
Compaction
=
Compaction
.
AUTO
,
DisableECI
=
true
,
ErrorCorrection
=
PDF417ErrorCorrectionLevel
.
AUTO
,
PureBarcode
=
false
,
GS1Format
=
false
,
Width
=
(
int
)
size
.
Width
,
CharacterSet
=
"UTF-8"
,
Height
=
(
int
)
size
.
Height
,
Margin
=
1
};
writer
.
Options
.
PureBarcode
=
true
;
//writer.Options.Margin = 0;
//writer.Options.Height = (int)size.Height;
writer
.
Options
.
Width
=
(
int
)
size
.
Width
;
switch
(
Type
)
{
case
LabelFieldType
.
Code39
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_39
;
Image
=
writer
.
Write
(
content
);
break
;
case
LabelFieldType
.
Code93
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_93
;
Image
=
writer
.
Write
(
content
);
break
;
case
LabelFieldType
.
Code128
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
CODE_128
;
Image
=
writer
.
Write
(
content
);
break
;
case
LabelFieldType
.
DataMatrix
:
writer
.
Format
=
ZXing
.
BarcodeFormat
.
DATA_MATRIX
;
Image
=
writer
.
Write
(
content
);
break
;
case
LabelFieldType
.
QRCode
:
writer
.
Options
=
qrCodeEncodingOptions
;
writer
.
Format
=
ZXing
.
BarcodeFormat
.
QR_CODE
;
Image
=
writer
.
Write
(
content
);
break
;
case
LabelFieldType
.
PDF417
:
writer
.
Options
=
pDF417EncodingOptions
;
writer
.
Format
=
ZXing
.
BarcodeFormat
.
PDF_417
;
Image
=
writer
.
Write
(
content
);
break
;
}
}
catch
(
Exception
ex
)
{
}
}
/// <summary>
/// 设置条码或二维码图片
/// </summary>
public
void
SetBarQRCode
()
{
SetBarQRCode
(
FormatText
);
SetBarQRCode
(
FormatText
,
Size_px
);
}
/// <summary>
...
...
PrintLabel/PrintLabel.cs
查看文件 @
21403df
...
...
@@ -15,8 +15,9 @@ namespace Asa
private
System
.
Threading
.
Thread
tRun
;
public
PrintLabel
(
string
dir
)
public
PrintLabel
(
string
dir
,
int
dpi
=
100
)
{
Common
.
MULTIPLE
=
dpi
;
Common
.
LabelPrint
=
new
BLL
.
LabelPrint
();
Common
.
LabelPrint
.
Load
(
dir
);
...
...
PrintLabel/PrintLabel.csproj
查看文件 @
21403df
...
...
@@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa</RootNamespace>
<AssemblyName>Asa.PrintLabel</AssemblyName>
<TargetFrameworkVersion>v4.6.
1
</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.
2
</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
...
...
PrintLabel_Test/Form1.cs
查看文件 @
21403df
...
...
@@ -21,7 +21,7 @@ namespace PrintLabel_Test
private
void
Form1_Load
(
object
sender
,
EventArgs
e
)
{
print
=
new
Asa
.
PrintLabel
(
Application
.
StartupPath
+
"\\Label"
);
print
=
new
Asa
.
PrintLabel
(
Application
.
StartupPath
+
"\\Label"
,
100
);
print
.
PrintStatusChanged
+=
Print_PrintStatusChanged
;
}
...
...
PrintLabel_Test/Form2.cs
查看文件 @
21403df
...
...
@@ -21,7 +21,7 @@ namespace PrintLabel_Test
private
void
Form2_Load
(
object
sender
,
EventArgs
e
)
{
print
=
new
Asa
.
PrintLabel
(
Application
.
StartupPath
+
"\\Label"
);
print
=
new
Asa
.
PrintLabel
(
Application
.
StartupPath
+
"\\Label"
,
300
);
reloadlabel
();
ConfigHelper
.
Config
.
PropertyBind
(
"IP"
,
textBox1
,
"Text"
,
"TextChanged"
);
ConfigHelper
.
Config
.
PropertyBind
<
int
>(
"labelindex"
,
comboBox1
,
"SelectedIndex"
,
"SelectedIndexChanged"
);
...
...
@@ -29,7 +29,9 @@ namespace PrintLabel_Test
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
{
print
.
EditLabel
();
PrintLabel
.
FrmLabel
frmLabel
=
new
PrintLabel
.
FrmLabel
();
frmLabel
.
KeyWord
=
new
List
<
string
>()
{
"123"
,
"234"
};
frmLabel
.
ShowDialog
();
reloadlabel
();
}
void
reloadlabel
()
{
...
...
PrintLabel_Test/Program.cs
查看文件 @
21403df
...
...
@@ -16,7 +16,7 @@ namespace PrintLabel_Test
{
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
Form
2
());
Application
.
Run
(
new
Form
1
());
}
}
}
ZebraPrinterHelper/ZebraManger.cs
查看文件 @
21403df
...
...
@@ -18,13 +18,14 @@ namespace ZebraPrinterHelper
{
ConnectionType
ConnectionType
;
string
ConnectionEndpoint
;
public
int
PrinterDPI
=
203
;
public
int
PrinterDPI
=
203
;
/// <summary>
/// 初始化打印机设置
/// </summary>
/// <param name="endpoint">连接地址</param>
/// <param name="connectionType">连接类型</param>
public
ZebraManger
(
string
endpoint
,
ConnectionType
connectionType
)
{
public
ZebraManger
(
string
endpoint
,
ConnectionType
connectionType
)
{
ConnectionEndpoint
=
endpoint
;
ConnectionType
=
connectionType
;
}
...
...
@@ -48,7 +49,8 @@ namespace ZebraPrinterHelper
{
try
{
if
(
string
.
IsNullOrEmpty
(
ConnectionEndpoint
))
{
if
(
string
.
IsNullOrEmpty
(
ConnectionEndpoint
))
{
var
dl
=
GetUsbDirectAddress
();
if
(
dl
.
Count
==
0
)
...
...
@@ -85,7 +87,8 @@ namespace ZebraPrinterHelper
/// </summary>
/// <param name="msg">错误消息</param>
/// <returns>是否成功</returns>
public
bool
Connection
(
out
string
msg
)
{
public
bool
Connection
(
out
string
msg
)
{
msg
=
""
;
try
{
...
...
@@ -124,7 +127,8 @@ namespace ZebraPrinterHelper
/// <summary>
/// 关闭打印机连接
/// </summary>
public
void
Close
()
{
public
void
Close
()
{
try
{
if
(
printerConnection
!=
null
)
...
...
@@ -141,7 +145,8 @@ namespace ZebraPrinterHelper
}
}
~
ZebraManger
()
{
~
ZebraManger
()
{
Close
();
}
/// <summary>
...
...
@@ -149,51 +154,66 @@ namespace ZebraPrinterHelper
/// </summary>
/// <param name="bmp"></param>
/// <param name="msg">错误消息</param>
/// <returns></returns>
public
bool
PrintImage
(
Bitmap
bmp
,
out
string
msg
)
{
return
PrintImage
(
bmp
,
out
msg
,
true
);
}
/// <summary>
/// 打印图像
/// </summary>
/// <param name="bmp"></param>
/// <param name="msg">错误消息</param>
/// <param name="checkPeeler">是否检查剥离器</param>
/// <returns>是否成功</returns>
public
bool
PrintImage
(
Bitmap
bmp
,
out
string
msg
)
public
bool
PrintImage
(
Bitmap
bmp
,
out
string
msg
,
bool
checkPeeler
)
{
if
(!
CheckAndGetStatus
(
out
PrinterStatus
status
,
out
msg
))
return
false
;
if
(
status
.
labelsRemainingInBatch
>
0
)
if
(
status
.
labelsRemainingInBatch
>
0
)
CancelAll
();
if
(!
status
.
isReadyToPrint
)
{
if
(!
status
.
isReadyToPrint
)
{
string
[]
printerStatusString
=
new
PrinterStatusMessages
(
status
).
GetStatusMessage
();
msg
=
string
.
Join
(
"\r\n"
,
printerStatusString
);
return
false
;
}
if
(
IsLabelOnPeeler
)
{
if
(
checkPeeler
&&
IsLabelOnPeeler
)
{
msg
=
"上一个标签尚未移走"
;
return
false
;
}
try
{
//var width = bmp.Width * ((double)PrinterDPI / 300);
//var height = bmp.Height * ((double)PrinterDPI / 300);
//var db = GetReducedImage(bmp, (int)width, (int)height);
//db.Save("temp.bmp");
ZebraImageI
image
=
ZebraImageFactory
.
GetImage
(
bmp
);
var
width
=
image
.
Width
;
// * (PrinterDPI/203f);
var
height
=
image
.
Height
;
// * (PrinterDPI / 203f);
printer
.
PrintImage
(
image
,
0
,
0
,
(
int
)
width
,
(
int
)
height
,
false
);
printer
.
PrintImage
(
image
,
0
,
0
,
(
int
)
bmp
.
Width
,
(
int
)
bmp
.
Height
,
false
);
return
true
;
}
catch
(
ConnectionException
e
)
{
msg
=
"Connection Error:"
+
e
.
Message
;
msg
=
"Connection Error:"
+
e
.
ToString
()
;
}
catch
(
ZebraPrinterLanguageUnknownException
e
)
{
msg
=
"Language Unknown:"
+
e
.
Message
;
msg
=
"Language Unknown:"
+
e
.
ToString
()
;
}
catch
(
IOException
e
)
{
msg
=
"Image Error"
+
e
.
Message
;
msg
=
"Image Error"
+
e
.
ToString
()
;
}
catch
(
ZebraIllegalArgumentException
e
)
{
msg
=
"Illegal Arguments"
+
e
.
Message
;
msg
=
"Illegal Arguments"
+
e
.
ToString
()
;
}
catch
(
ArgumentException
e
)
{
msg
=
"Invalid File Path"
+
e
.
Message
;
msg
=
"Invalid File Path"
+
e
.
ToString
()
;
}
finally
{
...
...
@@ -201,11 +221,12 @@ namespace ZebraPrinterHelper
}
return
false
;
}
bool
CheckAndGetStatus
(
out
PrinterStatus
status
,
out
string
msg
)
{
bool
CheckAndGetStatus
(
out
PrinterStatus
status
,
out
string
msg
)
{
msg
=
""
;
status
=
null
;
int
ReTryCount
=
0
;
ReTry
:
ReTry
:
if
(
printerConnection
==
null
||
!
printerConnection
.
Connected
)
{
if
(!
Connection
(
out
string
m
))
...
...
@@ -214,7 +235,7 @@ namespace ZebraPrinterHelper
return
false
;
}
}
status
=
GetStatus
();
status
=
GetStatus
();
if
(
status
==
null
)
{
Close
();
...
...
@@ -226,7 +247,18 @@ namespace ZebraPrinterHelper
}
goto
ReTry
;
}
ReTryCount
=
0
;
if
(
status
.
isPaused
)
{
PrintStartMode
();
ReTryCount
++;
if
(
ReTryCount
>
2
)
{
msg
=
"暂停状态无法解除"
;
return
false
;
}
goto
ReTry
;
}
return
true
;
}
/// <summary>
...
...
@@ -247,7 +279,8 @@ namespace ZebraPrinterHelper
//log("sensor.peeler" + rs);
return
rs
.
IndexOf
(
"not clear"
)
>
-
1
;
}
catch
{
catch
{
return
false
;
}
}
...
...
@@ -268,7 +301,8 @@ namespace ZebraPrinterHelper
rs
=
rs
.
Trim
(
'\"'
);
return
int
.
Parse
(
rs
);
}
else
{
else
{
throw
new
ZebraPrinterLanguageUnknownException
(
"Get DPI Error!"
);
}
return
203
;
...
...
@@ -277,7 +311,8 @@ namespace ZebraPrinterHelper
/// <summary>
/// 取消所有任务
/// </summary>
public
void
CancelAll
()
{
public
void
CancelAll
()
{
try
{
string
d
=
"~JA\n"
;
...
...
@@ -292,7 +327,8 @@ namespace ZebraPrinterHelper
/// 写入ZPL指令
/// </summary>
/// <param name="zplcommand"></param>
public
void
WriteZPL
(
string
zplcommand
)
{
public
void
WriteZPL
(
string
zplcommand
)
{
var
b
=
Encoding
.
ASCII
.
GetBytes
(
zplcommand
);
printerConnection
.
Write
(
b
);
}
...
...
@@ -320,7 +356,8 @@ namespace ZebraPrinterHelper
var
b
=
Encoding
.
ASCII
.
GetBytes
(
d
);
printerConnection
.
Write
(
b
);
}
public
bool
IsPrinterReady
(
out
string
msg
)
{
public
bool
IsPrinterReady
(
out
string
msg
)
{
msg
=
""
;
var
status
=
GetStatus
();
string
[]
printerStatusString
=
new
PrinterStatusMessages
(
status
).
GetStatusMessage
();
...
...
@@ -334,14 +371,15 @@ namespace ZebraPrinterHelper
{
msg
=
"打印机缓冲池内有未打印文档"
;
return
false
;
}
}
return
true
;
}
/// <summary>
/// 获取打印机状态
/// </summary>
/// <returns></returns>
public
PrinterStatus
GetStatus
()
{
public
PrinterStatus
GetStatus
()
{
if
(
printerConnection
==
null
||
!
printerConnection
.
Connected
)
{
if
(!
Connection
(
out
string
m
))
...
...
@@ -356,11 +394,13 @@ namespace ZebraPrinterHelper
//ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(printer);
//return (linkOsPrinter != null) ? linkOsPrinter.GetCurrentStatus() : printer.GetCurrentStatus();
}
catch
{
catch
{
return
null
;
}
}
public
static
Dictionary
<
string
,
Dictionary
<
string
,
string
>>
GetUsbDirectAddress
()
{
public
static
Dictionary
<
string
,
Dictionary
<
string
,
string
>>
GetUsbDirectAddress
()
{
var
devicelist
=
new
Dictionary
<
string
,
Dictionary
<
string
,
string
>>();
foreach
(
DiscoveredUsbPrinter
printer
in
UsbDiscoverer
.
GetZebraUsbPrinters
(
new
ZebraPrinterFilter
()))
{
...
...
@@ -368,9 +408,37 @@ namespace ZebraPrinterHelper
}
return
devicelist
;
}
private
Image
GetReducedImage
(
Image
resourceImage
,
int
width
,
int
height
)
{
try
{
Image
data
=
null
;
//用指定的大小和格式初始化Bitmap类的新实例
using
(
Bitmap
bitmap
=
new
Bitmap
(
width
,
height
,
resourceImage
.
PixelFormat
))
{
//从指定的Image对象创建新Graphics对象
using
(
Graphics
graphics
=
Graphics
.
FromImage
(
bitmap
))
{
//清除整个绘图面并以透明背景色填充
//graphics.Clear(Color.Transparent);
//在指定位置并且按指定大小绘制原图片对象
graphics
.
SmoothingMode
=
System
.
Drawing
.
Drawing2D
.
SmoothingMode
.
None
;
//graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
graphics
.
PixelOffsetMode
=
System
.
Drawing
.
Drawing2D
.
PixelOffsetMode
.
None
;
graphics
.
DrawImage
(
resourceImage
,
new
Rectangle
(
0
,
0
,
width
,
height
));
}
data
=
new
Bitmap
(
bitmap
);
}
return
data
;
}
catch
(
Exception
e
)
{
throw
e
;
}
}
}
public
enum
ConnectionType
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论