1.1.2 Alpha Bulid 20231025

This commit is contained in:
hehaoyang 2023-10-25 11:59:04 +08:00
parent c150c40902
commit 03a8ab215c
4 changed files with 71 additions and 64 deletions

12
.gitignore vendored
View File

@ -315,3 +315,15 @@ PrinterClient/PrinterClient/._BoxServer.cs
PrinterClient/PrinterClient/._Program.cs
PrinterClient/PrinterClient/._TaskDispatcher.cs
._printer.sh
其他资料/._gcm
其他资料/._gcm.zip
其他资料/gcm/._gcm.bin
其他资料/gcm/._install.sh
其他资料/gcm/gcm.bin
其他资料/gcm/install.sh
其他资料/install.zip
PrinterClient/.vs/PrinterClient/FileContentIndex/380efad8-1bf7-477a-a2ed-10befb6e69e8.vsidx
PrinterClient/.vs/PrinterClient/FileContentIndex/00734b31-8f07-4a4d-a6cf-df51dca98a72.vsidx
PrinterClient/.vs/PrinterClient/FileContentIndex/5fa9dda6-6f0e-44f6-aece-97d5743e32ec.vsidx
PrinterClient/.vs/PrinterClient/FileContentIndex/2d42fda6-5f3b-4099-a3df-2a7bea5a8424.vsidx
PrinterClient/.vs/PrinterClient/FileContentIndex/8b95cfed-56f9-4e94-abb0-9e49f4e05051.vsidx

View File

@ -16,6 +16,10 @@ static class ReadMe
static readonly Dictionary<string, List<string>> Versions = new()
{
["1.1.2 Alpha Bulid 20231025"] = new List<string>()
{
"优化 Windows 模式下代码",
},
["1.1.1 Alpha Bulid 20231019"] = new List<string>()
{
"修复: 无法检测到\"打印中\"状态的BUG",

View File

@ -145,6 +145,8 @@ namespace PrinterClient
{
var value = GetStatus();
Console.WriteLine($"{value:X4}");
switch (value)
{
case PrinterStatus.Normal:
@ -163,44 +165,56 @@ namespace PrinterClient
public static string Serial = "";
private static void FindSerial()
{
/* 获取打印机信息 */
if (TaskDispatcher.ExecuteCommand("lpinfo", "-v", out string result))
{
if (result.IndexOf("gutenprint52+usb://Dai+Nippon+Printing/Photo+Printer?serial=") == -1)
{
return;
}
var arrays = result.Split(new char[] { '\r', '\n' });
var directs = arrays.ToList().FindAll(ar => ar.IndexOf("gutenprint52+usb://Dai+Nippon+Printing/Photo+Printer?serial=") != -1);
string code = "";
foreach (var direct in directs)
{
int a = direct.LastIndexOf("serial="), b = direct.LastIndexOf("&backend");
if (a == -1 || b == -1)
continue;
code = direct.Substring(a + 7, b - a - 7);
if (code.IndexOf("NONE_UNKNOWN") != -1)
continue;
break;
}
if (code.Equals("NONE_UNKNOWN"))
Serial = "";
else
Serial = code;
}
}
private static PrinterStatus GetStatus()
{
string code = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var res = CyStatus.GetSerialNo(rx1_handle, ref code);
if (res == int.MinValue)
return;
Serial = code;
}
else
{
/* 获取打印机信息 */
if (TaskDispatcher.ExecuteCommand("lpinfo", "-v", out string result))
{
if (result.IndexOf("gutenprint52+usb://Dai+Nippon+Printing/Photo+Printer?serial=") == -1)
{
return;
}
var arrays = result.Split(new char[] { '\r', '\n' });
var directs = arrays.ToList().FindAll(ar => ar.IndexOf("gutenprint52+usb://Dai+Nippon+Printing/Photo+Printer?serial=") != -1);
foreach (var direct in directs)
{
int a = direct.LastIndexOf("serial="), b = direct.LastIndexOf("&backend");
if (a == -1 || b == -1)
continue;
code = direct.Substring(a + 7, b - a - 7);
if (code.IndexOf("NONE_UNKNOWN") != -1)
continue;
break;
}
if (code.Equals("NONE_UNKNOWN"))
Serial = "";
else
Serial = code;
}
}
}
private static PrinterStatus GetStatus()
{
PrinterStatus status = PrinterStatus.Normal;
@ -376,10 +390,6 @@ namespace PrinterClient
}
else
{
//TaskDispatcher.AsyncExecuteCommand("lpr", file);
//TaskDispatcher.ExecuteCommand("PrintPhoto", $"DS-RX1HS {file}", out string result);
string file_format = "TextGraphics", print_mode = "RGB", print_size = "B7";
switch (file_format_id)
@ -444,28 +454,6 @@ namespace PrinterClient
return false;
}
public static void SetProperty(string name, string value) => TaskDispatcher.AsyncExecuteCommand("lpoptions", $"-o {name}={value}");
public static bool GetProperty(string name, out string value)
{
value = string.Empty;
try
{
if (TaskDispatcher.ExecuteCommand("lpoptions", $"-l", out string result))
{
result = result.Split(new char[] { '\n', '\r' }).ToList().Find(s => s.IndexOf(name) != -1);
value = result.Split(' ').ToList().Find(s => s[0] == '*').Remove(0, 1);
return true;
}
}
catch { }
return false;
}
}
public class LprEntries

View File

@ -1,5 +1,8 @@
# PrinterClient 版本历史介绍
## 1.1.2 Alpha Bulid 20231025
* 优化 Windows 模式下代码
## 1.1.1 Alpha Bulid 20231019
* 修复: 无法检测到"打印中"状态的BUG
* 修复: 下载延时大的BUG