Commit 5d993d2e 刘韬

添加TSC打印机支持

1 个父辈 feb17f26
...@@ -23,9 +23,17 @@ namespace DeviceLibrary ...@@ -23,9 +23,17 @@ namespace DeviceLibrary
public bool Connection(string port) { public bool Connection(string port) {
Port = port; Port = port;
if (port.ToLower()=="usb") if (port.ToLower() == "usb")
zebraManger = new ZebraPrinterHelper.ZebraManger("", ZebraPrinterHelper.ConnectionType.UsbDirect); zebraManger = new ZebraPrinterHelper.ZebraManger("", ZebraPrinterHelper.ConnectionType.UsbDirect);
else else
if (port.ToLower().Contains("tsc"))
{
zebraManger = null;
print = new Asa.PrintLabel(Application.StartupPath + "\\Label", 100);
print.Printer(port, false);
return true;
}
else
zebraManger = new ZebraPrinterHelper.ZebraManger(Port, ZebraPrinterHelper.ConnectionType.Network); zebraManger = new ZebraPrinterHelper.ZebraManger(Port, ZebraPrinterHelper.ConnectionType.Network);
if (!zebraManger.Connection(out string msg)) if (!zebraManger.Connection(out string msg))
{ {
...@@ -67,26 +75,33 @@ namespace DeviceLibrary ...@@ -67,26 +75,33 @@ namespace DeviceLibrary
bool Print(string labelname,Dictionary<string, string> data,out string msg) { bool Print(string labelname,Dictionary<string, string> data,out string msg) {
msg = ""; msg = "";
print.LoadLabel(labelname); print.LoadLabel(labelname);
var bmp = print.PrintPreview(data); if (zebraManger != null)
//LogUtil.info("标签图像生成");
//bmp.Save("currentlabel.bmp");
try
{ {
//if (!zebraManger.PrintImage(bmp,bmp.Width*3, bmp.Height * 3, out msg, false)) var bmp = print.PrintPreview(data);
if (!zebraManger.PrintImage(bmp, out msg, false)) //LogUtil.info("标签图像生成");
//bmp.Save("currentlabel.bmp");
try
{
//if (!zebraManger.PrintImage(bmp,bmp.Width*3, bmp.Height * 3, out msg, false))
if (!zebraManger.PrintImage(bmp, out msg, false))
{
LogUtil.error(msg);
return false;
}
}
catch (Exception ex)
{ {
LogUtil.error(msg); LogUtil.error(ex.ToString());
return false; return false;
} }
finally
{
bmp.Dispose();
}
} }
catch (Exception ex) else
{
LogUtil.error(ex.ToString());
return false;
}
finally
{ {
bmp.Dispose(); print.Print(data);
} }
return true; return true;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!