Commit 21403dfb 刘韬

1

1 个父辈 1afba36f
...@@ -14,11 +14,11 @@ namespace PrintLabel ...@@ -14,11 +14,11 @@ namespace PrintLabel
/// <summary> /// <summary>
/// 像素毫米转换的倍数 /// 像素毫米转换的倍数
/// </summary> /// </summary>
internal static float MULTIPLE = 203f; internal static float MULTIPLE = 100;
/// <summary> /// <summary>
/// 添加标签时初始的大小,mm /// 添加标签时初始的大小,mm
/// </summary> /// </summary>
internal const string LABEL_SIZE = "50,70"; internal const string LABEL_SIZE = "50,30";
/// <summary> /// <summary>
......
...@@ -50,12 +50,20 @@ ...@@ -50,12 +50,20 @@
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label_desc = new System.Windows.Forms.Label(); 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.NumX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NumY)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NumY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NumW)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NumW)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NumH)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.NumH)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NumLabelH)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NumLabelW)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// LstLabelName // LstLabelName
...@@ -71,9 +79,10 @@ ...@@ -71,9 +79,10 @@
// //
// BtnLabelNew // BtnLabelNew
// //
this.BtnLabelNew.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnLabelNew.Location = new System.Drawing.Point(12, 108); this.BtnLabelNew.Location = new System.Drawing.Point(12, 108);
this.BtnLabelNew.Name = "BtnLabelNew"; 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.TabIndex = 1;
this.BtnLabelNew.Text = "新建"; this.BtnLabelNew.Text = "新建";
this.BtnLabelNew.UseVisualStyleBackColor = true; this.BtnLabelNew.UseVisualStyleBackColor = true;
...@@ -81,7 +90,8 @@ ...@@ -81,7 +90,8 @@
// //
// BtnLabelDel // 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.Name = "BtnLabelDel";
this.BtnLabelDel.Size = new System.Drawing.Size(85, 26); this.BtnLabelDel.Size = new System.Drawing.Size(85, 26);
this.BtnLabelDel.TabIndex = 2; this.BtnLabelDel.TabIndex = 2;
...@@ -91,7 +101,8 @@ ...@@ -91,7 +101,8 @@
// //
// BtnRename // 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.Name = "BtnRename";
this.BtnRename.Size = new System.Drawing.Size(85, 26); this.BtnRename.Size = new System.Drawing.Size(85, 26);
this.BtnRename.TabIndex = 3; this.BtnRename.TabIndex = 3;
...@@ -101,9 +112,10 @@ ...@@ -101,9 +112,10 @@
// //
// BtnPrintTest // 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.Name = "BtnPrintTest";
this.BtnPrintTest.Size = new System.Drawing.Size(166, 26); this.BtnPrintTest.Size = new System.Drawing.Size(179, 26);
this.BtnPrintTest.TabIndex = 4; this.BtnPrintTest.TabIndex = 4;
this.BtnPrintTest.Text = "打印测试"; this.BtnPrintTest.Text = "打印测试";
this.BtnPrintTest.UseVisualStyleBackColor = true; this.BtnPrintTest.UseVisualStyleBackColor = true;
...@@ -111,9 +123,10 @@ ...@@ -111,9 +123,10 @@
// //
// BtnSave // 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.Name = "BtnSave";
this.BtnSave.Size = new System.Drawing.Size(166, 26); this.BtnSave.Size = new System.Drawing.Size(179, 26);
this.BtnSave.TabIndex = 5; this.BtnSave.TabIndex = 5;
this.BtnSave.Text = "保存"; this.BtnSave.Text = "保存";
this.BtnSave.UseVisualStyleBackColor = true; this.BtnSave.UseVisualStyleBackColor = true;
...@@ -121,7 +134,9 @@ ...@@ -121,7 +134,9 @@
// //
// BtnFieldAdd // 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.Name = "BtnFieldAdd";
this.BtnFieldAdd.Size = new System.Drawing.Size(85, 26); this.BtnFieldAdd.Size = new System.Drawing.Size(85, 26);
this.BtnFieldAdd.TabIndex = 6; this.BtnFieldAdd.TabIndex = 6;
...@@ -131,7 +146,9 @@ ...@@ -131,7 +146,9 @@
// //
// BtnFieldDel // 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.Name = "BtnFieldDel";
this.BtnFieldDel.Size = new System.Drawing.Size(85, 26); this.BtnFieldDel.Size = new System.Drawing.Size(85, 26);
this.BtnFieldDel.TabIndex = 7; this.BtnFieldDel.TabIndex = 7;
...@@ -141,7 +158,9 @@ ...@@ -141,7 +158,9 @@
// //
// BtnFieldFont // 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.Name = "BtnFieldFont";
this.BtnFieldFont.Size = new System.Drawing.Size(85, 26); this.BtnFieldFont.Size = new System.Drawing.Size(85, 26);
this.BtnFieldFont.TabIndex = 8; this.BtnFieldFont.TabIndex = 8;
...@@ -151,20 +170,23 @@ ...@@ -151,20 +170,23 @@
// //
// CboFieldType // 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.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CboFieldType.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.CboFieldType.Font = new System.Drawing.Font("宋体", 11F); this.CboFieldType.Font = new System.Drawing.Font("宋体", 11F);
this.CboFieldType.FormattingEnabled = true; 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.Name = "CboFieldType";
this.CboFieldType.Size = new System.Drawing.Size(120, 23); this.CboFieldType.Size = new System.Drawing.Size(173, 23);
this.CboFieldType.TabIndex = 9; this.CboFieldType.TabIndex = 9;
this.CboFieldType.SelectedIndexChanged += new System.EventHandler(this.CboFieldType_SelectedIndexChanged); this.CboFieldType.SelectedIndexChanged += new System.EventHandler(this.CboFieldType_SelectedIndexChanged);
// //
// NumX // NumX
// //
this.NumX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NumX.DecimalPlaces = 2; this.NumX.DecimalPlaces = 2;
this.NumX.Font = new System.Drawing.Font("宋体", 11F); 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[] { this.NumX.Minimum = new decimal(new int[] {
100, 100,
0, 0,
...@@ -177,9 +199,10 @@ ...@@ -177,9 +199,10 @@
// //
// NumY // NumY
// //
this.NumY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NumY.DecimalPlaces = 2; this.NumY.DecimalPlaces = 2;
this.NumY.Font = new System.Drawing.Font("宋体", 11F); 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[] { this.NumY.Minimum = new decimal(new int[] {
100, 100,
0, 0,
...@@ -192,9 +215,10 @@ ...@@ -192,9 +215,10 @@
// //
// NumW // NumW
// //
this.NumW.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NumW.DecimalPlaces = 2; this.NumW.DecimalPlaces = 2;
this.NumW.Font = new System.Drawing.Font("宋体", 11F); 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[] { this.NumW.Minimum = new decimal(new int[] {
1, 1,
0, 0,
...@@ -212,9 +236,10 @@ ...@@ -212,9 +236,10 @@
// //
// NumH // NumH
// //
this.NumH.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.NumH.DecimalPlaces = 2; this.NumH.DecimalPlaces = 2;
this.NumH.Font = new System.Drawing.Font("宋体", 11F); 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[] { this.NumH.Minimum = new decimal(new int[] {
1, 1,
0, 0,
...@@ -232,11 +257,13 @@ ...@@ -232,11 +257,13 @@
// //
// TxtFormatText // 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.Multiline = true;
this.TxtFormatText.Name = "TxtFormatText"; this.TxtFormatText.Name = "TxtFormatText";
this.TxtFormatText.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.TxtFormatText.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.TxtFormatText.Size = new System.Drawing.Size(120, 133); this.TxtFormatText.Size = new System.Drawing.Size(176, 133);
this.TxtFormatText.TabIndex = 14; this.TxtFormatText.TabIndex = 14;
this.TxtFormatText.TextChanged += new System.EventHandler(this.TxtFormatText_TextChanged); this.TxtFormatText.TextChanged += new System.EventHandler(this.TxtFormatText_TextChanged);
// //
...@@ -245,17 +272,18 @@ ...@@ -245,17 +272,18 @@
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | 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.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(463, 426); this.pictureBox1.Size = new System.Drawing.Size(441, 671);
this.pictureBox1.TabIndex = 15; this.pictureBox1.TabIndex = 15;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
// //
// label1 // label1
// //
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.Name = "label1";
this.label1.Size = new System.Drawing.Size(16, 16); this.label1.Size = new System.Drawing.Size(16, 16);
this.label1.TabIndex = 16; this.label1.TabIndex = 16;
...@@ -263,9 +291,10 @@ ...@@ -263,9 +291,10 @@
// //
// label2 // label2
// //
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.Name = "label2";
this.label2.Size = new System.Drawing.Size(16, 16); this.label2.Size = new System.Drawing.Size(16, 16);
this.label2.TabIndex = 17; this.label2.TabIndex = 17;
...@@ -273,9 +302,10 @@ ...@@ -273,9 +302,10 @@
// //
// label3 // label3
// //
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.Name = "label3";
this.label3.Size = new System.Drawing.Size(16, 16); this.label3.Size = new System.Drawing.Size(16, 16);
this.label3.TabIndex = 18; this.label3.TabIndex = 18;
...@@ -283,9 +313,10 @@ ...@@ -283,9 +313,10 @@
// //
// label4 // label4
// //
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 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.Name = "label4";
this.label4.Size = new System.Drawing.Size(16, 16); this.label4.Size = new System.Drawing.Size(16, 16);
this.label4.TabIndex = 19; this.label4.TabIndex = 19;
...@@ -293,10 +324,11 @@ ...@@ -293,10 +324,11 @@
// //
// groupBox1 // 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.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.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.TabIndex = 20;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "字段说明"; this.groupBox1.Text = "字段说明";
...@@ -306,15 +338,108 @@ ...@@ -306,15 +338,108 @@
this.label_desc.Dock = System.Windows.Forms.DockStyle.Fill; this.label_desc.Dock = System.Windows.Forms.DockStyle.Fill;
this.label_desc.Location = new System.Drawing.Point(3, 17); this.label_desc.Location = new System.Drawing.Point(3, 17);
this.label_desc.Name = "label_desc"; 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.TabIndex = 0;
this.label_desc.Text = " "; 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 // FrmLabel
// //
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(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.groupBox1);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
...@@ -336,7 +461,9 @@ ...@@ -336,7 +461,9 @@
this.Controls.Add(this.BtnLabelDel); this.Controls.Add(this.BtnLabelDel);
this.Controls.Add(this.BtnLabelNew); this.Controls.Add(this.BtnLabelNew);
this.Controls.Add(this.LstLabelName); this.Controls.Add(this.LstLabelName);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "FrmLabel"; this.Name = "FrmLabel";
this.ShowIcon = false;
this.Text = "标签编辑"; this.Text = "标签编辑";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmLabel_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmLabel_FormClosing);
this.Load += new System.EventHandler(this.FrmLabel_Load); this.Load += new System.EventHandler(this.FrmLabel_Load);
...@@ -346,6 +473,8 @@ ...@@ -346,6 +473,8 @@
((System.ComponentModel.ISupportInitialize)(this.NumH)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.NumH)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NumLabelH)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NumLabelW)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
...@@ -375,5 +504,11 @@ ...@@ -375,5 +504,11 @@
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label_desc; 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 \ No newline at end of file
...@@ -4,6 +4,7 @@ using System; ...@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -17,9 +18,12 @@ namespace PrintLabel ...@@ -17,9 +18,12 @@ namespace PrintLabel
private bool change = false; private bool change = false;
private bool isLabel = false; private bool isLabel = false;
public string desc = ""; public string desc = "";
public FrmLabel() public List<string> KeyWord = new List<string>();
public FrmLabel(bool processui=false)
{ {
InitializeComponent(); InitializeComponent();
if (processui)
ProcessUI(this);
} }
private void LabelPrint_FieldSelected(PointF location, SizeF size, Model.LabelFieldType type) private void LabelPrint_FieldSelected(PointF location, SizeF size, Model.LabelFieldType type)
...@@ -27,6 +31,8 @@ namespace PrintLabel ...@@ -27,6 +31,8 @@ namespace PrintLabel
change = true; change = true;
NumX.Enabled = true; NumX.Enabled = true;
NumY.Enabled = true; NumY.Enabled = true;
NumW.Enabled = true;
NumH.Enabled = true;
NumW.Value = Convert.ToDecimal(size.Width < 0.01 ? 0.01 : size.Width); NumW.Value = Convert.ToDecimal(size.Width < 0.01 ? 0.01 : size.Width);
NumH.Value = Convert.ToDecimal(size.Height < 0.01 ? 0.01 : size.Height); NumH.Value = Convert.ToDecimal(size.Height < 0.01 ? 0.01 : size.Height);
NumX.Value = Convert.ToDecimal(location.X); NumX.Value = Convert.ToDecimal(location.X);
...@@ -47,12 +53,14 @@ namespace PrintLabel ...@@ -47,12 +53,14 @@ namespace PrintLabel
private void LabelPrint_LabelSelected(SizeF size) private void LabelPrint_LabelSelected(SizeF size)
{ {
change = true; change = true;
NumW.Value = Convert.ToDecimal(size.Width); NumLabelW.Value = Convert.ToDecimal(size.Width);
NumH.Value = Convert.ToDecimal(size.Height); NumLabelH.Value = Convert.ToDecimal(size.Height);
NumX.Value = 0; NumX.Value = 0;
NumY.Value = 0; NumY.Value = 0;
NumX.Enabled = false; NumX.Enabled = false;
NumY.Enabled = false; NumY.Enabled = false;
NumW.Enabled = false;
NumH.Enabled = false;
TxtFormatText.Text = ""; TxtFormatText.Text = "";
CboFieldType.SelectedIndex = -1; CboFieldType.SelectedIndex = -1;
CboFieldType.Enabled = false; CboFieldType.Enabled = false;
...@@ -71,10 +79,20 @@ namespace PrintLabel ...@@ -71,10 +79,20 @@ namespace PrintLabel
Common.LabelPrint.EditControl(pictureBox1); Common.LabelPrint.EditControl(pictureBox1);
CboFieldType.Items.AddRange(Common.LabelPrint.FieldType); CboFieldType.Items.AddRange(Common.LabelPrint.FieldType);
groupBox1.Visible = false; groupBox1.Visible = false;
cb_keyword.Visible = false;
if (desc != "") { if (desc != "") {
label_desc.Text = desc; label_desc.Text = desc;
groupBox1.Visible = true; 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) private void FrmLabel_FormClosing(object sender, FormClosingEventArgs e)
...@@ -88,16 +106,20 @@ namespace PrintLabel ...@@ -88,16 +106,20 @@ namespace PrintLabel
private void LstLabelName_SelectedIndexChanged(object sender, EventArgs e) 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); if (LstLabelName.SelectedIndex == -1) return;
NumH.Value = Convert.ToDecimal(Common.Label[Common.LabelPrint.LabelIndex].Size_mm.Height); Common.LabelPrint.LabelIndex = LstLabelName.SelectedIndex;
NumLabelW.Value = Convert.ToDecimal(Common.Label[Common.LabelPrint.LabelIndex].Size_mm.Width);
NumLabelH.Value = Convert.ToDecimal(Common.Label[Common.LabelPrint.LabelIndex].Size_mm.Height);
NumX.Value = 0; NumX.Value = 0;
NumY.Value = 0; NumY.Value = 0;
NumX.Enabled = false; NumX.Enabled = false;
NumY.Enabled = false; NumY.Enabled = false;
NumW.Enabled = false;
NumH.Enabled = false;
CboFieldType.Enabled = false; CboFieldType.Enabled = false;
} }
private void BtnLabelNew_Click(object sender, EventArgs e) private void BtnLabelNew_Click(object sender, EventArgs e)
...@@ -114,7 +136,7 @@ namespace PrintLabel ...@@ -114,7 +136,7 @@ namespace PrintLabel
private void BtnLabelDel_Click(object sender, EventArgs e) private void BtnLabelDel_Click(object sender, EventArgs e)
{ {
if (LstLabelName.SelectedIndex == -1) return; 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; if (dr == DialogResult.No) return;
Common.LabelPrint.LabelDel(); Common.LabelPrint.LabelDel();
LstLabelName.Items.RemoveAt(LstLabelName.SelectedIndex); LstLabelName.Items.RemoveAt(LstLabelName.SelectedIndex);
...@@ -174,7 +196,7 @@ namespace PrintLabel ...@@ -174,7 +196,7 @@ namespace PrintLabel
{ {
if (change) return; if (change) return;
if (isLabel) if (isLabel)
Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumLabelW.Value), Convert.ToSingle(NumLabelH.Value));
else else
Common.LabelPrint.SetFieldSize(Convert.ToSingle(NumX.Value), Convert.ToSingle(NumY.Value), Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); 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 ...@@ -183,7 +205,7 @@ namespace PrintLabel
{ {
if (change) return; if (change) return;
if (isLabel) if (isLabel)
Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumLabelW.Value), Convert.ToSingle(NumLabelH.Value));
else else
Common.LabelPrint.SetFieldSize(Convert.ToSingle(NumX.Value), Convert.ToSingle(NumY.Value), Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); 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 ...@@ -192,7 +214,7 @@ namespace PrintLabel
{ {
if (change) return; if (change) return;
if (isLabel) if (isLabel)
Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumLabelW.Value), Convert.ToSingle(NumLabelH.Value));
else else
Common.LabelPrint.SetFieldSize(Convert.ToSingle(NumX.Value), Convert.ToSingle(NumY.Value), Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); 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 ...@@ -201,7 +223,7 @@ namespace PrintLabel
{ {
if (change) return; if (change) return;
if (isLabel) if (isLabel)
Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); Common.LabelPrint.SetLabelSize(Convert.ToSingle(NumLabelW.Value), Convert.ToSingle(NumLabelH.Value));
else else
Common.LabelPrint.SetFieldSize(Convert.ToSingle(NumX.Value), Convert.ToSingle(NumY.Value), Convert.ToSingle(NumW.Value), Convert.ToSingle(NumH.Value)); 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 ...@@ -212,6 +234,77 @@ namespace PrintLabel
Common.LabelPrint.SetFieldFormat(TxtFormatText.Text); 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));
}
} }
} }
...@@ -80,7 +80,7 @@ namespace BLL ...@@ -80,7 +80,7 @@ namespace BLL
else else
{ {
int x = Convert.ToInt32((_pic.Width - Common.Label[labelIdx].Size_px.Width) / 2); 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); offset = new Point(x, y);
} }
...@@ -237,7 +237,7 @@ namespace BLL ...@@ -237,7 +237,7 @@ namespace BLL
rect = list[j].Attributes["Rectangle"].Value; rect = list[j].Attributes["Rectangle"].Value;
field.SetLocationSize(rect); field.SetLocationSize(rect);
field.SetFont(list[j].Attributes["Font"].Value); field.SetFont(list[j].Attributes["Font"].Value);
field.SetBarQRCode(field.FormatText); field.SetBarQRCode(field.FormatText,field.Size_px);
label.Field.Add(field); label.Field.Add(field);
} }
Common.Label.Add(label); Common.Label.Add(label);
...@@ -340,7 +340,7 @@ namespace BLL ...@@ -340,7 +340,7 @@ namespace BLL
{ {
if (fieldIdx == -1) return; if (fieldIdx == -1) return;
Common.Label[labelIdx].Field[fieldIdx].FormatText = s; 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(); if (_pic != null) _pic.Refresh();
} }
...@@ -466,7 +466,11 @@ namespace BLL ...@@ -466,7 +466,11 @@ namespace BLL
using (PrintDialog dlg = new PrintDialog()) using (PrintDialog dlg = new PrintDialog())
{ {
if (dlg.ShowDialog() != DialogResult.OK) return; 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.PrintPage += PrintTest_PrintPage;
print.DefaultPageSettings.Landscape = dlg.PrinterSettings.DefaultPageSettings.Landscape; print.DefaultPageSettings.Landscape = dlg.PrinterSettings.DefaultPageSettings.Landscape;
print.Print(); print.Print();
...@@ -501,7 +505,7 @@ namespace BLL ...@@ -501,7 +505,7 @@ namespace BLL
} }
if (field.Type != Model.LabelFieldType.Text) if (field.Type != Model.LabelFieldType.Text)
{ {
field.SetBarQRCode(field.PrintText); field.SetBarQRCode(field.PrintText,field.Size_px);
content.Add(field.PrintText); content.Add(field.PrintText);
} }
} }
...@@ -509,12 +513,15 @@ namespace BLL ...@@ -509,12 +513,15 @@ namespace BLL
Bitmap bmp = new Bitmap((int)Common.Label[labelIdx].Size_px.Width, (int)Common.Label[labelIdx].Size_px.Height); Bitmap bmp = new Bitmap((int)Common.Label[labelIdx].Size_px.Width, (int)Common.Label[labelIdx].Size_px.Height);
Graphics g = Graphics.FromImage(bmp); Graphics g = Graphics.FromImage(bmp);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.Clear(Color.White); g.Clear(Color.White);
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];
if (field.Type == Model.LabelFieldType.Text) if (field.Type == Model.LabelFieldType.Text)
{ {
//StringFormat stringFormat = new StringFormat();
g.DrawString(field.PrintText, field.Font, Brushes.Black, field.GetRectangleF()); g.DrawString(field.PrintText, field.Font, Brushes.Black, field.GetRectangleF());
} }
else else
...@@ -770,6 +777,7 @@ namespace BLL ...@@ -770,6 +777,7 @@ namespace BLL
private void PicEdit_MouseUp(object sender, MouseEventArgs e) private void PicEdit_MouseUp(object sender, MouseEventArgs e)
{ {
} }
private void PicEdit_MouseMove(object sender, MouseEventArgs e) private void PicEdit_MouseMove(object sender, MouseEventArgs e)
...@@ -797,8 +805,12 @@ namespace BLL ...@@ -797,8 +805,12 @@ namespace BLL
oldPoint = e.Location; oldPoint = e.Location;
if (_pic != null) if (_pic != null)
{
if (fieldIdx>=0)
Common.Label[labelIdx].Field[fieldIdx].SetBarQRCode();
_pic.Refresh(); _pic.Refresh();
} }
}
else if (e.Button == MouseButtons.None) else if (e.Button == MouseButtons.None)
{ {
if (fieldIdx == -1) return; if (fieldIdx == -1) return;
......
...@@ -274,7 +274,7 @@ namespace Model ...@@ -274,7 +274,7 @@ namespace Model
Width = 300, Width = 300,
Height = 300, Height = 300,
Margin = 1, Margin = 1,
PureBarcode = true PureBarcode = true,
}; };
ZXing.PDF417.PDF417EncodingOptions pDF417EncodingOptions = new ZXing.PDF417.PDF417EncodingOptions() ZXing.PDF417.PDF417EncodingOptions pDF417EncodingOptions = new ZXing.PDF417.PDF417EncodingOptions()
{ {
...@@ -303,6 +303,7 @@ namespace Model ...@@ -303,6 +303,7 @@ namespace Model
break; break;
case LabelFieldType.Code128: case LabelFieldType.Code128:
writer.Format = ZXing.BarcodeFormat.CODE_128; writer.Format = ZXing.BarcodeFormat.CODE_128;
Image = writer.Write(content); Image = writer.Write(content);
break; break;
case LabelFieldType.DataMatrix: case LabelFieldType.DataMatrix:
...@@ -327,13 +328,88 @@ namespace Model ...@@ -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>
/// 设置条码或二维码图片 /// 设置条码或二维码图片
/// </summary> /// </summary>
public void SetBarQRCode() public void SetBarQRCode()
{ {
SetBarQRCode(FormatText); SetBarQRCode(FormatText, Size_px);
} }
/// <summary> /// <summary>
......
...@@ -15,8 +15,9 @@ namespace Asa ...@@ -15,8 +15,9 @@ namespace Asa
private System.Threading.Thread tRun; 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 = new BLL.LabelPrint();
Common.LabelPrint.Load(dir); Common.LabelPrint.Load(dir);
......
...@@ -9,9 +9,10 @@ ...@@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa</RootNamespace> <RootNamespace>Asa</RootNamespace>
<AssemblyName>Asa.PrintLabel</AssemblyName> <AssemblyName>Asa.PrintLabel</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
......
...@@ -21,7 +21,7 @@ namespace PrintLabel_Test ...@@ -21,7 +21,7 @@ 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"); print = new Asa.PrintLabel(Application.StartupPath + "\\Label",100);
print.PrintStatusChanged += Print_PrintStatusChanged; print.PrintStatusChanged += Print_PrintStatusChanged;
} }
......
...@@ -21,7 +21,7 @@ namespace PrintLabel_Test ...@@ -21,7 +21,7 @@ namespace PrintLabel_Test
private void Form2_Load(object sender, EventArgs e) private void Form2_Load(object sender, EventArgs e)
{ {
print = new Asa.PrintLabel(Application.StartupPath + "\\Label"); print = new Asa.PrintLabel(Application.StartupPath + "\\Label",300);
reloadlabel(); reloadlabel();
ConfigHelper.Config.PropertyBind("IP", textBox1, "Text", "TextChanged"); ConfigHelper.Config.PropertyBind("IP", textBox1, "Text", "TextChanged");
ConfigHelper.Config.PropertyBind<int>("labelindex", comboBox1, "SelectedIndex", "SelectedIndexChanged"); ConfigHelper.Config.PropertyBind<int>("labelindex", comboBox1, "SelectedIndex", "SelectedIndexChanged");
...@@ -29,7 +29,9 @@ namespace PrintLabel_Test ...@@ -29,7 +29,9 @@ namespace PrintLabel_Test
private void button1_Click(object sender, EventArgs e) 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(); reloadlabel();
} }
void reloadlabel() { void reloadlabel() {
......
...@@ -16,7 +16,7 @@ namespace PrintLabel_Test ...@@ -16,7 +16,7 @@ namespace PrintLabel_Test
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form2()); Application.Run(new Form1());
} }
} }
} }
...@@ -18,13 +18,14 @@ namespace ZebraPrinterHelper ...@@ -18,13 +18,14 @@ namespace ZebraPrinterHelper
{ {
ConnectionType ConnectionType; ConnectionType ConnectionType;
string ConnectionEndpoint; string ConnectionEndpoint;
public int PrinterDPI=203; public int PrinterDPI = 203;
/// <summary> /// <summary>
/// 初始化打印机设置 /// 初始化打印机设置
/// </summary> /// </summary>
/// <param name="endpoint">连接地址</param> /// <param name="endpoint">连接地址</param>
/// <param name="connectionType">连接类型</param> /// <param name="connectionType">连接类型</param>
public ZebraManger(string endpoint, ConnectionType connectionType) { public ZebraManger(string endpoint, ConnectionType connectionType)
{
ConnectionEndpoint = endpoint; ConnectionEndpoint = endpoint;
ConnectionType = connectionType; ConnectionType = connectionType;
} }
...@@ -48,7 +49,8 @@ namespace ZebraPrinterHelper ...@@ -48,7 +49,8 @@ namespace ZebraPrinterHelper
{ {
try try
{ {
if (string.IsNullOrEmpty(ConnectionEndpoint)) { if (string.IsNullOrEmpty(ConnectionEndpoint))
{
var dl = GetUsbDirectAddress(); var dl = GetUsbDirectAddress();
if (dl.Count == 0) if (dl.Count == 0)
...@@ -85,7 +87,8 @@ namespace ZebraPrinterHelper ...@@ -85,7 +87,8 @@ namespace ZebraPrinterHelper
/// </summary> /// </summary>
/// <param name="msg">错误消息</param> /// <param name="msg">错误消息</param>
/// <returns>是否成功</returns> /// <returns>是否成功</returns>
public bool Connection(out string msg) { public bool Connection(out string msg)
{
msg = ""; msg = "";
try try
{ {
...@@ -124,7 +127,8 @@ namespace ZebraPrinterHelper ...@@ -124,7 +127,8 @@ namespace ZebraPrinterHelper
/// <summary> /// <summary>
/// 关闭打印机连接 /// 关闭打印机连接
/// </summary> /// </summary>
public void Close() { public void Close()
{
try try
{ {
if (printerConnection != null) if (printerConnection != null)
...@@ -141,7 +145,8 @@ namespace ZebraPrinterHelper ...@@ -141,7 +145,8 @@ namespace ZebraPrinterHelper
} }
} }
~ZebraManger() { ~ZebraManger()
{
Close(); Close();
} }
/// <summary> /// <summary>
...@@ -149,51 +154,66 @@ namespace ZebraPrinterHelper ...@@ -149,51 +154,66 @@ namespace ZebraPrinterHelper
/// </summary> /// </summary>
/// <param name="bmp"></param> /// <param name="bmp"></param>
/// <param name="msg">错误消息</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> /// <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)) if (!CheckAndGetStatus(out PrinterStatus status, out msg))
return false; return false;
if (status.labelsRemainingInBatch>0) if (status.labelsRemainingInBatch > 0)
CancelAll(); CancelAll();
if (!status.isReadyToPrint) {
if (!status.isReadyToPrint)
{
string[] printerStatusString = new PrinterStatusMessages(status).GetStatusMessage(); string[] printerStatusString = new PrinterStatusMessages(status).GetStatusMessage();
msg = string.Join("\r\n", printerStatusString); msg = string.Join("\r\n", printerStatusString);
return false; return false;
} }
if (IsLabelOnPeeler) { if (checkPeeler && IsLabelOnPeeler)
{
msg = "上一个标签尚未移走"; msg = "上一个标签尚未移走";
return false; return false;
} }
try 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); ZebraImageI image = ZebraImageFactory.GetImage(bmp);
var width = image.Width; // * (PrinterDPI/203f); printer.PrintImage(image, 0, 0, (int)bmp.Width, (int)bmp.Height, false);
var height = image.Height; // * (PrinterDPI / 203f);
printer.PrintImage(image, 0, 0, (int)width, (int)height, false);
return true; return true;
} }
catch (ConnectionException e) catch (ConnectionException e)
{ {
msg = "Connection Error:" + e.Message; msg = "Connection Error:" + e.ToString();
} }
catch (ZebraPrinterLanguageUnknownException e) catch (ZebraPrinterLanguageUnknownException e)
{ {
msg = "Language Unknown:" + e.Message; msg = "Language Unknown:" + e.ToString();
} }
catch (IOException e) catch (IOException e)
{ {
msg = "Image Error" + e.Message; msg = "Image Error" + e.ToString();
} }
catch (ZebraIllegalArgumentException e) catch (ZebraIllegalArgumentException e)
{ {
msg = "Illegal Arguments"+e.Message; msg = "Illegal Arguments" + e.ToString();
} }
catch (ArgumentException e) catch (ArgumentException e)
{ {
msg = "Invalid File Path" + e.Message; msg = "Invalid File Path" + e.ToString();
} }
finally finally
{ {
...@@ -201,7 +221,8 @@ namespace ZebraPrinterHelper ...@@ -201,7 +221,8 @@ namespace ZebraPrinterHelper
} }
return false; return false;
} }
bool CheckAndGetStatus(out PrinterStatus status, out string msg) { bool CheckAndGetStatus(out PrinterStatus status, out string msg)
{
msg = ""; msg = "";
status = null; status = null;
int ReTryCount = 0; int ReTryCount = 0;
...@@ -226,7 +247,18 @@ namespace ZebraPrinterHelper ...@@ -226,7 +247,18 @@ namespace ZebraPrinterHelper
} }
goto ReTry; goto ReTry;
} }
ReTryCount = 0;
if (status.isPaused)
{
PrintStartMode();
ReTryCount++;
if (ReTryCount > 2)
{
msg = "暂停状态无法解除";
return false;
}
goto ReTry;
}
return true; return true;
} }
/// <summary> /// <summary>
...@@ -247,7 +279,8 @@ namespace ZebraPrinterHelper ...@@ -247,7 +279,8 @@ namespace ZebraPrinterHelper
//log("sensor.peeler" + rs); //log("sensor.peeler" + rs);
return rs.IndexOf("not clear") > -1; return rs.IndexOf("not clear") > -1;
} }
catch { catch
{
return false; return false;
} }
} }
...@@ -268,7 +301,8 @@ namespace ZebraPrinterHelper ...@@ -268,7 +301,8 @@ namespace ZebraPrinterHelper
rs = rs.Trim('\"'); rs = rs.Trim('\"');
return int.Parse(rs); return int.Parse(rs);
} }
else { else
{
throw new ZebraPrinterLanguageUnknownException("Get DPI Error!"); throw new ZebraPrinterLanguageUnknownException("Get DPI Error!");
} }
return 203; return 203;
...@@ -277,7 +311,8 @@ namespace ZebraPrinterHelper ...@@ -277,7 +311,8 @@ namespace ZebraPrinterHelper
/// <summary> /// <summary>
/// 取消所有任务 /// 取消所有任务
/// </summary> /// </summary>
public void CancelAll() { public void CancelAll()
{
try try
{ {
string d = "~JA\n"; string d = "~JA\n";
...@@ -292,7 +327,8 @@ namespace ZebraPrinterHelper ...@@ -292,7 +327,8 @@ namespace ZebraPrinterHelper
/// 写入ZPL指令 /// 写入ZPL指令
/// </summary> /// </summary>
/// <param name="zplcommand"></param> /// <param name="zplcommand"></param>
public void WriteZPL(string zplcommand) { public void WriteZPL(string zplcommand)
{
var b = Encoding.ASCII.GetBytes(zplcommand); var b = Encoding.ASCII.GetBytes(zplcommand);
printerConnection.Write(b); printerConnection.Write(b);
} }
...@@ -320,7 +356,8 @@ namespace ZebraPrinterHelper ...@@ -320,7 +356,8 @@ namespace ZebraPrinterHelper
var b = Encoding.ASCII.GetBytes(d); var b = Encoding.ASCII.GetBytes(d);
printerConnection.Write(b); printerConnection.Write(b);
} }
public bool IsPrinterReady(out string msg) { public bool IsPrinterReady(out string msg)
{
msg = ""; msg = "";
var status = GetStatus(); var status = GetStatus();
string[] printerStatusString = new PrinterStatusMessages(status).GetStatusMessage(); string[] printerStatusString = new PrinterStatusMessages(status).GetStatusMessage();
...@@ -341,7 +378,8 @@ namespace ZebraPrinterHelper ...@@ -341,7 +378,8 @@ namespace ZebraPrinterHelper
/// 获取打印机状态 /// 获取打印机状态
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public PrinterStatus GetStatus() { public PrinterStatus GetStatus()
{
if (printerConnection == null || !printerConnection.Connected) if (printerConnection == null || !printerConnection.Connected)
{ {
if (!Connection(out string m)) if (!Connection(out string m))
...@@ -356,11 +394,13 @@ namespace ZebraPrinterHelper ...@@ -356,11 +394,13 @@ namespace ZebraPrinterHelper
//ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(printer); //ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(printer);
//return (linkOsPrinter != null) ? linkOsPrinter.GetCurrentStatus() : printer.GetCurrentStatus(); //return (linkOsPrinter != null) ? linkOsPrinter.GetCurrentStatus() : printer.GetCurrentStatus();
} }
catch { catch
{
return null; 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>>(); var devicelist = new Dictionary<string, Dictionary<string, string>>();
foreach (DiscoveredUsbPrinter printer in UsbDiscoverer.GetZebraUsbPrinters(new ZebraPrinterFilter())) foreach (DiscoveredUsbPrinter printer in UsbDiscoverer.GetZebraUsbPrinters(new ZebraPrinterFilter()))
{ {
...@@ -368,8 +408,36 @@ namespace ZebraPrinterHelper ...@@ -368,8 +408,36 @@ namespace ZebraPrinterHelper
} }
return devicelist; 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 public enum ConnectionType
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!