Commit 1afba36f 刘韬

1

1 个父辈 176e4433
...@@ -95,7 +95,7 @@ namespace PrintLabel_Test ...@@ -95,7 +95,7 @@ namespace PrintLabel_Test
MessageBox.Show(msg); MessageBox.Show(msg);
} }
else else
MessageBox.Show("连接成功"); MessageBox.Show("连接成功,dpi:"+ zebraManger.PrinterDPI);
} }
private void button5_Click(object sender, EventArgs e) private void button5_Click(object sender, EventArgs e)
......
...@@ -48,6 +48,15 @@ namespace ZebraPrinterHelper ...@@ -48,6 +48,15 @@ namespace ZebraPrinterHelper
{ {
try try
{ {
if (string.IsNullOrEmpty(ConnectionEndpoint)) {
var dl = GetUsbDirectAddress();
if (dl.Count == 0)
{
new Exception("没有找到打印机");
}
ConnectionEndpoint = dl.First().Key;
}
return new UsbConnection(ConnectionEndpoint); return new UsbConnection(ConnectionEndpoint);
} }
catch (Exception e) catch (Exception e)
...@@ -161,8 +170,8 @@ namespace ZebraPrinterHelper ...@@ -161,8 +170,8 @@ namespace ZebraPrinterHelper
try try
{ {
ZebraImageI image = ZebraImageFactory.GetImage(bmp); ZebraImageI image = ZebraImageFactory.GetImage(bmp);
var width = image.Width * (PrinterDPI/203f); var width = image.Width; // * (PrinterDPI/203f);
var height = image.Height * (PrinterDPI / 203f); var height = image.Height; // * (PrinterDPI / 203f);
printer.PrintImage(image, 0, 0, (int)width, (int)height, false); printer.PrintImage(image, 0, 0, (int)width, (int)height, false);
return true; return true;
} }
...@@ -208,6 +217,7 @@ namespace ZebraPrinterHelper ...@@ -208,6 +217,7 @@ namespace ZebraPrinterHelper
status = GetStatus(); status = GetStatus();
if (status == null) if (status == null)
{ {
Close();
ReTryCount++; ReTryCount++;
if (ReTryCount > 3) if (ReTryCount > 3)
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E4F7AFC7-2F6D-4685-8350-3C05697428EA}</ProjectGuid> <ProjectGuid>{E4F7AFC7-2F6D-4685-8350-3C05697428EA}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ZebraPrinterHelper</RootNamespace> <RootNamespace>ZebraPrinterHelper</RootNamespace>
<AssemblyName>ZebraPrinterHelper</AssemblyName> <AssemblyName>ZebraPrinterHelper</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SdkApi.Core"> <Reference Include="SdkApi.Core">
<HintPath>..\Source\Sdk\SdkApi.Core.dll</HintPath> <HintPath>..\Source\Sdk\SdkApi.Core.dll</HintPath>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!