Commit 463738c6 刘韬

1

1 个父辈 68f397be
......@@ -212,6 +212,7 @@
this.NumX.Name = "NumX";
this.NumX.Size = new System.Drawing.Size(131, 24);
this.NumX.TabIndex = 10;
this.NumX.Tag = "not";
this.NumX.ValueChanged += new System.EventHandler(this.NumX_ValueChanged);
//
// NumY
......@@ -229,6 +230,7 @@
this.NumY.Name = "NumY";
this.NumY.Size = new System.Drawing.Size(131, 24);
this.NumY.TabIndex = 11;
this.NumY.Tag = "not";
this.NumY.ValueChanged += new System.EventHandler(this.NumY_ValueChanged);
//
// NumW
......@@ -246,6 +248,7 @@
this.NumW.Name = "NumW";
this.NumW.Size = new System.Drawing.Size(131, 24);
this.NumW.TabIndex = 12;
this.NumW.Tag = "not";
this.NumW.Value = new decimal(new int[] {
1,
0,
......@@ -268,6 +271,7 @@
this.NumH.Name = "NumH";
this.NumH.Size = new System.Drawing.Size(131, 24);
this.NumH.TabIndex = 13;
this.NumH.Tag = "not";
this.NumH.Value = new decimal(new int[] {
1,
0,
......@@ -286,6 +290,7 @@
this.TxtFormatText.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.TxtFormatText.Size = new System.Drawing.Size(234, 122);
this.TxtFormatText.TabIndex = 14;
this.TxtFormatText.Tag = "not";
this.TxtFormatText.TextChanged += new System.EventHandler(this.TxtFormatText_TextChanged);
//
// label1
......@@ -377,23 +382,25 @@
//
this.label5.Anchor = System.Windows.Forms.AnchorStyles.Left;
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(534, 10);
this.label5.Location = new System.Drawing.Point(509, 10);
this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(46, 24);
this.label5.Size = new System.Drawing.Size(71, 24);
this.label5.TabIndex = 25;
this.label5.Text = "高:";
this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label6
//
this.label6.Anchor = System.Windows.Forms.AnchorStyles.Left;
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(316, 9);
this.label6.Location = new System.Drawing.Point(293, 9);
this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(46, 25);
this.label6.Size = new System.Drawing.Size(69, 25);
this.label6.TabIndex = 24;
this.label6.Text = "宽:";
this.label6.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// NumLabelH
//
......@@ -410,6 +417,7 @@
this.NumLabelH.Name = "NumLabelH";
this.NumLabelH.Size = new System.Drawing.Size(131, 24);
this.NumLabelH.TabIndex = 23;
this.NumLabelH.Tag = "not";
this.NumLabelH.Value = new decimal(new int[] {
1,
0,
......@@ -432,6 +440,7 @@
this.NumLabelW.Name = "NumLabelW";
this.NumLabelW.Size = new System.Drawing.Size(131, 24);
this.NumLabelW.TabIndex = 22;
this.NumLabelW.Tag = "not";
this.NumLabelW.Value = new decimal(new int[] {
1,
0,
......@@ -517,7 +526,6 @@
private System.Windows.Forms.Button BtnLabelNew;
private System.Windows.Forms.Button BtnLabelDel;
private System.Windows.Forms.Button BtnRename;
private System.Windows.Forms.Button BtnPrintTest;
private System.Windows.Forms.Button BtnSave;
private System.Windows.Forms.Button BtnFieldAdd;
private System.Windows.Forms.Button BtnFieldDel;
......@@ -541,5 +549,6 @@
private System.Windows.Forms.NumericUpDown NumLabelW;
private System.Windows.Forms.Label label_labelsize;
private System.Windows.Forms.PictureBox pictureBox1;
public System.Windows.Forms.Button BtnPrintTest;
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ using PrintLabel;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Management;
using System.Net.NetworkInformation;
using System.Printing;
......@@ -326,22 +327,24 @@ namespace Asa
Bitmap bmp = null;
try
{
bmp = PrintPreview(key);
bmp = PrintPreview(key);
bmp.Save(Path.Combine(System.Windows.Forms.Application.StartupPath, "label.bmp"));
var mm = Common.PxToMM(bmp.Width);
var nn = Common.PxToMM(bmp.Height);
TSCSDK.driver TSCLIB_DLL = new TSCSDK.driver();
TSCLIB_DLL.openport(tscConfig.PrinterName);
TSCLIB_DLL.sendcommand($"SIZE {mm:0.00} mm, {nn:0.00} mm");
TSCLIB_DLL.sendcommand($"GAP {tscConfig.Gap} mm,{tscConfig.GapOffset} mm");
//TSCLIB_DLL.sendcommand($"GAP {tscConfig.Gap} mm,{tscConfig.GapOffset} mm");
//TSCLIB_DLL.sendcommand("SET STRIPER ON");//撕纸状态
//TSCLIB_DLL.sendcommand("SET CUTTER OFF");//裁剪模式
//TSCLIB_DLL.sendcommand($"SET PEEL ON");//剥离模式
//TSCLIB_DLL.sendcommand("SET RIBBON ON"); //使用碳带
//TSCLIB_DLL.sendcommand("SET PEEL OFF");//剥离模式
//TSCLIB_DLL.sendcommand("SET RIBBON OFF"); //使用碳带
//TSCLIB_DLL.sendcommand("SET ENCODER OFF"); //碳带编码器检测
TSCLIB_DLL.sendcommand($"OFFSET {tscConfig.Offset} mm"); //出纸偏移
TSCLIB_DLL.sendcommand($"SPEED {tscConfig.Speed}"); //速度最大15
TSCLIB_DLL.sendcommand($"DENSITY {tscConfig.Density}"); //浓度最大15
TSCLIB_DLL.sendcommand($"DIRECTION {tscConfig.Direction}");
//TSCLIB_DLL.sendcommand($"OFFSET {tscConfig.Offset} mm"); //出纸偏移
//TSCLIB_DLL.sendcommand($"SPEED {tscConfig.Speed}"); //速度最大15
//TSCLIB_DLL.sendcommand($"DENSITY {tscConfig.Density}"); //浓度最大15
//TSCLIB_DLL.sendcommand($"DIRECTION {tscConfig.Direction}");
TSCLIB_DLL.clearbuffer();
TSCLIB_DLL.sendpicture(tscConfig.x, tscConfig.y, bmp);
......@@ -486,7 +489,58 @@ namespace Asa
return true;
//Console.WriteLine("usbportqueryprinter:" + TSCLIB_DLL.usbportqueryprinter());
}
TscStauts CheckTscStatus() {
public bool PrintCommandToTsc(string command, TscConfig tscConfig, out TscStauts tscStauts)
{
tscStauts = CheckTscStatus();
if (tscStauts != 0)
{
var err = (TscStauts)tscStauts;
Console.WriteLine($"Error: {err}");
return false;
}
var printt = Task.Run(() =>
{
try
{
TSCSDK.driver TSCLIB_DLL = new TSCSDK.driver();
TSCLIB_DLL.openport(tscConfig.PrinterName);
var commands = command.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < commands.Length; i++) {
if (!commands[i].StartsWith("PRINT"))
TSCLIB_DLL.sendcommand(commands[i].Trim());
else
TSCLIB_DLL.printlabel("1", "1");
}
TSCLIB_DLL.closeport();
}
catch (Exception e)
{
}
finally
{
//bmp?.Dispose();
}
});
tscStauts = CheckTscStatus();
Console.WriteLine("After print:" + tscStauts);
Task.Delay(500).Wait();
if (printt.IsCompleted)
{
}
if (tscStauts == TscStauts.打印中 || tscStauts == TscStauts.准备就绪 || tscStauts == TscStauts.None)
{
return true;
}
else
{
return false;
}
//Console.WriteLine("usbportqueryprinter:" + TSCLIB_DLL.usbportqueryprinter());
}
public TscStauts CheckTscStatus() {
//return TscStauts.准备就绪;
TscStauts s = TscStauts.None;
var t = Task.Run(() => {
......@@ -504,7 +558,7 @@ namespace Asa
}
}
});
if (!t.Wait(1000))
if (!t.Wait(3000))
Console.WriteLine("usbportqueryprinter time out");
return s;
}
......
......@@ -41,15 +41,18 @@
this.advanceConfigEdit1 = new ConfigHelper.AdvanceConfigEdit();
this.button7 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.txt_command = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button6 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(13, 13);
this.button1.Margin = new System.Windows.Forms.Padding(4);
this.button1.Location = new System.Drawing.Point(9, 9);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(184, 74);
this.button1.Size = new System.Drawing.Size(123, 49);
this.button1.TabIndex = 0;
this.button1.Text = "编辑";
this.button1.UseVisualStyleBackColor = true;
......@@ -57,19 +60,17 @@
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(205, 14);
this.textBox1.Margin = new System.Windows.Forms.Padding(4);
this.textBox1.Location = new System.Drawing.Point(137, 9);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(241, 28);
this.textBox1.Size = new System.Drawing.Size(162, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "test2";
//
// button2
//
this.button2.Location = new System.Drawing.Point(205, 102);
this.button2.Margin = new System.Windows.Forms.Padding(4);
this.button2.Location = new System.Drawing.Point(137, 68);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(150, 34);
this.button2.Size = new System.Drawing.Size(100, 23);
this.button2.TabIndex = 2;
this.button2.Text = "加载";
this.button2.UseVisualStyleBackColor = true;
......@@ -77,10 +78,9 @@
//
// button3
//
this.button3.Location = new System.Drawing.Point(13, 102);
this.button3.Margin = new System.Windows.Forms.Padding(4);
this.button3.Location = new System.Drawing.Point(9, 68);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(184, 74);
this.button3.Size = new System.Drawing.Size(123, 49);
this.button3.TabIndex = 3;
this.button3.Text = "打印";
this.button3.UseVisualStyleBackColor = true;
......@@ -88,19 +88,17 @@
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(205, 59);
this.textBox2.Margin = new System.Windows.Forms.Padding(4);
this.textBox2.Location = new System.Drawing.Point(137, 39);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(241, 28);
this.textBox2.Size = new System.Drawing.Size(162, 21);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "ZDesigner GT800 (EPL)";
//
// button4
//
this.button4.Location = new System.Drawing.Point(205, 144);
this.button4.Margin = new System.Windows.Forms.Padding(4);
this.button4.Location = new System.Drawing.Point(137, 96);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(150, 34);
this.button4.Size = new System.Drawing.Size(100, 23);
this.button4.TabIndex = 5;
this.button4.Text = "获取状态";
this.button4.UseVisualStyleBackColor = true;
......@@ -108,19 +106,17 @@
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(456, 426);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4);
this.pictureBox1.Location = new System.Drawing.Point(216, 252);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(376, 244);
this.pictureBox1.Size = new System.Drawing.Size(251, 163);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// button5
//
this.button5.Location = new System.Drawing.Point(13, 188);
this.button5.Margin = new System.Windows.Forms.Padding(4);
this.button5.Location = new System.Drawing.Point(9, 125);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(184, 70);
this.button5.Size = new System.Drawing.Size(123, 47);
this.button5.TabIndex = 7;
this.button5.Text = "button5";
this.button5.UseVisualStyleBackColor = true;
......@@ -128,10 +124,9 @@
//
// btn_tsc
//
this.btn_tsc.Location = new System.Drawing.Point(24, 437);
this.btn_tsc.Margin = new System.Windows.Forms.Padding(4);
this.btn_tsc.Location = new System.Drawing.Point(16, 291);
this.btn_tsc.Name = "btn_tsc";
this.btn_tsc.Size = new System.Drawing.Size(184, 63);
this.btn_tsc.Size = new System.Drawing.Size(123, 42);
this.btn_tsc.TabIndex = 8;
this.btn_tsc.Text = "TSC Print";
this.btn_tsc.UseVisualStyleBackColor = true;
......@@ -140,26 +135,24 @@
// cb_labelname
//
this.cb_labelname.FormattingEnabled = true;
this.cb_labelname.Location = new System.Drawing.Point(24, 378);
this.cb_labelname.Margin = new System.Windows.Forms.Padding(4);
this.cb_labelname.Location = new System.Drawing.Point(16, 252);
this.cb_labelname.Name = "cb_labelname";
this.cb_labelname.Size = new System.Drawing.Size(238, 26);
this.cb_labelname.Size = new System.Drawing.Size(160, 20);
this.cb_labelname.TabIndex = 9;
//
// advanceConfigEdit1
//
this.advanceConfigEdit1.Location = new System.Drawing.Point(456, 13);
this.advanceConfigEdit1.Margin = new System.Windows.Forms.Padding(6);
this.advanceConfigEdit1.Location = new System.Drawing.Point(304, 9);
this.advanceConfigEdit1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.advanceConfigEdit1.Name = "advanceConfigEdit1";
this.advanceConfigEdit1.Size = new System.Drawing.Size(655, 391);
this.advanceConfigEdit1.Size = new System.Drawing.Size(437, 209);
this.advanceConfigEdit1.TabIndex = 10;
//
// button7
//
this.button7.Location = new System.Drawing.Point(24, 508);
this.button7.Margin = new System.Windows.Forms.Padding(4);
this.button7.Location = new System.Drawing.Point(16, 339);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(184, 63);
this.button7.Size = new System.Drawing.Size(123, 42);
this.button7.TabIndex = 12;
this.button7.Text = "X400";
this.button7.UseVisualStyleBackColor = true;
......@@ -167,20 +160,52 @@
//
// button10
//
this.button10.Location = new System.Drawing.Point(24, 588);
this.button10.Margin = new System.Windows.Forms.Padding(4);
this.button10.Location = new System.Drawing.Point(16, 392);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(184, 63);
this.button10.Size = new System.Drawing.Size(123, 42);
this.button10.TabIndex = 15;
this.button10.Text = "X6";
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// txt_command
//
this.txt_command.Dock = System.Windows.Forms.DockStyle.Fill;
this.txt_command.Location = new System.Drawing.Point(3, 17);
this.txt_command.Margin = new System.Windows.Forms.Padding(0);
this.txt_command.Multiline = true;
this.txt_command.Name = "txt_command";
this.txt_command.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txt_command.Size = new System.Drawing.Size(355, 292);
this.txt_command.TabIndex = 16;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txt_command);
this.groupBox1.Location = new System.Drawing.Point(497, 238);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(361, 312);
this.groupBox1.TabIndex = 17;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "RAW Command";
//
// button6
//
this.button6.Location = new System.Drawing.Point(681, 556);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(177, 23);
this.button6.TabIndex = 18;
this.button6.Text = "Send";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1366, 911);
this.ClientSize = new System.Drawing.Size(911, 607);
this.Controls.Add(this.button6);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button10);
this.Controls.Add(this.button7);
this.Controls.Add(this.advanceConfigEdit1);
......@@ -194,12 +219,13 @@
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -220,6 +246,9 @@
private ConfigHelper.AdvanceConfigEdit advanceConfigEdit1;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.TextBox txt_command;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button button6;
}
}
......@@ -23,10 +23,12 @@ namespace PrintLabel_Test
private void Form1_Load(object sender, EventArgs e)
{
print = new Asa.PrintLabel(Application.StartupPath + "\\Label",300);
print = new Asa.PrintLabel(Application.StartupPath + "\\Label",100);
print.PrintStatusChanged += Print_PrintStatusChanged;
loadlabelname();
ConfigHelper.Config.PropertyBind("txt_command", txt_command, "Text", "TextChanged", "");
}
private void Print_PrintStatusChanged(Asa.PrintLabel.PrinterStatus sta, string msg)
......@@ -132,5 +134,11 @@ namespace PrintLabel_Test
tscConfig.Directions = ConfigHelper.Config.Get("Tsc_Directions", 1);
print.PrintToTsc_X6(keys, tscConfig, out TscStauts tscStauts);
}
private void button6_Click(object sender, EventArgs e)
{
TscConfig tscConfig = new TscConfig();
print.PrintCommandToTsc(txt_command.Text.Trim(), tscConfig, out TscStauts tscStauts);
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!