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;
}
......
......@@ -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!