Commit 27ad3e76 王海洋

why修改

1 个父辈 ade252a8
...@@ -148,6 +148,7 @@ namespace BLL ...@@ -148,6 +148,7 @@ namespace BLL
var now = DateTime.Now; var now = DateTime.Now;
// 比较当前 key 和上次的 key // 比较当前 key 和上次的 key
bool isSame = false; bool isSame = false;
bool isFirstCapture=lastKeys==null;
try try
{ {
...@@ -202,8 +203,9 @@ namespace BLL ...@@ -202,8 +203,9 @@ namespace BLL
} }
#endregion #endregion
// 添加或替换自增ID // 添加或替换自增ID
string reelIdKeyWord = config.ReelIDKeyWord; string reelIdKeyWord = config.ReelIDKeyWord;
if (!string.IsNullOrEmpty(config.ReelIDKeyWord) && isdisplay) if (!string.IsNullOrEmpty(config.ReelIDKeyWord) && isdisplay)
{ {
var Reelidstr = GetReelid(); var Reelidstr = GetReelid();
...@@ -217,6 +219,8 @@ namespace BLL ...@@ -217,6 +219,8 @@ namespace BLL
} }
} }
//客户定制key //客户定制key
string exKey = ConfigHelper.Config.Get("Ex_UserDataKey", "Manufactured_Date"); string exKey = ConfigHelper.Config.Get("Ex_UserDataKey", "Manufactured_Date");
if (macroKey.Contains(exKey)) if (macroKey.Contains(exKey))
...@@ -230,6 +234,30 @@ namespace BLL ...@@ -230,6 +234,30 @@ namespace BLL
key.Add(exKey, DateTime.Now.ToString(ConfigHelper.Config.Get("Ex_UserDataRule", "MM/dd/yyyy"))); key.Add(exKey, DateTime.Now.ToString(ConfigHelper.Config.Get("Ex_UserDataRule", "MM/dd/yyyy")));
} }
} }
// 添加或更新 dataTime 字段为当前日期(格式:yyyy年MM月dd日)
bool addDateTime = false;
foreach (var item in BLLCommon.macroKeyValue)
{
string[] parts = item.Split('/');
if (parts.Length >= 3 && parts[0] == "DataTime" && parts[2].Trim().Equals("True", StringComparison.OrdinalIgnoreCase))
{
addDateTime = true;
break;
}
}
// 只有当DataTime配置存在且启用时才添加
if (addDateTime)
{
if (key.ContainsKey("DataTime"))
{
key["DataTime"] = DateTime.Now.ToString("yyyy.MM.dd");
}
else
{
key.Add("DataTime", DateTime.Now.ToString("yyyy.MM.dd"));
}
}
if (extensions != null && !extensions[0].Control.InvokeRequired) if (extensions != null && !extensions[0].Control.InvokeRequired)
{ {
//使用key填充时,请处理字段开头的<OCR>字段 //使用key填充时,请处理字段开头的<OCR>字段
...@@ -246,37 +274,57 @@ namespace BLL ...@@ -246,37 +274,57 @@ namespace BLL
} }
} }
} }
lastkey = key;
islast = false;
if (lastKeys != null) if (lastKeys != null)
{ {
// 创建不包含自增ID的临时字典进行比较 if (BLLCommon.config.CheckFunction)
var keyWithoutReelID = new Dictionary<string, string>(key);
var lastKeysWithoutReelID = new Dictionary<string, string>(lastKeys);
// 从比较中排除自增ID
if (!string.IsNullOrEmpty(reelIdKeyWord))
{ {
keyWithoutReelID.Remove(reelIdKeyWord); if (BLLCommon.config.Language.Equals("English"))
lastKeysWithoutReelID.Remove(reelIdKeyWord); {
BLLCommon.extension.labelText = "Waiting";
CheckText("Waiting");
} }
else if (BLLCommon.config.Language.Equals("日语"))
// 比较不包含自增ID的字典 {
isSame = keyWithoutReelID.Count == lastKeysWithoutReelID.Count && BLLCommon.extension.labelText = "待機中";
!keyWithoutReelID.Except(lastKeysWithoutReelID).Any(); CheckText("待機中");
} }
lastkey = key; else
islast = false;
if (isSame)
{ {
BLLCommon.extension.labelText = "OK"; BLLCommon.extension.labelText = "等待中";
CheckText("OK"); CheckText("等待中");
lastKeys = null;
islast = true;
// 两次的 key 相同,可添加相应逻辑
} }
else if (lastKeys != null && !isSame) islast = false;
{ // 两次的 key 不同,可添加相应逻辑
BLLCommon.extension.labelText = "NG"; }
CheckText("NG"); // 创建不包含自增ID的临时字典进行比较
//var keyWithoutReelID = new Dictionary<string, string>(key);
//var lastKeysWithoutReelID = new Dictionary<string, string>(lastKeys);
//// 从比较中排除自增ID
//if (!string.IsNullOrEmpty(reelIdKeyWord))
//{
// keyWithoutReelID.Remove(reelIdKeyWord);
// lastKeysWithoutReelID.Remove(reelIdKeyWord);
//}
//// 比较不包含自增ID的字典
//isSame = keyWithoutReelID.Count == lastKeysWithoutReelID.Count &&
// !keyWithoutReelID.Except(lastKeysWithoutReelID).Any();
//if (isSame)
//{
// BLLCommon.extension.labelText = "OK";
// CheckText("OK");
// lastKeys = null;
// islast = true;
// // 两次的 key 相同,可添加相应逻辑
//}
//else
//{ // 两次的 key 不同,可添加相应逻辑
// BLLCommon.extension.labelText = "NG";
// CheckText("NG");
//}
} }
else else
{ {
...@@ -286,7 +334,8 @@ namespace BLL ...@@ -286,7 +334,8 @@ namespace BLL
{ {
BLLCommon.extension.labelText = "Waiting"; BLLCommon.extension.labelText = "Waiting";
CheckText("Waiting"); CheckText("Waiting");
}else if (BLLCommon.config.Language.Equals("日语")) }
else if (BLLCommon.config.Language.Equals("日语"))
{ {
BLLCommon.extension.labelText = "待機中"; BLLCommon.extension.labelText = "待機中";
CheckText("待機中"); CheckText("待機中");
...@@ -299,20 +348,23 @@ namespace BLL ...@@ -299,20 +348,23 @@ namespace BLL
islast = false; islast = false;
} }
}
} }
// 如果有字段更新,则再次调用OnKeySet更新WPF界面 // 如果有字段更新,则再次调用OnKeySet更新WPF界面
OnKeySet(originalCode, key, hasMatch); OnKeySet(originalCode, key, hasMatch);
if (lastKeys == null && !islast) if (lastKeys == null && !islast && BLLCommon.config.CheckFunction)
{
if (BLLCommon.config.CheckFunction)
{ {
lastKeys = new Dictionary<string, string>(key); // 更新 lastKey lastKeys = new Dictionary<string, string>(key); // 更新 lastKey
}
} }
...@@ -345,31 +397,23 @@ namespace BLL ...@@ -345,31 +397,23 @@ namespace BLL
{ {
extensions[i].Control.Text = BLLCommon.extension.labelText; extensions[i].Control.Text = BLLCommon.extension.labelText;
} }
//if (extensions[i].LinkName == "ischeckresult" && lastKeys != null) }
//if (BLLCommon.config.CheckFunction)
//{ //{
// if (BLLCommon.extension.labelText == "NG") // if (isFirstCapture)
// { // {
// extensions[i].Control.Text = BLLCommon.extension.labelText; // if (!updatereelid(key, out errmsg))
// extensions[i].Control.ForeColor = System.Drawing.Color.Red; // return false;
// }
// else if (BLLCommon.extension.labelText == "OK")
// {
// extensions[i].Control.Text = BLLCommon.extension.labelText;
// extensions[i].Control.ForeColor = System.Drawing.Color.Green;
// } // }
//} //}
//else
//{
}
}
if (!updatereelid(key, out errmsg)) if (!updatereelid(key, out errmsg))
return false; return false;
// }
Application.DoEvents(); Application.DoEvents();
...@@ -387,27 +431,35 @@ namespace BLL ...@@ -387,27 +431,35 @@ namespace BLL
} }
} }
if (BLLCommon.config.CheckFunction&&!islast) //if (BLLCommon.config.CheckFunction&&!islast)
{ //{
return false; // return false;
} //}
return true; return true;
} }
bool updatereelid(Dictionary<string, string> key, out string errmsg) bool updatereelid(Dictionary<string, string> key, out string errmsg)
{ {
errmsg = ""; errmsg = "";
try
{
foreach (var item in key)
{
LogNet.log.Info("接口上传信息(" + item.Key+":"+item.Value+")");
}
if (!string.IsNullOrEmpty(config.HttpReelID)) if (!string.IsNullOrEmpty(config.HttpReelID))
{ {
Dictionary<string, object> pairs = new Dictionary<string, object>(); Dictionary<string, object> pairs = new Dictionary<string, object>();
if (!GetHttpReelID(key, out errmsg,out pairs)) if (!GetHttpReelID(key, out errmsg, out pairs))
{ {
LogNet.log.Error("GetHttpReelID:" + errmsg); LogNet.log.Error("GetHttpReelID:" + errmsg);
return false; return false;
} }
//key["ReelID"] = newid; //key["ReelID"] = newid;
} }
if (extensions != null && extensions.Count>0&& !extensions[0].Control.InvokeRequired) if (extensions != null && extensions.Count > 0 && !extensions[0].Control.InvokeRequired)
{ {
for (int i = 0; i < extensions.Count; i++) for (int i = 0; i < extensions.Count; i++)
{ {
...@@ -415,8 +467,17 @@ namespace BLL ...@@ -415,8 +467,17 @@ namespace BLL
extensions[i].Control.Text = key["reelid"]; extensions[i].Control.Text = key["reelid"];
} }
} }
}
catch (Exception ex)
{
LogNet.log.Info("ex" + ex.ToString());
}
//SaveRetrospect?.Invoke(key); //SaveRetrospect?.Invoke(key);
return true; return true;
} }
public void Update() public void Update()
...@@ -664,44 +725,7 @@ namespace BLL ...@@ -664,44 +725,7 @@ namespace BLL
} }
public void CheckClear() public void CheckClear()
{ {
if (BLLCommon.config.Language.Equals("English"))
{
bool result = MessageboxNeo.Show( "", "Whether to skip this operation?", "NEO SCAN", true);
if (result )
{
lastKeys = null;
BLLCommon.extension.labelText = "Waiting";
}
}
else if (BLLCommon.config.Language.Equals("日语"))
{
bool result = MessageboxNeo.Show("",
"この操作をスキップしますか?",
"NEO SCAN",
true);
if (result)
{
lastKeys = null;
BLLCommon.extension.labelText = "待機中";
}
}
else
{
bool result = MessageboxNeo.Show( "", "是否跳过此操作?", "NEO SCAN", true);
if (result )
{
lastKeys = null;
BLLCommon.extension.labelText = "等待中";
}
}
} }
private void ComboBoxTextChanged(object sender, EventArgs e) private void ComboBoxTextChanged(object sender, EventArgs e)
{ {
...@@ -822,7 +846,8 @@ namespace BLL ...@@ -822,7 +846,8 @@ namespace BLL
{ {
errmsg = "Api error"; errmsg = "Api error";
if (extensions != null && !extensions[0].Control.InvokeRequired) if (extensions != null && !extensions[0].Control.InvokeRequired)
new FaceMessageBox("BoxReelIDInfoMaintain", errmsg, System.Windows.Forms.MessageBoxButtons.OK, true).ShowDialog(); MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg,"NEO SCAN",true);
// new FaceMessageBox("BoxReelIDInfoMaintain", errmsg, System.Windows.Forms.MessageBoxButtons.OK, true).ShowDialog();
return false; return false;
} }
...@@ -836,7 +861,8 @@ namespace BLL ...@@ -836,7 +861,8 @@ namespace BLL
{ {
errmsg = "Api parse error:\r\n" + json; errmsg = "Api parse error:\r\n" + json;
if (extensions != null && !extensions[0].Control.InvokeRequired) if (extensions != null && !extensions[0].Control.InvokeRequired)
new FaceMessageBox("BoxReelIDInfoMaintain", errmsg, System.Windows.Forms.MessageBoxButtons.OK, true).ShowDialog(); MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg, "NEO SCAN", true);
//new FaceMessageBox("BoxReelIDInfoMaintain", errmsg, System.Windows.Forms.MessageBoxButtons.OK, true).ShowDialog();
return false; return false;
} }
...@@ -844,7 +870,8 @@ namespace BLL ...@@ -844,7 +870,8 @@ namespace BLL
if (!dic.TryGetValue("CODE", out object value)) if (!dic.TryGetValue("CODE", out object value))
{ {
if (extensions != null && !extensions[0].Control.InvokeRequired) if (extensions != null && !extensions[0].Control.InvokeRequired)
new FaceMessageBox("BoxReelIDInfoMaintain", "Api return data error:\r\n" + json, System.Windows.Forms.MessageBoxButtons.OK, true).ShowDialog(); MessageboxNeo.Show("BoxReelIDInfoMaintain", errmsg, "NEO SCAN", true);
//new FaceMessageBox("BoxReelIDInfoMaintain", "Api return data error:\r\n" + json, System.Windows.Forms.MessageBoxButtons.OK, true).ShowDialog();
else else
errmsg = "Api return data error:\r\n" + json; errmsg = "Api return data error:\r\n" + json;
return false; return false;
......
...@@ -173,7 +173,7 @@ namespace BLL ...@@ -173,7 +173,7 @@ namespace BLL
if (!File.Exists(filename)) if (!File.Exists(filename))
return titles; return titles;
LogNet.log.Info("filename:"+ filename);
XLWorkbook wb = new XLWorkbook(filename); XLWorkbook wb = new XLWorkbook(filename);
IXLWorksheet ws = wb.Worksheet(1); IXLWorksheet ws = wb.Worksheet(1);
for (int i = 1; i < 50; i++) for (int i = 1; i < 50; i++)
......
...@@ -35,6 +35,8 @@ namespace BLL ...@@ -35,6 +35,8 @@ namespace BLL
public MessageboxNeo(string headerText, string descriptionText, string title = "NEO SCAN", bool showCancelButton = true) public MessageboxNeo(string headerText, string descriptionText, string title = "NEO SCAN", bool showCancelButton = true)
{ {
InitializeComponent(); InitializeComponent();
this.TopMost = true; // 添加这一行,使窗体总是在最前面
this.StartPosition = FormStartPosition.CenterScreen; // 改为CenterScreen以相对于整个屏幕居中
titleLabel.Text = title; titleLabel.Text = title;
headerLabel.Text = headerText; headerLabel.Text = headerText;
descriptionLabel.Text = descriptionText; descriptionLabel.Text = descriptionText;
......
...@@ -256,7 +256,7 @@ namespace BLL ...@@ -256,7 +256,7 @@ namespace BLL
public class Operation public class Operation
{ {
public string cid; public string cid;
public string type = "NEOSCAN"; //COUNTING public string type = "NS100"; //COUNTING
public StoreStatus status; public StoreStatus status;
public int seq; public int seq;
public int op; public int op;
......
...@@ -27,5 +27,6 @@ namespace Model ...@@ -27,5 +27,6 @@ namespace Model
public static readonly string CONFIG_REELID = Environment.CurrentDirectory + "\\Config\\ReelID"; public static readonly string CONFIG_REELID = Environment.CurrentDirectory + "\\Config\\ReelID";
public static readonly string CONFIG_DATABASE = Environment.CurrentDirectory + "\\Config\\Database.db3"; public static readonly string CONFIG_DATABASE = Environment.CurrentDirectory + "\\Config\\Database.db3";
public static readonly string CONFIG_AUTOGENRULES = Environment.CurrentDirectory + "\\Config\\AutoGenRules.json"; public static readonly string CONFIG_AUTOGENRULES = Environment.CurrentDirectory + "\\Config\\AutoGenRules.json";
public static readonly string CONFIG_Code_Value = Environment.CurrentDirectory + "\\Config\\CodeValue.txt";
} }
} }
using Asa.FaceControl; using Asa.FaceControl;
using BLL; using BLL;
using DocumentFormat.OpenXml.Bibliography; 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;
...@@ -57,6 +58,7 @@ namespace SmartScan ...@@ -57,6 +58,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)
{ {
...@@ -186,6 +188,7 @@ namespace SmartScan ...@@ -186,6 +188,7 @@ namespace SmartScan
// 调用新的UpdateLanguage方法,而不仅仅是UpdateRight // 调用新的UpdateLanguage方法,而不仅仅是UpdateRight
wpfControl.UpdateLanguage(); wpfControl.UpdateLanguage();
} }
} }
// 当窗口状态改变时,通知WPF控件 // 当窗口状态改变时,通知WPF控件
...@@ -415,6 +418,8 @@ namespace SmartScan ...@@ -415,6 +418,8 @@ namespace SmartScan
// 确保它位于Z顺序的顶部 // 确保它位于Z顺序的顶部
host.BringToFront(); host.BringToFront();
} }
...@@ -474,12 +479,109 @@ namespace SmartScan ...@@ -474,12 +479,109 @@ namespace SmartScan
PnlExtension.Left = Width - PnlExtension.Width - 12; PnlExtension.Left = Width - PnlExtension.Width - 12;
PnlExtension.BackColor = System.Drawing.Color.FromArgb(20, 20, 20); PnlExtension.BackColor = System.Drawing.Color.FromArgb(20, 20, 20);
wpfControl.UpdateMultipleRecognitionData(BLLCommon.macroKeyValue); wpfControl.UpdateMultipleRecognitionData(BLLCommon.macroKeyValue);
if (BLLCommon.config.CheckFunction)
{
Extension_Checks("2");
}
} }
private void WpfControl_Cherkfun(object sender, EventArgs e) private void WpfControl_Cherkfun(object sender, EventArgs e)
{ {
if (BLLCommon.config.Language.Equals("English"))
{
bool result = MessageboxNeo.Show("", "Whether to skip this operation?", "NEO SCAN", true);
if (result)
{
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false;
//lastKeys = null;
string text = "";
if (BLLCommon.config.Language.Equals("English"))
{
text = "Waiting";
}
else if (BLLCommon.config.Language.Equals("日语"))
{
text = "待機中";
}
else
{
text = "等待中";
}
wpfControl.SetSkipButtonVisibility(false);
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
}
}
else if (BLLCommon.config.Language.Equals("日语"))
{
bool result = MessageboxNeo.Show("",
"この操作をスキップしますか?",
"NEO SCAN",
true);
if (result)
{
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false;
//lastKeys = null;
string text = "";
if (BLLCommon.config.Language.Equals("English"))
{
text = "Waiting";
}
else if (BLLCommon.config.Language.Equals("日语"))
{
text = "待機中";
}
else
{
text = "等待中";
}
wpfControl.SetSkipButtonVisibility(false);
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
}
}
else
{
bool result = MessageboxNeo.Show("", "是否跳过此操作?", "NEO SCAN", true);
if (result)
{
wpfControl.ClearFieldContents(); // 这会将文本设置为空,颜色设置为白色
scanWork.needPrint = false;
//lastKeys = null;
string text = "";
if (BLLCommon.config.Language.Equals("English"))
{
text = "Waiting";
}
else if (BLLCommon.config.Language.Equals("日语"))
{
text = "待機中";
}
else
{
text = "等待中";
}
wpfControl.SetSkipButtonVisibility(false);
wpfControl.SetResultText(text, "#FFCC00"); // 显示NG
}
}
extension.CheckClears(); extension.CheckClears();
} }
...@@ -780,14 +882,30 @@ namespace SmartScan ...@@ -780,14 +882,30 @@ namespace SmartScan
// } // }
//} //}
string aa = "";
try try
{ {
foreach (string key in content.Keys) foreach (string key in content.Keys)
{// 提取简写键(保留原键的层级结构) {// 提取简写键(保留原键的层级结构)
string shortKey = key.Split('/').First(); // 输出 "RID" 或 "QTY" string shortKey = key.Split('/').First(); // 输出 "RID" 或 "QTY"
str += string.Format("({0}:{1})", shortKey, content[key]); str += string.Format("({0}:{1})", shortKey, content[key]);
aa += string.Format("({0}:{1})", shortKey, content[key]);
}
try
{
// 确保目录存在
string directory = Path.GetDirectoryName(FilePath.CONFIG_Code_Value);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
// 覆盖文件内容(只保留最新日志)
File.WriteAllText(FilePath.CONFIG_Code_Value, $"{aa}");
}
catch (Exception ex)
{
LogNet.log.Error($"写入文件失败: {ex.Message}");
} }
LogNet.log.Info(str); LogNet.log.Info(str);
...@@ -842,6 +960,7 @@ namespace SmartScan ...@@ -842,6 +960,7 @@ namespace SmartScan
scanWork.generals = new General(BLLCommon.config); scanWork.generals = new General(BLLCommon.config);
BLLCommon.extension.KeySets += OnBllKeySet; BLLCommon.extension.KeySets += OnBllKeySet;
BLLCommon.extension.Checks += Extension_Checks; ; BLLCommon.extension.Checks += Extension_Checks; ;
scanWork.Check2s += Extension_Checks;
LblVersion.Text = BLLCommon.config.SoftVersion; LblVersion.Text = BLLCommon.config.SoftVersion;
LblUserName.Text = BLLCommon.config.UserName; LblUserName.Text = BLLCommon.config.UserName;
...@@ -894,10 +1013,27 @@ namespace SmartScan ...@@ -894,10 +1013,27 @@ namespace SmartScan
private void Extension_Checks(string text) private void Extension_Checks(string text)
{ {
if (text=="OK")
if (this.InvokeRequired)
{
this.Invoke(new Action(() => Extension_Checks(text)));
return;
}
if (text == "1")
{
wpfControl.SetSkipButtonVisibility(true);
return;
}
if (text == "2")
{
wpfControl.SetSkipButtonVisibility(false);
return;
}
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
} }
...@@ -905,6 +1041,7 @@ namespace SmartScan ...@@ -905,6 +1041,7 @@ namespace SmartScan
{ {
wpfControl.SetResultNG(); // 显示NG wpfControl.SetResultNG(); // 显示NG
} }
} }
private void OnBllKeySet(string[] originalCode, Dictionary<string, string> key, bool hasMatch) private void OnBllKeySet(string[] originalCode, Dictionary<string, string> key, bool hasMatch)
......
...@@ -12,6 +12,7 @@ using System.Drawing; ...@@ -12,6 +12,7 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using static BLL.BLLCommon; using static BLL.BLLCommon;
...@@ -40,12 +41,12 @@ namespace SmartScan ...@@ -40,12 +41,12 @@ namespace SmartScan
btnMatchedName = (FaceButton)Common.frmMain.Controls["BtnMatchedName"]; btnMatchedName = (FaceButton)Common.frmMain.Controls["BtnMatchedName"];
} }
private void Extension_Checks(string text)
{
throw new NotImplementedException();
}
public void Open() public void Open()
{ {
...@@ -90,6 +91,12 @@ namespace SmartScan ...@@ -90,6 +91,12 @@ namespace SmartScan
static System.Diagnostics.Stopwatch reckontime = new System.Diagnostics.Stopwatch(); static System.Diagnostics.Stopwatch reckontime = new System.Diagnostics.Stopwatch();
public bool bendi = false; public bool bendi = false;
protected virtual void CheckText(string text)
{
extension.Check(text);
}
public delegate void Check2(string text);
public event Check2 Check2s;
public void Scan() public void Scan()
{ {
//此段代码加锁是因为,客户在连续点击识别设备按钮时,线程会同时生成rid=123并且rid赋值是重复的123123 //此段代码加锁是因为,客户在连续点击识别设备按钮时,线程会同时生成rid=123并且rid赋值是重复的123123
...@@ -99,6 +106,11 @@ namespace SmartScan ...@@ -99,6 +106,11 @@ namespace SmartScan
if (!isRun) return; if (!isRun) return;
if (isTouch) return; if (isTouch) return;
if (BLLCommon.config.CheckFunction)
{
Check2s?.Invoke("1");
}
isTouch = true; isTouch = true;
btnMatchedName.Invoke(delegate () btnMatchedName.Invoke(delegate ()
{ {
...@@ -153,6 +165,46 @@ namespace SmartScan ...@@ -153,6 +165,46 @@ namespace SmartScan
//Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialTemplateMatching"),5);//模版匹配... //Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialTemplateMatching"),5);//模版匹配...
reckontime.Restart(); reckontime.Restart();
//Common.frmMain.Showlogs("OCR识别中请稍后"); //Common.frmMain.Showlogs("OCR识别中请稍后");
Common.frmMain.Showlogs("");
if (needPrint&&BLLCommon.config.CheckFunction)
{
LoadingScreen.Instance.Hide();
originalCodeText = Camera.GetBarCodeText(workCodeInfo);
// 检查条码内容是否与文件中的内容匹配
bool isMatched = CheckCodeWithFileContent(originalCodeText);
if (isMatched)
{
Check2s?.Invoke("2");
// Common.frmMain.wpfControl.SetResultOK();
Check2s?.Invoke("OK");
needPrint =false;
}
else
{
Check2s?.Invoke("NG");
}
}
else
{
string text = "";
if (BLLCommon.config.Language.Equals("English"))
{
text = "Waiting";
}
else if (BLLCommon.config.Language.Equals("日语"))
{
text = "待機中";
}
else
{
text = "等待中";
}
Check2s?.Invoke("text");
bool hasMatch = MatchingTemplate(); bool hasMatch = MatchingTemplate();
LogNet.log.Info($"模板匹配耗时{reckontime.ElapsedMilliseconds}ms"); LogNet.log.Info($"模板匹配耗时{reckontime.ElapsedMilliseconds}ms");
reckontime.Restart(); reckontime.Restart();
...@@ -167,6 +219,10 @@ namespace SmartScan ...@@ -167,6 +219,10 @@ namespace SmartScan
isTouch = false; isTouch = false;
LogNet.log.Info("Work scan is done"); LogNet.log.Info("Work scan is done");
LogNet.log.Info($"渲染控件耗时{reckontime.ElapsedMilliseconds}ms"); LogNet.log.Info($"渲染控件耗时{reckontime.ElapsedMilliseconds}ms");
}
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -185,7 +241,46 @@ namespace SmartScan ...@@ -185,7 +241,46 @@ namespace SmartScan
}); });
} }
} }
// 修改方法定义
private bool CheckCodeWithFileContent(string[] codeTexts)
{
if (codeTexts == null || codeTexts.Length == 0)
{
LogNet.log.Warn("条码文本数组为空,无法进行匹配");
return false;
}
try
{
// 检查文件是否存在
if (!File.Exists(FilePath.CONFIG_Code_Value))
{
LogNet.log.Warn($"匹配文件不存在: {FilePath.CONFIG_Code_Value}");
return false;
}
// 读取文件内容
string fileContent = File.ReadAllText(FilePath.CONFIG_Code_Value);
// 检查文件内容是否包含任一条码文本
foreach (string codeText in codeTexts)
{
if (fileContent.Contains(codeText))
{
LogNet.log.Info($"条码 {codeText} 在文件中找到匹配");
return true;
}
}
LogNet.log.Info("所有条码在文件中均未找到匹配");
return false;
}
catch (Exception ex)
{
LogNet.log.Error($"检查文件内容时出错: {ex.Message}");
return false;
}
}
public void Scan(string[] code) public void Scan(string[] code)
{ {
try try
...@@ -590,6 +685,7 @@ namespace SmartScan ...@@ -590,6 +685,7 @@ namespace SmartScan
return rtn; return rtn;
} }
public bool Ispring=true; public bool Ispring=true;
public bool needPrint = false;
public void SetKey(bool hasMatch) public void SetKey(bool hasMatch)
{ {
LogNet.log.Info("Work SetKey hasMatch:" + hasMatch); LogNet.log.Info("Work SetKey hasMatch:" + hasMatch);
...@@ -599,8 +695,16 @@ namespace SmartScan ...@@ -599,8 +695,16 @@ namespace SmartScan
bool a= BLLCommon.extension.SetKey(originalCodeText, workCodeKeyword, hasMatch, out _); bool a= BLLCommon.extension.SetKey(originalCodeText, workCodeKeyword, hasMatch, out _);
LoadingScreen.Instance.Hide(); LoadingScreen.Instance.Hide();
Common.frmMain.Showlogs(""); Common.frmMain.Showlogs("");
// 通过检查结果状态来判断是否需要打印
if (Ispring) // 检查结果是否为"等待中"/"Waiting"/"待機中",以判断是否是第一次拍照
if (BLLCommon.extension.labelText != null)
{
string status = BLLCommon.extension.labelText.ToLower();
needPrint = (status == "等待中" || status == "Waiting" || status == "待機中");
}
if (needPrint)
{ {
if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>"))) if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>")))
{ {
...@@ -652,12 +756,7 @@ namespace SmartScan ...@@ -652,12 +756,7 @@ namespace SmartScan
} }
else else
{ {
if (!a)
{
}
else
{
if (bendi) if (bendi)
{ {
string YU = BLLCommon.config.Language; string YU = BLLCommon.config.Language;
...@@ -685,7 +784,7 @@ namespace SmartScan ...@@ -685,7 +784,7 @@ namespace SmartScan
} }
//打印 //打印
}
} }
if (BLLCommon.config.PromptAfterPrinting && !BLL.Config.Backgrounder) if (BLLCommon.config.PromptAfterPrinting && !BLL.Config.Backgrounder)
...@@ -695,82 +794,82 @@ namespace SmartScan ...@@ -695,82 +794,82 @@ namespace SmartScan
} }
Ispring = true; Ispring = true;
} }
else //else
{
if (!a)
{
}
else
{
string YU = BLLCommon.config.Language;
bool result = false;
if (YU == "English")
{
result = NeoAlertBox.Show("", "Identified content is incomplete. Continue printing anyway?", AlertType.Warning, "NEO SCAN", true);
}
else if (YU == "日语")
{
result = NeoAlertBox.Show("", "認識内容が不完全です。印刷を続けますか?", AlertType.Warning, "NEO SCAN", true);
}
else
{
result = NeoAlertBox.Show("", "识别的内容不完整,是否继续打印?", AlertType.Warning, "NEO SCAN", true);
}
if (result)
{
if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>")))
{
BLLCommon.extension.DrawTextBackground(workCodeKeyword);
//FrmDrawText frmDraw = new FrmDrawText();
//if (frmDraw.ShowDialog() == DialogResult.OK)
//{ //{
Dictionary<string, string> pairs = workCodeKeyword.ToDictionary(val => val.Key, // if (!a)
val => val.Value.StartsWith("<OCR>") ? val.Value.Replace("<OCR>", "") : val.Value // {
);
//打印
BLLCommon.extension.Print(hasMatch, pairs);
//}
}
else
{
if (bendi)
{
bool result1 = false;
if (YU == "English")
{
result1 = NeoAlertBox.Show("", "Whether to print or not?", 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
{
BLLCommon.extension.Print(hasMatch, workCodeKeyword);
}
}
if (BLLCommon.config.PromptAfterPrinting && !BLL.Config.Backgrounder)
{
string text = Language.Dialog("SelectPrintContent");
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
}
Ispring = true;
} // }
Ispring = true; // else
} // {
// string YU = BLLCommon.config.Language;
// bool result = false;
// if (YU == "English")
// {
// result = NeoAlertBox.Show("", "Identified content is incomplete. Continue printing anyway?", AlertType.Warning, "NEO SCAN", true);
// }
// else if (YU == "日语")
// {
// result = NeoAlertBox.Show("", "認識内容が不完全です。印刷を続けますか?", AlertType.Warning, "NEO SCAN", true);
// }
// else
// {
// result = NeoAlertBox.Show("", "识别的内容不完整,是否继续打印?", AlertType.Warning, "NEO SCAN", true);
// }
// if (result)
// {
// if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>")))
// {
// BLLCommon.extension.DrawTextBackground(workCodeKeyword);
// //FrmDrawText frmDraw = new FrmDrawText();
// //if (frmDraw.ShowDialog() == DialogResult.OK)
// //{
// Dictionary<string, string> pairs = workCodeKeyword.ToDictionary(val => val.Key,
// val => val.Value.StartsWith("<OCR>") ? val.Value.Replace("<OCR>", "") : val.Value
// );
// //打印
// BLLCommon.extension.Print(hasMatch, pairs);
// //}
// }
// else
// {
// if (bendi)
// {
// bool result1 = false;
// if (YU == "English")
// {
// result1 = NeoAlertBox.Show("", "Whether to print or not?", 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
// {
// BLLCommon.extension.Print(hasMatch, workCodeKeyword);
// }
// }
// if (BLLCommon.config.PromptAfterPrinting && !BLL.Config.Backgrounder)
// {
// string text = Language.Dialog("SelectPrintContent");
// new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
// }
// Ispring = true;
} // }
// Ispring = true;
// }
//}
} }
} }
......
...@@ -138,6 +138,30 @@ namespace SmartScan.SetControl.WPF ...@@ -138,6 +138,30 @@ namespace SmartScan.SetControl.WPF
// 更新识别结果 // 更新识别结果
UpdateRecognitionResults(ResultItemsPanel); UpdateRecognitionResults(ResultItemsPanel);
} }
public void ClearFieldContents()
{
foreach (var kvp in fieldControls)
{
kvp.Value.Text = string.Empty;
// 同时更新数据字典
if (recognizedData.ContainsKey(kvp.Key))
{
recognizedData[kvp.Key] = string.Empty;
fieldValidStatus[kvp.Key] = false;
}
}
// 更新结果显示
UpdateRecognitionResults(ResultItemsPanel);
// 触发数据更新事件
DataUpdated?.Invoke(this, "clear");
// 触发ISPrint事件(如果适用)
ISPrint?.Invoke(this, null);
}
private TextBlock txtResults; private TextBlock txtResults;
public NS_KetRight() public NS_KetRight()
{ {
...@@ -263,7 +287,7 @@ namespace SmartScan.SetControl.WPF ...@@ -263,7 +287,7 @@ namespace SmartScan.SetControl.WPF
TextBlock resultTextBlock = new TextBlock TextBlock resultTextBlock = new TextBlock
{ {
Name = "txtResults", Name = "txtResults",
Text = "NG", // 初始为空,稍后会根据结果设置为"OK"或"NG" Text = "", // 初始为空,稍后会根据结果设置为"OK"或"NG"
Margin = new Thickness(8, 0, 0, 0), Margin = new Thickness(8, 0, 0, 0),
Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f0f0f0")), Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f0f0f0")),
FontSize = 14, FontSize = 14,
...@@ -361,6 +385,18 @@ namespace SmartScan.SetControl.WPF ...@@ -361,6 +385,18 @@ namespace SmartScan.SetControl.WPF
//ButtonsPanel.Children.Add(printButton); //ButtonsPanel.Children.Add(printButton);
} }
/// <summary>
/// 设置跳过按钮的可见性
/// </summary>
/// <param name="isVisible">true 显示按钮,false 隐藏按钮</param>
public void SetSkipButtonVisibility(bool isVisible)
{
if (skipButton != null)
{
skipButton.Visibility = isVisible ? Visibility.Visible : Visibility.Collapsed;
}
}
/// <summary> /// <summary>
/// 更新界面语言 /// 更新界面语言
/// </summary> /// </summary>
......
...@@ -617,7 +617,7 @@ Visibility="Collapsed"/> ...@@ -617,7 +617,7 @@ Visibility="Collapsed"/>
<!-- 已选关键词(按显示顺序排列) --> <!-- 已选关键词(按显示顺序排列) -->
<TextBlock Text="已选关键词(按显示顺序排列)" Name="xianshi" Style="{StaticResource LabelStyle}" Margin="0,15,0,5"/> <TextBlock Text="已选关键词(按显示顺序排列)" Name="xianshi" Style="{StaticResource LabelStyle}" Margin="0,15,0,5"/>
<Border Background="#222222" CornerRadius="5" Margin="0,0,0,15"> <Border Background="#222222" CornerRadius="5" Margin="0,0,0,15">
<ScrollViewer MaxHeight="200" Margin="5"> <ScrollViewer MaxHeight="200" Margin="5" >
<StackPanel x:Name="SelectedKeywordsPanel" > <StackPanel x:Name="SelectedKeywordsPanel" >
<!-- 已选关键词将在此动态添加 --> <!-- 已选关键词将在此动态添加 -->
</StackPanel> </StackPanel>
......
...@@ -60,6 +60,7 @@ namespace SmartScan.SetControl.WPF ...@@ -60,6 +60,7 @@ namespace SmartScan.SetControl.WPF
// 新增属性用于流水号 // 新增属性用于流水号
public bool IsSerialNumber { get; set; } // 是否为流水号 public bool IsSerialNumber { get; set; } // 是否为流水号
public string SerialExample { get; set; } // 流水号示例 public string SerialExample { get; set; } // 流水号示例
public bool IsEditing { get; set; } // 新增编辑状态属性
} }
private readonly List<string> keyCopy; private readonly List<string> keyCopy;
...@@ -305,16 +306,65 @@ namespace SmartScan.SetControl.WPF ...@@ -305,16 +306,65 @@ namespace SmartScan.SetControl.WPF
} }
}; };
Grid.SetColumn(numberBorder, 0); Grid.SetColumn(numberBorder, 0);
StackPanel contentPanel = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal };
// 关键词文本 - 这里已经支持显示流水号预览格式 // 关键词文本 - 这里已经支持显示流水号预览格式
System.Windows.Controls.TextBlock keywordText = new System.Windows.Controls.TextBlock System.Windows.Controls.TextBlock keywordText = new System.Windows.Controls.TextBlock
{ {
Text = keyword.DisplayText ?? keyword.Text, Text = keyword.DisplayText ?? keyword.Text,
Visibility = keyword.IsEditing ? Visibility.Collapsed : Visibility.Visible,
Foreground = Brushes.White, Foreground = Brushes.White,
VerticalAlignment = VerticalAlignment.Center, VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(10, 0, 0, 0), Margin = new Thickness(10, 0, 0, 0),
FontSize = 14, FontSize = 14,
FontFamily = new System.Windows.Media.FontFamily("微软雅黑"), FontFamily = new System.Windows.Media.FontFamily("微软雅黑"),
}; };
// 可编辑的TextBox
System.Windows.Controls.TextBox editTextBox = new System.Windows.Controls.TextBox
{
Text = keyword.Text,
Visibility = keyword.IsEditing ? Visibility.Visible : Visibility.Collapsed,
MinWidth = 100,
Margin = new Thickness(10, 0, 0, 0),
FontSize = 14,
FontFamily = new FontFamily("微软雅黑"),
Foreground = Brushes.White,
Background = Brushes.Transparent,
BorderThickness = new Thickness(1),
BorderBrush = Brushes.White
};
// 添加键盘事件处理
editTextBox.KeyDown += (s, e) => {
if (e.Key == Key.Enter)
{
keyword.Text = editTextBox.Text;
keyword.DisplayText = editTextBox.Text;
keyword.IsEditing = false;
UpdateSelectedKeywordsUI();
}
};
// 失去焦点时保存
editTextBox.LostFocus += (s, e) => {
keyword.Text = editTextBox.Text;
keyword.DisplayText = editTextBox.Text;
keyword.IsEditing = false;
UpdateSelectedKeywordsUI();
};
contentPanel.Children.Add(keywordText);
contentPanel.Children.Add(editTextBox);
// 双击事件处理
itemGrid.MouseDown += (s, e) => {
if (e.ClickCount == 2 && !keyword.IsEditing)
{
keyword.IsEditing = true;
UpdateSelectedKeywordsUI();
// 设置焦点到TextBox
Dispatcher.BeginInvoke((Action)(() => {
editTextBox.Focus();
editTextBox.SelectAll();
}), System.Windows.Threading.DispatcherPriority.Render);
}
};
Grid.SetColumn(keywordText, 1); Grid.SetColumn(keywordText, 1);
// 上移按钮 // 上移按钮
Button upButton = new Button Button upButton = new Button
...@@ -351,11 +401,14 @@ namespace SmartScan.SetControl.WPF ...@@ -351,11 +401,14 @@ namespace SmartScan.SetControl.WPF
Grid.SetColumn(removeButton, 4); Grid.SetColumn(removeButton, 4);
// 添加所有元素到网格 // 添加所有元素到网格
itemGrid.Children.Add(numberBorder); itemGrid.Children.Add(numberBorder);
itemGrid.Children.Add(keywordText); //itemGrid.Children.Add(keywordText);
itemGrid.Children.Add(upButton); itemGrid.Children.Add(upButton);
itemGrid.Children.Add(downButton); itemGrid.Children.Add(downButton);
itemGrid.Children.Add(removeButton); itemGrid.Children.Add(removeButton);
// 将网格添加到面板 // 将网格添加到面板
Grid.SetColumn(contentPanel, 1);
itemGrid.Children.Add(contentPanel);
SelectedKeywordsPanel.Children.Add(itemGrid); SelectedKeywordsPanel.Children.Add(itemGrid);
} }
// 更新预览 // 更新预览
...@@ -940,5 +993,8 @@ namespace SmartScan.SetControl.WPF ...@@ -940,5 +993,8 @@ namespace SmartScan.SetControl.WPF
string keywordsStr = string.Join(",", keywords); string keywordsStr = string.Join(",", keywords);
BLLCommon.config.CharacterTypeKeywords = keywordsStr; BLLCommon.config.CharacterTypeKeywords = keywordsStr;
} }
} }
} }
<UserControl x:Class="SmartScan.SetControl.WPF.UserControl2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SmartScan.SetControl.WPF"
mc:Ignorable="d"
d:DesignHeight="650" d:DesignWidth="500">
<Grid>
<ListView x:Name="data3" Background="#1c1c1c" BorderThickness="1" BorderBrush="Gray" Foreground="White" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionChanged="data3_SelectionChanged">
<!-- 设置交替行数为2 -->
<ListView.AlternationCount>2</ListView.AlternationCount>
<!-- 自定义每个项的显示模板 -->
<ListView.ItemTemplate>
<DataTemplate>
<ContentControl Content="{Binding Converter={StaticResource OcrTextHighlighter}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" FontSize="14" FontFamily="微软雅黑"
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Converter={StaticResource WidthMinusMarginConverter}}"/>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="MinHeight" Value="25"/>
<Setter Property="Padding" Value="5,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderThickness="0">
<ContentPresenter HorizontalAlignment="Left"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="#005A9E"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<!-- 交替行颜色 -->
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#353535"/>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#2a2a2a"/>
</Trigger>
<!-- 选中行颜色 -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#0061c8"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<!-- 鼠标悬停效果 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#464646"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Grid>
</UserControl>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SmartScan.SetControl.WPF
{
/// <summary>
/// UserControl2.xaml 的交互逻辑
/// </summary>
public partial class UserControl2 : UserControl
{
public UserControl2()
{
InitializeComponent();
}
// 公开获取data3控件的方法
public ListView GetListView()
{
return data3;
}
// 提供设置ItemsSource的方法
public void SetItemsSource(IEnumerable source)
{
data3.ItemsSource = source;
}
// 暴露选中索引改变的事件
public event SelectionChangedEventHandler SelectionChanged;
private void data3_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// 触发外部事件
SelectionChanged?.Invoke(sender, e);
}
}
}
...@@ -44,7 +44,14 @@ namespace SmartScan.SetControl.WPF ...@@ -44,7 +44,14 @@ namespace SmartScan.SetControl.WPF
public UsrPrintTemplateleft() public UsrPrintTemplateleft()
{ {
InitializeComponent(); InitializeComponent();
if (LstLabel.SelectedIndex >= 0)
{
LabelSelectionChanged?.Invoke(this, new LabelSelectionEventArgs
{
SelectedIndex = 0,
SelectedItem = LstLabel.SelectedItem.ToString()
});
}
} }
// 清空标签列表 // 清空标签列表
public void ClearLabelList() public void ClearLabelList()
...@@ -53,6 +60,7 @@ namespace SmartScan.SetControl.WPF ...@@ -53,6 +60,7 @@ namespace SmartScan.SetControl.WPF
} }
private void LstLabel_SelectedIndexChanged(object sender, SelectionChangedEventArgs e) private void LstLabel_SelectedIndexChanged(object sender, SelectionChangedEventArgs e)
{ {
if (LstLabel.SelectedIndex == -1) return;
if (LstLabel.SelectedIndex >= 0) if (LstLabel.SelectedIndex >= 0)
{ {
LabelSelectionChanged?.Invoke(this, new LabelSelectionEventArgs LabelSelectionChanged?.Invoke(this, new LabelSelectionEventArgs
...@@ -61,6 +69,8 @@ namespace SmartScan.SetControl.WPF ...@@ -61,6 +69,8 @@ namespace SmartScan.SetControl.WPF
SelectedItem = LstLabel.SelectedItem.ToString() SelectedItem = LstLabel.SelectedItem.ToString()
}); });
} }
// 重置选中状态
LstLabel.SelectedIndex = -1;
} }
private readonly SizeF LABEL_ADD_DEFAULT = new(50, 60); private readonly SizeF LABEL_ADD_DEFAULT = new(50, 60);
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
</Button.Tag> </Button.Tag>
</Button> </Button>
<Button Content="AI" Name="BtnAI" Style="{StaticResource MenuButtonStyle}" Click="BtnAI_Click"> <Button Content="AI" Name="BtnAI" Style="{StaticResource MenuButtonStyle}" Visibility="Collapsed" Click="BtnAI_Click">
<Button.Tag> <Button.Tag>
<Image Source="/Resources/AI.png" Width="18" Height="18" /> <Image Source="/Resources/AI.png" Width="18" Height="18" />
</Button.Tag> </Button.Tag>
......
...@@ -477,7 +477,7 @@ ...@@ -477,7 +477,7 @@
</Grid> </Grid>
</Border> </Border>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Frame x:Name="aa"></Frame> <ContentControl x:Name="aa"></ContentControl>
</Grid> </Grid>
</Grid> </Grid>
......
...@@ -382,6 +382,7 @@ namespace SmartScan.SetControl.WPF ...@@ -382,6 +382,7 @@ namespace SmartScan.SetControl.WPF
{ {
if (userControls.TryGetValue(clickedButton, out UserControl1 userControl)) if (userControls.TryGetValue(clickedButton, out UserControl1 userControl))
{ {
//aa.NavigationService?.RemoveBackEntry();
// 清空Frame内容 // 清空Frame内容
aa.Content = null; aa.Content = null;
......
...@@ -463,7 +463,7 @@ ...@@ -463,7 +463,7 @@
<StackPanel Grid.Row="6"> <StackPanel Grid.Row="6">
<Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_BtnExport" Click="FrmRetrospect_BtnExport_Click" Content="导出" Margin="0,5,0,5"/> <Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_BtnExport" Click="FrmRetrospect_BtnExport_Click" Content="导出" Margin="0,5,0,5"/>
<Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_BtnExportAll" Click="FrmRetrospect_BtnExportAll_Click" Content="导出所有" Margin="0,5,0,5"/> <Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_BtnExportAll" Click="FrmRetrospect_BtnExportAll_Click" Content="导出所有" Margin="0,5,0,5"/>
<Button Style="{StaticResource buttonStyle}" Name="FrmRetrospect_butt_startserver" Click="FrmRetrospect_butt_startserver_Click" Content="启动服务" Margin="0,5,0,5"/> <Button Style="{StaticResource buttonStyle}" Visibility="Collapsed" Name="FrmRetrospect_butt_startserver" Click="FrmRetrospect_butt_startserver_Click" Content="启动服务" Margin="0,5,0,5"/>
<!-- 结果显示区域 --> <!-- 结果显示区域 -->
<TextBlock Text="" Name="FrmRetrospect_faceLabel1" Foreground="White" Margin="0,15,0,5"/> <TextBlock Text="" Name="FrmRetrospect_faceLabel1" Foreground="White" Margin="0,15,0,5"/>
......
...@@ -252,6 +252,9 @@ ...@@ -252,6 +252,9 @@
<Compile Include="SetControl\WPF\UserControl1.xaml.cs"> <Compile Include="SetControl\WPF\UserControl1.xaml.cs">
<DependentUpon>UserControl1.xaml</DependentUpon> <DependentUpon>UserControl1.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="SetControl\WPF\UserControl2.xaml.cs">
<DependentUpon>UserControl2.xaml</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\UsrPrintTemplatebottom.xaml.cs"> <Compile Include="SetControl\WPF\UsrPrintTemplatebottom.xaml.cs">
<DependentUpon>UsrPrintTemplatebottom.xaml</DependentUpon> <DependentUpon>UsrPrintTemplatebottom.xaml</DependentUpon>
</Compile> </Compile>
...@@ -598,6 +601,10 @@ ...@@ -598,6 +601,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="SetControl\WPF\UserControl2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SetControl\WPF\UsrPrintTemplatebottom.xaml"> <Page Include="SetControl\WPF\UsrPrintTemplatebottom.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!