Commit fc66978b 刘韬

1

1 个父辈 75d9da12
...@@ -250,7 +250,6 @@ namespace BLL ...@@ -250,7 +250,6 @@ namespace BLL
CheckText("等待中"); CheckText("等待中");
} }
islast = false; islast = false;
} }
// 创建不包含自增ID的临时字典进行比较 // 创建不包含自增ID的临时字典进行比较
//var keyWithoutReelID = new Dictionary<string, string>(key); //var keyWithoutReelID = new Dictionary<string, string>(key);
......
using Asa.FaceControl; using Asa.FaceControl;
using BLL; using BLL;
using DocumentFormat.OpenXml.Bibliography;
using HandyControl.Properties.Langs;
using HandyControl.Tools.Extension; using HandyControl.Tools.Extension;
using Model; using Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using OnlineStore.Common.util; using OnlineStore.Common.util;
using SmartScan.Form;
using SmartScan.SetControl.WPF; using SmartScan.SetControl.WPF;
using SmartScan.SetControl.WPF.Model; using SmartScan.SetControl.WPF.Model;
using System; using System;
...@@ -15,14 +12,11 @@ using System.Data; ...@@ -15,14 +12,11 @@ using System.Data;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.RightsManagement;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Script.Serialization; using System.Web.Script.Serialization;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Forms.Integration; using System.Windows.Forms.Integration;
using System.Windows.Input;
using static BLL.BLLCommon; using static BLL.BLLCommon;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox; using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
...@@ -44,7 +38,7 @@ namespace SmartScan ...@@ -44,7 +38,7 @@ namespace SmartScan
public static FrmMain mon_frmMain; public static FrmMain mon_frmMain;
public FrmMain() public FrmMain()
{ {
//成静态变量赋值为本窗体 //成静态变量赋值为本窗体
//kmon //kmon
//2025-6-24 //2025-6-24
...@@ -52,8 +46,8 @@ namespace SmartScan ...@@ -52,8 +46,8 @@ namespace SmartScan
InitializeComponent(); InitializeComponent();
// 初始化导航栏 // 初始化导航栏
InitializeMFTop(); InitializeMFTop();
// 初始化菜单 // 初始化菜单
InitializeWpfMenu(); InitializeWpfMenu();
this.Load += Ns_rigth_Load; this.Load += Ns_rigth_Load;
BtnStart.Tag = "not"; BtnStart.Tag = "not";
if (Config.AppUI_HideLogo) if (Config.AppUI_HideLogo)
...@@ -68,7 +62,7 @@ namespace SmartScan ...@@ -68,7 +62,7 @@ namespace SmartScan
InitializeImageControls(); InitializeImageControls();
// 添加窗体大小调整事件 // 添加窗体大小调整事件
this.Resize += YourWinFormClass_Resize; this.Resize += YourWinFormClass_Resize;
} }
private void YourWinFormClass_Resize(object sender, EventArgs e) private void YourWinFormClass_Resize(object sender, EventArgs e)
{ {
...@@ -117,7 +111,7 @@ namespace SmartScan ...@@ -117,7 +111,7 @@ namespace SmartScan
//拖动 //拖动
MF_top.DragRequested += MF_top_DragRequested; MF_top.DragRequested += MF_top_DragRequested;
} }
private bool isDragging = false; private bool isDragging = false;
private System.Drawing.Point dragStartPoint; private System.Drawing.Point dragStartPoint;
...@@ -217,9 +211,9 @@ namespace SmartScan ...@@ -217,9 +211,9 @@ namespace SmartScan
catch (Exception ex) catch (Exception ex)
{ {
} }
} }
/// <summary> /// <summary>
...@@ -247,9 +241,9 @@ namespace SmartScan ...@@ -247,9 +241,9 @@ namespace SmartScan
if (wpfImagePanel != null) if (wpfImagePanel != null)
{ // 创建WPF图片查看控件实例 { // 创建WPF图片查看控件实例
// 将ElementHost添加到面板中 // 将ElementHost添加到面板中
wpfImagePanel.Controls.Clear(); // 清除Panel中的所有控件 wpfImagePanel.Controls.Clear(); // 清除Panel中的所有控件
...@@ -258,7 +252,8 @@ namespace SmartScan ...@@ -258,7 +252,8 @@ namespace SmartScan
// 默认不显示WPF控件 // 默认不显示WPF控件
wpfImagePanel.Visible = true; wpfImagePanel.Visible = true;
// 注册SizeChanged事件 // 注册SizeChanged事件
wpfImagePanel.SizeChanged += (sender, args) => { wpfImagePanel.SizeChanged += (sender, args) =>
{
// 当Panel大小改变时,通知WPF控件重新适应图片 // 当Panel大小改变时,通知WPF控件重新适应图片
if (Imagetest != null) if (Imagetest != null)
{ {
...@@ -280,9 +275,9 @@ namespace SmartScan ...@@ -280,9 +275,9 @@ namespace SmartScan
public void Showlogs(string text) public void Showlogs(string text)
{ {
this.Invoke((MethodInvoker)delegate { wpfMenu.ShowLog.Text = text; }); this.Invoke((MethodInvoker)delegate { wpfMenu.ShowLog.Text = text; });
} }
// 在主窗体类中添加 // 在主窗体类中添加
public image_text GetImageViewer() public image_text GetImageViewer()
...@@ -298,11 +293,11 @@ namespace SmartScan ...@@ -298,11 +293,11 @@ namespace SmartScan
ElementHost host = new ElementHost(); ElementHost host = new ElementHost();
host.Dock = DockStyle.Left; host.Dock = DockStyle.Left;
host.Width = 205; host.Width = 205;
host.Height = this.ClientSize.Height - 55-10; // 减去标题区域的高度(假设为40像素) host.Height = this.ClientSize.Height - 55 - 10; // 减去标题区域的高度(假设为40像素)
// wpfMenu.Button1Text = "设置"; // wpfMenu.Button1Text = "设置";
host.Location = new Point(10, 55); // 将控件放在标题区域下方 host.Location = new Point(10, 55); // 将控件放在标题区域下方
host.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; // 确保在窗体大小调整时保持相对位置 host.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; // 确保在窗体大小调整时保持相对位置
// 创建WPF菜单控件 // 创建WPF菜单控件
wpfMenu = new VerticalMenuControl(); wpfMenu = new VerticalMenuControl();
// 设置属性 // 设置属性
...@@ -311,7 +306,7 @@ namespace SmartScan ...@@ -311,7 +306,7 @@ namespace SmartScan
// 添加事件处理 // 添加事件处理
wpfMenu.BtnStartClicked += (s, e) => wpfMenu.BtnStartClicked += (s, e) =>
{ {
LogNet.log.Info("按钮点击触发Work"); LogNet.log.Info("按钮点击触发Work");
if (BLLCommon.config.EnabledCamera) if (BLLCommon.config.EnabledCamera)
{ {
...@@ -322,13 +317,14 @@ namespace SmartScan ...@@ -322,13 +317,14 @@ namespace SmartScan
//scanWork.TouchOff(); //scanWork.TouchOff();
}); });
} }
else{ else
{
string YU = BLLCommon.config.Language; string YU = BLLCommon.config.Language;
if (YU=="English") if (YU == "English")
{ {
bool result = NeoAlertBox.Show("Camera Not Connected", "Unable to detect the camera device or the camera device is offline.\nPlease check the camera connection status.", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("Camera Not Connected", "Unable to detect the camera device or the camera device is offline.\nPlease check the camera connection status.", AlertType.Warning, "NEO SCAN", true);
} }
else if (YU=="日语") else if (YU == "日语")
{ {
bool result = NeoAlertBox.Show("カメラが接続されていません", "カメラデバイスが検出できませんでした/カメラデバイスがオフライン状態です。\nカメラの接続状態をご確認ください。", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("カメラが接続されていません", "カメラデバイスが検出できませんでした/カメラデバイスがオフライン状態です。\nカメラの接続状態をご確認ください。", AlertType.Warning, "NEO SCAN", true);
} }
...@@ -336,9 +332,9 @@ namespace SmartScan ...@@ -336,9 +332,9 @@ namespace SmartScan
{ {
bool result = NeoAlertBox.Show("相机未连接", "无法检测到相机设备或相机设备处于离线状态。\n请检查相机连接状态。", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("相机未连接", "无法检测到相机设备或相机设备处于离线状态。\n请检查相机连接状态。", AlertType.Warning, "NEO SCAN", true);
} }
} }
}; };
wpfMenu.BtnRetrospectClicked += (s, e) => wpfMenu.BtnRetrospectClicked += (s, e) =>
{ {
...@@ -347,7 +343,8 @@ namespace SmartScan ...@@ -347,7 +343,8 @@ namespace SmartScan
monitor.Pause = false; monitor.Pause = false;
}; };
wpfMenu.BtnSetClicked += (s, e) => { wpfMenu.BtnSetClicked += (s, e) =>
{
monitor.Pause = true; monitor.Pause = true;
FrmSet set = new FrmSet(); FrmSet set = new FrmSet();
set.Width = PicShow.Width; set.Width = PicShow.Width;
...@@ -374,7 +371,8 @@ namespace SmartScan ...@@ -374,7 +371,8 @@ namespace SmartScan
if (YU == "English") if (YU == "English")
{ {
bool result = NeoAlertBox.Show("", $"Application not found: {appPath}", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("", $"Application not found: {appPath}", AlertType.Warning, "NEO SCAN", true);
}else if (YU == "日语") }
else if (YU == "日语")
{ {
bool result = NeoAlertBox.Show("", $"アプリケーションが見つかりません: {appPath}", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("", $"アプリケーションが見つかりません: {appPath}", AlertType.Warning, "NEO SCAN", true);
} }
...@@ -382,7 +380,7 @@ namespace SmartScan ...@@ -382,7 +380,7 @@ namespace SmartScan
{ {
bool result = NeoAlertBox.Show("", $"找不到应用程序: {appPath}", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("", $"找不到应用程序: {appPath}", AlertType.Warning, "NEO SCAN", true);
} }
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -400,8 +398,8 @@ namespace SmartScan ...@@ -400,8 +398,8 @@ namespace SmartScan
{ {
bool result = NeoAlertBox.Show("", $"启动应用程序时出错: {ex.Message}", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("", $"启动应用程序时出错: {ex.Message}", AlertType.Warning, "NEO SCAN", true);
} }
} }
}; };
wpfMenu.BtnAboutClicked += (s, e) => wpfMenu.BtnAboutClicked += (s, e) =>
...@@ -421,7 +419,7 @@ namespace SmartScan ...@@ -421,7 +419,7 @@ namespace SmartScan
//scanWork.TouchOff(); //scanWork.TouchOff();
}); });
}; };
// 将WPF控件设置为ElementHost的子控件 // 将WPF控件设置为ElementHost的子控件
host.Child = wpfMenu; host.Child = wpfMenu;
...@@ -429,12 +427,12 @@ namespace SmartScan ...@@ -429,12 +427,12 @@ namespace SmartScan
this.Controls.Add(host); this.Controls.Add(host);
// 确保它位于Z顺序的顶部 // 确保它位于Z顺序的顶部
host.BringToFront(); host.BringToFront();
} }
public void UpdateNS_VericalMenuControl() public void UpdateNS_VericalMenuControl()
{ {
string YU = BLLCommon.config.Language; string YU = BLLCommon.config.Language;
...@@ -443,7 +441,7 @@ namespace SmartScan ...@@ -443,7 +441,7 @@ namespace SmartScan
YU = "en-US"; YU = "en-US";
} }
else if(YU=="日语") else if (YU == "日语")
{ {
YU = "ja-JP"; YU = "ja-JP";
} }
...@@ -454,7 +452,7 @@ namespace SmartScan ...@@ -454,7 +452,7 @@ namespace SmartScan
LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR); LanguageWwitchover.LoadPath(FilePath.LANGUAGE_DIR);
LanguageWwitchover.LoadLanguage(YU); LanguageWwitchover.LoadLanguage(YU);
wpfMenu.ApplyLanguage(); wpfMenu.ApplyLanguage();
} }
/// <summary> /// <summary>
/// 主界面右侧初始化 /// 主界面右侧初始化
...@@ -483,7 +481,7 @@ namespace SmartScan ...@@ -483,7 +481,7 @@ namespace SmartScan
elementHost = new ElementHost(); elementHost = new ElementHost();
elementHost.Dock = DockStyle.Fill; elementHost.Dock = DockStyle.Fill;
elementHost.Child = wpfControl; elementHost.Child = wpfControl;
// 清除 PnlExtension 的现有内容 // 清除 PnlExtension 的现有内容
PnlExtension.Controls.Clear(); PnlExtension.Controls.Clear();
...@@ -510,7 +508,7 @@ namespace SmartScan ...@@ -510,7 +508,7 @@ namespace SmartScan
if (result) if (result)
{ {
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色 wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false; scanWork.WaitLabelRecheck = false;
//lastKeys = null; //lastKeys = null;
string text = ""; string text = "";
if (BLLCommon.config.Language.Equals("English")) if (BLLCommon.config.Language.Equals("English"))
...@@ -544,7 +542,7 @@ namespace SmartScan ...@@ -544,7 +542,7 @@ namespace SmartScan
{ {
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色 wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false; scanWork.WaitLabelRecheck = false;
//lastKeys = null; //lastKeys = null;
string text = ""; string text = "";
if (BLLCommon.config.Language.Equals("English")) if (BLLCommon.config.Language.Equals("English"))
...@@ -573,23 +571,23 @@ namespace SmartScan ...@@ -573,23 +571,23 @@ namespace SmartScan
if (result) if (result)
{ {
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色 wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false; scanWork.WaitLabelRecheck = false;
//lastKeys = null; //lastKeys = null;
string text = ""; string text = "";
if (BLLCommon.config.Language.Equals("English")) if (BLLCommon.config.Language.Equals("English"))
{ {
text = "Waiting"; text = "Waiting";
} }
else if (BLLCommon.config.Language.Equals("日语")) else if (BLLCommon.config.Language.Equals("日语"))
{ {
text = "待機中"; text = "待機中";
} }
else else
{ {
text = "等待中"; text = "等待中";
} }
wpfControl.SetSkipButtonVisibility(false); wpfControl.SetSkipButtonVisibility(false);
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
...@@ -641,7 +639,7 @@ namespace SmartScan ...@@ -641,7 +639,7 @@ namespace SmartScan
{ {
bool result = NeoAlertBox.Show("Print Error", "Unable to print label, no valid identification data", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("Print Error", "Unable to print label, no valid identification data", AlertType.Warning, "NEO SCAN", true);
} }
else if (YU =="日语") else if (YU == "日语")
{ {
bool result = NeoAlertBox.Show("印刷に异常が発生しました", "ラベルを印刷できません。有効な認識データがありません", AlertType.Warning, "NEO SCAN", true); bool result = NeoAlertBox.Show("印刷に异常が発生しました", "ラベルを印刷できません。有効な認識データがありません", AlertType.Warning, "NEO SCAN", true);
} }
...@@ -690,7 +688,7 @@ namespace SmartScan ...@@ -690,7 +688,7 @@ namespace SmartScan
else else
{ {
LblCameraExist.ForeColor = Color.Lime; LblCameraExist.ForeColor = Color.Lime;
wpfMenu.LblCameraExist.Foreground= System.Windows.Media.Brushes.Lime; wpfMenu.LblCameraExist.Foreground = System.Windows.Media.Brushes.Lime;
// 更新状态卡片 - 相机已启用且已连接 // 更新状态卡片 - 相机已启用且已连接
wpfMenu.UpdateCameraStatus(true, true); wpfMenu.UpdateCameraStatus(true, true);
return true; return true;
...@@ -699,7 +697,7 @@ namespace SmartScan ...@@ -699,7 +697,7 @@ namespace SmartScan
else else
{ {
LogNet.log.Info("相机已禁用"); LogNet.log.Info("相机已禁用");
LblCameraExist.ForeColor = Color.Lime; LblCameraExist.ForeColor = Color.Lime;
wpfMenu.LblCameraExist.Background = System.Windows.Media.Brushes.Red; wpfMenu.LblCameraExist.Background = System.Windows.Media.Brushes.Red;
// 更新状态卡片 - 相机已禁用 // 更新状态卡片 - 相机已禁用
wpfMenu.UpdateCameraStatus(false, false); wpfMenu.UpdateCameraStatus(false, false);
...@@ -707,20 +705,20 @@ namespace SmartScan ...@@ -707,20 +705,20 @@ namespace SmartScan
return true; return true;
} }
} }
private bool CheckIOModule() private bool CheckIOModule()
{ {
if (BLLCommon.config.EnabledIO) if (BLLCommon.config.EnabledIO)
{ {
BLLCommon.ioModule.DI_Changed_Event += IoModule_DI_Changed_Event; BLLCommon.ioModule.DI_Changed_Event += IoModule_DI_Changed_Event;
if (BLLCommon.ioModule.IsConn) if (BLLCommon.ioModule.IsConn)
{ {
LogNet.log.Info($"IO模块 {BLLCommon.ioModule.IP} 连接成功"); LogNet.log.Info($"IO模块 {BLLCommon.ioModule.IP} 连接成功");
wpfMenu.LblIOExist.Background = System.Windows.Media.Brushes.Lime; wpfMenu.LblIOExist.Background = System.Windows.Media.Brushes.Lime;
wpfMenu.LblIOExist.Content =$"IO模块 {BLLCommon.ioModule.IP} 连接成功"; wpfMenu.LblIOExist.Content = $"IO模块 {BLLCommon.ioModule.IP} 连接成功";
wpfMenu.UpdateIOStatus(true); wpfMenu.UpdateIOStatus(true);
LblIOExist.ForeColor = Color.Lime; LblIOExist.ForeColor = Color.Lime;
return true; return true;
} }
...@@ -737,7 +735,7 @@ namespace SmartScan ...@@ -737,7 +735,7 @@ namespace SmartScan
{ {
wpfMenu.UpdateIOStatus(false); wpfMenu.UpdateIOStatus(false);
LogNet.log.Info("IO模块已禁用"); LogNet.log.Info("IO模块已禁用");
LblIOExist.ForeColor = Color.Lime; LblIOExist.ForeColor = Color.Lime;
wpfMenu.LblIOExist.Background = System.Windows.Media.Brushes.Red; wpfMenu.LblIOExist.Background = System.Windows.Media.Brushes.Red;
wpfMenu.LblIOExist.Content = "IO模块已禁用"; wpfMenu.LblIOExist.Content = "IO模块已禁用";
return true; return true;
...@@ -870,7 +868,7 @@ namespace SmartScan ...@@ -870,7 +868,7 @@ namespace SmartScan
public delegate void CheckResultEventHandler(object sender, bool value); public delegate void CheckResultEventHandler(object sender, bool value);
public static event CheckResultEventHandler Checkresult; public static event CheckResultEventHandler Checkresult;
public Dictionary<string, string> lastContent; public Dictionary<string, string> lastContent;
private bool CompareContent(Dictionary<string, string> content) private bool CompareContent(Dictionary<string, string> content)
{ {
if (lastContent != null) if (lastContent != null)
...@@ -878,14 +876,14 @@ namespace SmartScan ...@@ -878,14 +876,14 @@ namespace SmartScan
return content.Count == lastContent.Count && !content.Except(lastContent).Any(); return content.Count == lastContent.Count && !content.Except(lastContent).Any();
} }
return false; return false;
} }
private void Extension_Printing(Dictionary<string, string> content) private void Extension_Printing(Dictionary<string, string> content)
{ {
try try
{ {
LogNet.log.Info("打印内容:"+JsonConvert.SerializeObject(content)); LogNet.log.Info("打印内容:" + JsonConvert.SerializeObject(content));
SaveResult(content); SaveResult(content);
//Bitmap labelBmp = Common.labelEdit.PrintImage(Common.config.DefaultPrintLabel, content, out _); //Bitmap labelBmp = Common.labelEdit.PrintImage(Common.config.DefaultPrintLabel, content, out _);
BLLCommon.labelEdit.PrintLast(BLLCommon.config.DefaultPrintLabel, BLLCommon.config.PrinterName, BLLCommon.config.PrintLandscape, content, out List<string> barcode); BLLCommon.labelEdit.PrintLast(BLLCommon.config.DefaultPrintLabel, BLLCommon.config.PrinterName, BLLCommon.config.PrintLandscape, content, out List<string> barcode);
...@@ -917,7 +915,7 @@ namespace SmartScan ...@@ -917,7 +915,7 @@ namespace SmartScan
{ {
paramMap.Add(key, content[key]); paramMap.Add(key, content[key]);
} }
paramMap.Add("cid", BLLCommon.config.CID + "_2"); paramMap.Add("cid", BLLCommon.config.CID + "_2");
_ = UnifiedDataHandler.PostSmfImageAsync(bmp, paramMap, bmp.Width, bmp.Height); _ = UnifiedDataHandler.PostSmfImageAsync(bmp, paramMap, bmp.Width, bmp.Height);
//_ = UnifiedDataHandler.PostSmfImageAsync(bmp, new Dictionary<string, string> { { "cid", BLLCommon.config.CID + "_2" } }, bmp.Width, bmp.Height); //_ = UnifiedDataHandler.PostSmfImageAsync(bmp, new Dictionary<string, string> { { "cid", BLLCommon.config.CID + "_2" } }, bmp.Width, bmp.Height);
} }
...@@ -932,7 +930,7 @@ namespace SmartScan ...@@ -932,7 +930,7 @@ namespace SmartScan
{ {
LogNet.log.Error($"Extension_Printing", ex); LogNet.log.Error($"Extension_Printing", ex);
} }
} }
private void FrmMain_Load(object sender, EventArgs e) private void FrmMain_Load(object sender, EventArgs e)
...@@ -1016,7 +1014,7 @@ namespace SmartScan ...@@ -1016,7 +1014,7 @@ namespace SmartScan
private void Extension_Checks(string text) private void Extension_Checks(string text)
{ {
if (this.InvokeRequired) if (this.InvokeRequired)
{ {
this.Invoke(new Action(() => Extension_Checks(text))); this.Invoke(new Action(() => Extension_Checks(text)));
...@@ -1033,18 +1031,17 @@ namespace SmartScan ...@@ -1033,18 +1031,17 @@ namespace SmartScan
return; return;
} }
if (text == "OK") if (text == "OK")
{ {
wpfControl.SetResultOK(); wpfControl.SetResultOK();
} }
else if (text == "等待中" || text == "Waiting" || text == "待機中") else if (text == "等待中" || text == "Waiting" || text == "待機中")
{ {
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
} }
else else
{ {
wpfControl.SetResultNG(); // 显示NG wpfControl.SetResultNG(); // 显示NG
} }
} }
private void OnBllKeySet(string templateName, string[] originalCode, Dictionary<string, string> key, bool hasMatch) private void OnBllKeySet(string templateName, string[] originalCode, Dictionary<string, string> key, bool hasMatch)
...@@ -1112,28 +1109,28 @@ namespace SmartScan ...@@ -1112,28 +1109,28 @@ namespace SmartScan
changeBtnStartText(); changeBtnStartText();
Language.SetLanguage(this); Language.SetLanguage(this);
LanguageWwitchover.LoadLanguage(CboLanguage.Text); LanguageWwitchover.LoadLanguage(CboLanguage.Text);
if (wpfMenu!=null&& wpfControl!=null) if (wpfMenu != null && wpfControl != null)
{ {
wpfMenu.ApplyLanguage(); wpfMenu.ApplyLanguage();
wpfControl.UpdateRight(); wpfControl.UpdateRight();
} }
} }
} }
void changeBtnStartText() void changeBtnStartText()
{ {
if(BLLCommon.config.Language.Equals("English")) if (BLLCommon.config.Language.Equals("English"))
{ {
BtnStart.Font = new Font("Arial",14,FontStyle.Bold); BtnStart.Font = new Font("Arial", 14, FontStyle.Bold);
} }
else else
{ {
BtnStart.Font = new Font("微软雅黑", 14, FontStyle.Bold); BtnStart.Font = new Font("微软雅黑", 14, FontStyle.Bold);
} }
if(scanWork?.isRun??false) if (scanWork?.isRun ?? false)
{ {
BtnStart.Text = Language.Dialog("Exit", "退出"); BtnStart.Text = Language.Dialog("Exit", "退出");
} }
...@@ -1177,7 +1174,7 @@ namespace SmartScan ...@@ -1177,7 +1174,7 @@ namespace SmartScan
monitor.Pause = true; monitor.Pause = true;
new FrmRetrospect().ShowDialog(); new FrmRetrospect().ShowDialog();
monitor.Pause = false; monitor.Pause = false;
WPF_Date_From wPF_Date_From=new WPF_Date_From(); WPF_Date_From wPF_Date_From = new WPF_Date_From();
wPF_Date_From.Show(); wPF_Date_From.Show();
} }
...@@ -1199,14 +1196,14 @@ namespace SmartScan ...@@ -1199,14 +1196,14 @@ namespace SmartScan
} }
private void BtnTriggerIO_Click(object sender, EventArgs e) private void BtnTriggerIO_Click(object sender, EventArgs e)
{ {
LogNet.log.Info("按钮点击触发Work"); LogNet.log.Info("按钮点击触发Work");
Task.Run(() => Task.Run(() =>
{ {
scanWork.Scan(); scanWork.Scan();
//scanWork.TouchOff(); //scanWork.TouchOff();
}); });
} }
private void BtnMatchedName_Click(object sender, EventArgs e) private void BtnMatchedName_Click(object sender, EventArgs e)
{ {
...@@ -1234,12 +1231,13 @@ namespace SmartScan ...@@ -1234,12 +1231,13 @@ namespace SmartScan
}); });
} }
catch { } catch { }
}; }
;
return; return;
} }
Common.frmWaitting.Close(); Common.frmWaitting.Close();
} }
public void SetWaittingMsg (string msg,int keepsec=3) public void SetWaittingMsg(string msg, int keepsec = 3)
{ {
if (Common.frmMain.InvokeRequired) if (Common.frmMain.InvokeRequired)
{ {
...@@ -1254,7 +1252,7 @@ namespace SmartScan ...@@ -1254,7 +1252,7 @@ namespace SmartScan
Application.DoEvents(); Application.DoEvents();
} }
public void DrawTextForm(Dictionary<string,string> valuePairs) public void DrawTextForm(Dictionary<string, string> valuePairs)
{ {
// //
if (Common.frmMain.InvokeRequired) if (Common.frmMain.InvokeRequired)
...@@ -1279,6 +1277,6 @@ namespace SmartScan ...@@ -1279,6 +1277,6 @@ namespace SmartScan
// new HBEditor(); // new HBEditor();
ConfigHelper.AdvanceConfigForm.ShowEditDialog(this, true); ConfigHelper.AdvanceConfigForm.ShowEditDialog(this, true);
} }
} }
} }
using Asa.FaceControl; using Asa.FaceControl;
using BLL; using BLL;
using DocumentFormat.OpenXml.Wordprocessing;
using HandyControl.Controls;
using MemoryRead; using MemoryRead;
using Model; using Model;
using OnlineStore.Common.util; using OnlineStore.Common.util;
using SmartScan.Form;
using SmartScan.SetControl.WPF;
using SmartScan.SetControl.WPF.Model; using SmartScan.SetControl.WPF.Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -17,7 +13,6 @@ using System.Linq; ...@@ -17,7 +13,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Script.Serialization; using System.Web.Script.Serialization;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using static BLL.BLLCommon; using static BLL.BLLCommon;
using static SmartScan.SetControl.WPF.Model.NeoAlertBox; using static SmartScan.SetControl.WPF.Model.NeoAlertBox;
...@@ -38,12 +33,12 @@ namespace SmartScan ...@@ -38,12 +33,12 @@ namespace SmartScan
//bool falg = true; //bool falg = true;
public General generals; public General generals;
public ScanWork() public ScanWork()
{ {
picShow = (FacePictureBox)Common.frmMain.Controls["PicShow"]; picShow = (FacePictureBox)Common.frmMain.Controls["PicShow"];
btnMatchedName = (FaceButton)Common.frmMain.Controls["BtnMatchedName"]; btnMatchedName = (FaceButton)Common.frmMain.Controls["BtnMatchedName"];
//wpfImagePanel = Common.frmMain.Controls.Find("wpf_image", true)[0] as System.Windows.Forms.Panel; //wpfImagePanel = Common.frmMain.Controls.Find("wpf_image", true)[0] as System.Windows.Forms.Panel;
} }
...@@ -70,7 +65,7 @@ namespace SmartScan ...@@ -70,7 +65,7 @@ namespace SmartScan
else else
BLLCommon.lightSource?.TurnOn(); BLLCommon.lightSource?.TurnOn();
} }
public void Close() public void Close()
{ {
isRun = false; isRun = false;
...@@ -101,29 +96,29 @@ namespace SmartScan ...@@ -101,29 +96,29 @@ namespace SmartScan
} }
public delegate void Check2(string text); public delegate void Check2(string text);
public event Check2 Check2s; public event Check2 Check2s;
public void Scan(bool fromlocalfile=false) public void Scan(bool fromlocalfile = false)
{ {
//此段代码加锁是因为,客户在连续点击识别设备按钮时,线程会同时生成rid=123并且rid赋值是重复的123123 //此段代码加锁是因为,客户在连续点击识别设备按钮时,线程会同时生成rid=123并且rid赋值是重复的123123
//在测试时也遇到这个情况,但只成功复现了一次;故加锁。 //在测试时也遇到这个情况,但只成功复现了一次;故加锁。
lock (lockObject) lock (lockObject)
{ {
if (!isRun) return; if (!isRun) return;
if (isTouch) return; if (isTouch) return;
if (BLLCommon.config.CheckFunction) if (BLLCommon.config.CheckFunction)
{ {
Check2s?.Invoke("1"); Check2s?.Invoke("1");
} }
isTouch = true; isTouch = true;
btnMatchedName.Invoke(delegate () btnMatchedName.Invoke(delegate ()
{ {
if (!BLL.Config.Backgrounder) if (!BLL.Config.Backgrounder)
btnMatchedName.Visible = false; btnMatchedName.Visible = false;
BLLCommon.extension.Clear(); BLLCommon.extension.Clear();
}); });
// LoadingScreen.Instance.Show("拍照中", "请稍候..."); // LoadingScreen.Instance.Show("拍照中", "请稍候...");
//Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialScanning"));//拍照识别... //Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialScanning"));//拍照识别...
var t = Task.Run(() => var t = Task.Run(() =>
...@@ -132,23 +127,23 @@ namespace SmartScan ...@@ -132,23 +127,23 @@ namespace SmartScan
reckontime.Restart(); reckontime.Restart();
try try
{ {
//Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialScanning"));//拍照识别... //Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialScanning"));//拍照识别...
workCodeInfo = new(); workCodeInfo = new();
workCodeKeyword = new(StringComparer.OrdinalIgnoreCase); workCodeKeyword = new(StringComparer.OrdinalIgnoreCase);
originalCodeText = null; originalCodeText = null;
originalCodeIsUsed = null; originalCodeIsUsed = null;
LoadingScreen.Instance.Hide(); LoadingScreen.Instance.Hide();
if (!GetCodeInfo(fromlocalfile)) if (!GetCodeInfo(fromlocalfile))
{ {
isTouch = false; isTouch = false;
Common.frmMain.CloseWaittingDialog(); Common.frmMain.CloseWaittingDialog();
return; return;
} }
string YU= BLLCommon.config.Language; string YU = BLLCommon.config.Language;
if (YU=="English") if (YU == "English")
{ {
LoadingScreen.Instance.Show("Matching", "Please wait..."); LoadingScreen.Instance.Show("Matching", "Please wait...");
} }
...@@ -160,7 +155,7 @@ namespace SmartScan ...@@ -160,7 +155,7 @@ namespace SmartScan
{ {
LoadingScreen.Instance.Show("匹配中", "请稍候..."); LoadingScreen.Instance.Show("匹配中", "请稍候...");
} }
Common.frmMain.Invoke(delegate () Common.frmMain.Invoke(delegate ()
{ {
AddCodeCenter(); AddCodeCenter();
...@@ -170,7 +165,8 @@ namespace SmartScan ...@@ -170,7 +165,8 @@ namespace SmartScan
reckontime.Restart(); reckontime.Restart();
//Common.frmMain.Showlogs("OCR识别中请稍后"); //Common.frmMain.Showlogs("OCR识别中请稍后");
Common.frmMain.Showlogs(""); Common.frmMain.Showlogs("");
if (needPrint&&BLLCommon.config.CheckFunction) LogNet.log.Info($"WaitLabelRecheck:{WaitLabelRecheck},CheckFunction:{BLLCommon.config.CheckFunction}");
if (WaitLabelRecheck && BLLCommon.config.CheckFunction)
{ {
LoadingScreen.Instance.Hide(); LoadingScreen.Instance.Hide();
originalCodeText = Camera.GetBarCodeText(workCodeInfo); originalCodeText = Camera.GetBarCodeText(workCodeInfo);
...@@ -186,12 +182,12 @@ namespace SmartScan ...@@ -186,12 +182,12 @@ namespace SmartScan
Check2s?.Invoke("2"); Check2s?.Invoke("2");
// Common.frmMain.wpfControl.SetResultOK(); // Common.frmMain.wpfControl.SetResultOK();
Check2s?.Invoke("OK"); Check2s?.Invoke("OK");
needPrint =false; WaitLabelRecheck = false;
} }
else else
{ {
Check2s?.Invoke("NG"); Check2s?.Invoke("NG");
} }
} }
else else
...@@ -230,8 +226,8 @@ namespace SmartScan ...@@ -230,8 +226,8 @@ namespace SmartScan
LogNet.log.Info($"渲染控件耗时{reckontime.ElapsedMilliseconds}ms"); LogNet.log.Info($"渲染控件耗时{reckontime.ElapsedMilliseconds}ms");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -239,7 +235,7 @@ namespace SmartScan ...@@ -239,7 +235,7 @@ namespace SmartScan
} }
finally finally
{ {
bendi=false; bendi = false;
isTouch = false; isTouch = false;
Common.frmMain.CloseWaittingDialog(); Common.frmMain.CloseWaittingDialog();
} }
...@@ -262,7 +258,7 @@ namespace SmartScan ...@@ -262,7 +258,7 @@ namespace SmartScan
var errmsg = ""; var errmsg = "";
Dictionary<string, object> dic = null; Dictionary<string, object> dic = null;
string json = Http.PostJson(url, null, keylist); string json = Http.PostJson(url, null, keylist);
if (json == "") if (json == "")
{ {
...@@ -285,7 +281,7 @@ namespace SmartScan ...@@ -285,7 +281,7 @@ namespace SmartScan
if (!dic.TryGetValue("CODE", out object value)) if (!dic.TryGetValue("CODE", out object value))
{ {
LogUtil.info("Api C2 return data error:\r\n" + json); LogUtil.info("Api C2 return data error:\r\n" + json);
return MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg, "NEO SCAN", true); return MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg, "NEO SCAN", true);
} }
if (Convert.ToInt32(value) != 0) if (Convert.ToInt32(value) != 0)
...@@ -318,9 +314,9 @@ namespace SmartScan ...@@ -318,9 +314,9 @@ namespace SmartScan
// 读取文件内容 // 读取文件内容
string fileContent = File.ReadAllText(FilePath.CONFIG_Code_Value); string fileContent = File.ReadAllText(FilePath.CONFIG_Code_Value);
List<string> lines = fileContent.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(s=>s.Trim()).ToList(); List<string> lines = fileContent.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
LogNet.log.Info("扫描到条码:"+string.Join(",", codeTexts)); LogNet.log.Info("扫描到条码:" + string.Join(",", codeTexts));
LogNet.log.Info("在以下条码中匹配:"+fileContent); LogNet.log.Info("在以下条码中匹配:" + fileContent);
// 检查文件内容是否包含任一条码文本 // 检查文件内容是否包含任一条码文本
foreach (string ln in lines.ToArray()) foreach (string ln in lines.ToArray())
{ {
...@@ -477,7 +473,7 @@ namespace SmartScan ...@@ -477,7 +473,7 @@ namespace SmartScan
} }
}); });
} }
public bool isstart = false; public bool isstart = false;
private bool GetCodeInfo(bool fromlocalfile = false) private bool GetCodeInfo(bool fromlocalfile = false)
{ {
LogNet.log.Info("Work GetCodeInfo"); LogNet.log.Info("Work GetCodeInfo");
...@@ -492,7 +488,7 @@ namespace SmartScan ...@@ -492,7 +488,7 @@ namespace SmartScan
} }
LogNet.log.Info("2"); LogNet.log.Info("2");
List<Bitmap> image = new List<Bitmap>(Camera.CaptureAndGetCode(out workCodeInfo)); List<Bitmap> image = new List<Bitmap>(Camera.CaptureAndGetCode(out workCodeInfo));
LogNet.log.Info("image"+image.Count); LogNet.log.Info("image" + image.Count);
LogNet.log.Info("image[0]" + image[0]); LogNet.log.Info("image[0]" + image[0]);
if (image.Count > 0 && image[0] != null) if (image.Count > 0 && image[0] != null)
{ {
...@@ -503,7 +499,7 @@ namespace SmartScan ...@@ -503,7 +499,7 @@ namespace SmartScan
// 使用WPF控件显示图片 // 使用WPF控件显示图片
if (!BLL.Config.Backgrounder) if (!BLL.Config.Backgrounder)
{//在图片画出识别的二维码 {//在图片画出识别的二维码
picShow.Image = image[0]; picShow.Image = image[0];
DisplayBitmapInWpfControl(image[0]); DisplayBitmapInWpfControl(image[0]);
} }
...@@ -523,7 +519,7 @@ namespace SmartScan ...@@ -523,7 +519,7 @@ namespace SmartScan
LogNet.log.Info("image[1]"); LogNet.log.Info("image[1]");
return false; return false;
} }
if (BLLCommon.config.TriggerOpenLight) if (BLLCommon.config.TriggerOpenLight)
BLLCommon.lightSource.TurnOff(); BLLCommon.lightSource.TurnOff();
...@@ -562,7 +558,7 @@ namespace SmartScan ...@@ -562,7 +558,7 @@ namespace SmartScan
DisplayBitmapInWpfControl(bmp); DisplayBitmapInWpfControl(bmp);
picShow.Image = bmp; picShow.Image = bmp;
} }
BLLCommon.mateEdit.CurrntBitmap = bmp; BLLCommon.mateEdit.CurrntBitmap = bmp;
}); });
return true; return true;
...@@ -713,7 +709,7 @@ namespace SmartScan ...@@ -713,7 +709,7 @@ namespace SmartScan
Console.WriteLine($"显示图片内部错误: {innerEx.Message}\n{innerEx.StackTrace}"); Console.WriteLine($"显示图片内部错误: {innerEx.Message}\n{innerEx.StackTrace}");
} }
})); }));
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -796,8 +792,8 @@ namespace SmartScan ...@@ -796,8 +792,8 @@ namespace SmartScan
center[i] = workCodeInfo[i].Center; center[i] = workCodeInfo[i].Center;
if (!BLL.Config.Backgrounder) if (!BLL.Config.Backgrounder)
picShow.AddCodeCenter(center); picShow.AddCodeCenter(center);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
} }
...@@ -821,7 +817,7 @@ namespace SmartScan ...@@ -821,7 +817,7 @@ namespace SmartScan
{ {
btnMatchedName.Visible = true; btnMatchedName.Visible = true;
btnMatchedName.Text = mateName; btnMatchedName.Text = mateName;
} }
} }
else else
...@@ -830,7 +826,7 @@ namespace SmartScan ...@@ -830,7 +826,7 @@ namespace SmartScan
if (!BLL.Config.Backgrounder) if (!BLL.Config.Backgrounder)
{ {
string text = Language.Dialog("MaterialTemplateNoMatch"); string text = Language.Dialog("MaterialTemplateNoMatch");
NeoAlertBox.Show("", text,AlertType.Warning,"NEO SCAN",true); NeoAlertBox.Show("", text, AlertType.Warning, "NEO SCAN", true);
//var fm = new FaceMessageBox("", text, MessageBoxButtons.OK); //var fm = new FaceMessageBox("", text, MessageBoxButtons.OK);
//fm.TopMost = true; //fm.TopMost = true;
...@@ -840,32 +836,32 @@ namespace SmartScan ...@@ -840,32 +836,32 @@ namespace SmartScan
}); });
return rtn; return rtn;
} }
public bool Ispring=true; public bool Ispring = true;
public bool needPrint = false; public bool WaitLabelRecheck = false;
public void SetKey(bool hasMatch,string templateName) public void SetKey(bool hasMatch, string templateName)
{ {
LogNet.log.Info("Work SetKey hasMatch:" + hasMatch); LogNet.log.Info("Work SetKey hasMatch:" + hasMatch);
//if (workCodeKeyword.Count == 0){ return;} //if (workCodeKeyword.Count == 0){ return;}
//if(hasMatch) //if(hasMatch)
Ispring = true; Ispring = true;
bool a= BLLCommon.extension.SetKey(templateName,originalCodeText, workCodeKeyword, hasMatch, out _); bool a = BLLCommon.extension.SetKey(templateName, originalCodeText, workCodeKeyword, hasMatch, out _);
LoadingScreen.Instance.Hide(); LoadingScreen.Instance.Hide();
Common.frmMain.Showlogs(""); Common.frmMain.Showlogs("");
// 通过检查结果状态来判断是否需要打印 // 通过检查结果状态来判断是否需要打印
// 检查结果是否为"等待中"/"Waiting"/"待機中",以判断是否是第一次拍照 // 检查结果是否为"等待中"/"Waiting"/"待機中",以判断是否是第一次拍照
if (BLLCommon.extension.labelText != null) if (BLLCommon.extension.labelText != null)
{ {
string status = BLLCommon.extension.labelText.ToLower(); string status = BLLCommon.extension.labelText;
needPrint = (status == "等待中" || status == "Waiting" || status == "待機中"); WaitLabelRecheck = (status == "等待中" || status == "Waiting" || status == "待機中");
} }
if (needPrint && BLLCommon.config.AutoPrint) if (WaitLabelRecheck && BLLCommon.config.AutoPrint)
{ {
if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>"))) if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>")))
{ {
BLLCommon.extension.DrawTextBackground(workCodeKeyword); BLLCommon.extension.DrawTextBackground(workCodeKeyword);
bool results = NeoAlertBox.Show("", Language.Dialog("Using_OCR_Result", "是否使用OCR识别结果?"),AlertType.Warning,"NEO SCAN",true); bool results = NeoAlertBox.Show("", Language.Dialog("Using_OCR_Result", "是否使用OCR识别结果?"), AlertType.Warning, "NEO SCAN", true);
//FrmDrawText frmDraw = new FrmDrawText(); //FrmDrawText frmDraw = new FrmDrawText();
if (results == true) if (results == true)
{ {
...@@ -906,44 +902,44 @@ namespace SmartScan ...@@ -906,44 +902,44 @@ namespace SmartScan
//打印 //打印
BLLCommon.extension.Print(hasMatch, pairs); BLLCommon.extension.Print(hasMatch, pairs);
} }
} }
} }
} }
else else
{ {
if (bendi) if (bendi)
{
string YU = BLLCommon.config.Language;
bool result1 = false;
if (YU == "English")
{ {
string YU = BLLCommon.config.Language; result1 = NeoAlertBox.Show("", "Whether to print or not?", AlertType.Warning, "NEO SCAN", true);
bool result1 = false; }
if (YU == "English") else if (YU == "日语")
{ {
result1 = NeoAlertBox.Show("", "Whether to print or not?", AlertType.Warning, "NEO SCAN", true); result1 = NeoAlertBox.Show("", "印刷しますか?", AlertType.Warning, "NEO SCAN", true);
}
else if (YU == "日语")
{
result1 = NeoAlertBox.Show("", "印刷しますか?", AlertType.Warning, "NEO SCAN", true);
}
else
{
result1 = NeoAlertBox.Show("", "是否打印?", AlertType.Warning, "NEO SCAN", true);
}
if (result1)
{
BLLCommon.extension.Print(hasMatch, workCodeKeyword);
}
} }
else else
{ {
if (hasMatch) result1 = NeoAlertBox.Show("", "是否打印?", AlertType.Warning, "NEO SCAN", true);
}
if (result1)
{
BLLCommon.extension.Print(hasMatch, workCodeKeyword); BLLCommon.extension.Print(hasMatch, workCodeKeyword);
} }
//打印 }
else
{
if (hasMatch)
BLLCommon.extension.Print(hasMatch, workCodeKeyword);
}
//打印
} }
if (BLLCommon.config.PromptAfterPrinting && !BLL.Config.Backgrounder) if (BLLCommon.config.PromptAfterPrinting && !BLL.Config.Backgrounder)
{ {
...@@ -1026,9 +1022,9 @@ namespace SmartScan ...@@ -1026,9 +1022,9 @@ namespace SmartScan
// } // }
// Ispring = true; // Ispring = true;
// } // }
//} //}
} }
} }
} }
...@@ -323,7 +323,7 @@ namespace SmartScan.SetControl.WPF ...@@ -323,7 +323,7 @@ namespace SmartScan.SetControl.WPF
if (target != null) if (target != null)
{ {
int value; int value;
if (int.TryParse(target.Text, out value) && value > 1) if (int.TryParse(target.Text, out value) && value > 0)
{ {
target.Text = (value - 1).ToString(); target.Text = (value - 1).ToString();
CheckMatchForUserControl(match, userControl); CheckMatchForUserControl(match, userControl);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!