Commit b2cad748 刘韬

bugfix

1 个父辈 f85a0b3d
......@@ -215,7 +215,7 @@ namespace BLL
foreach (var item in BLLCommon.macroKeyValue)
{
string[] parts = item.Split('\t');
if (parts.Length >= 3 && parts[0] == "DateTime" && parts[2].Trim().Equals("True", StringComparison.OrdinalIgnoreCase))
if (parts.Length >= 3 && parts[0].ToLower() == "DateTime".ToLower() && parts[2].Trim().Equals("True", StringComparison.OrdinalIgnoreCase))
{
addDateTime = true;
break;
......
......@@ -417,7 +417,7 @@ namespace SmartScan
scanWork.isstart = false;
Task.Run(() =>
{
scanWork.Scan();
scanWork.Scan(true);
//scanWork.TouchOff();
});
};
......
......@@ -124,7 +124,7 @@ UsrPrintTemplate_BtnDelLabel 删除标签 Delete Label Arial,12,,
UsrPrintTemplate_BtnCopyLabel 复制标签 Duplicate Label Arial,11,,
UsrPrintTemplate_BtnRenameLabel 重命名 Rename Arial,12,,
UsrPrintTemplate_BtnPrintTest 打印测试 Print Test Arial,12,,
UsrPrintTemplate_BtnAddField 添加字段 Add Filed Arial,12,,
UsrPrintTemplate_BtnAddField 添加字段 Add Field Arial,12,,
UsrPrintTemplate_BtnDelField 删除字段 Delete Filed Arial,12,,
UsrPrintTemplate_BtnFieldFont 字段字体 Field Font Arial,12,,
UsrPrintTemplate_BtnSetField 设置字段内容 Set Filed Content Arial,12,,
......@@ -413,4 +413,7 @@ Dialog_NS_KetRight_Green 绿色 - 完全正确 Green - Completely correct 微软
Dialog_NS_KetRight_yllow 黄色 - OCR识别结果,需要验证 OCR recognition result, needs verification 微软雅黑,12,,
Dialog_NS_KetRight_Red 红色 - 无法识别或有问题 Unrecognizable or problematic 微软雅黑,12,,
Dialog_NS_KetRight_TextBlock 识别结果 Result: 微软雅黑,12,,
NS_KetRight_Detect 已检测字段 Detected Fields 微软雅黑,12,,
\ No newline at end of file
NS_KetRight_Detect 已检测字段 Detected Fields 微软雅黑,12,,
Dialog_NS_KetRight_Detect 已检测字段 Detected Fields 微软雅黑,12,,
Dialog_About_About 关于 About
Dialog_About_mrs 物料注册系统 Material Registration System
......@@ -462,4 +462,58 @@ Dialog_NS_KetRight_Green 绿色 - 完全正确 绿色 - 完全正确 微软雅
Dialog_NS_KetRight_yllow 黄色 - OCR识别结果,需要验证 黄色 - OCR识别结果,需要验证 微软雅黑,12,,
Dialog_NS_KetRight_Red 红色 - 无法识别或有问题 红色 - 无法识别或有问题 微软雅黑,12,,
Dialog_NS_KetRight_TextBlock 识别结果 识别结果 微软雅黑,12,,
NS_KetRight_Detect 已检测字段 已检测字段 微软雅黑,12,,
\ No newline at end of file
NS_KetRight_Detect 已检测字段 已检测字段 微软雅黑,12,,Dialog_NS_KetRight_Detect 已检测字段
Dialog_NS_KetRight_Detect 已检测字段 已检测字段
Dialog_NS_KetRight_Detect 已检测字段 已检测字段
FrmSet_pnlPrintTmpLst 标签模板 标签模板 Arial,12,,
FrmSet_pnlPrintTmpLstOp 标签模板操作 标签模板操作 Arial,12,,
FrmSet_BtnAddLabel 新建标签 新建标签 Arial,12,,
FrmSet_BtnDelLabel 删除标签 删除标签 Arial,12,,
FrmSet_BtnCopyLabel 复制标签 复制标签 Arial,12,,
FrmSet_BtnRenameLabel 重命名 重命名 Arial,12,,
FrmSet_pnLabelStyle 标签样式 标签样式 Arial,12,,
FrmSet_pnAllFieldsOfLabel 标签的所有字段 标签的所有字段 Arial,12,,
FrmSet_facePanel7 字段操作 字段操作 Arial,12,,
FrmSet_BtnAddField 添加字段 添加字段 Arial,12,,
FrmSet_BtnDelField 删除字段 删除字段 Arial,12,,
FrmSet_BtnFieldFont 字段字体 字段字体 Arial,12,,
FrmSet_ChkFieldShowKey 显示关键字 显示关键字 Arial,12,,
FrmSet_BtnSetField 设置字段内容 设置字段内容 Arial,12,,
FrmSet_BtnPrintTest 打印测试 打印测试 Arial,12,,
FrmSet_LblFieldType 条形码类型 条形码类型 Arial,12,,
FrmSet_pnLabelFieldPos 字段位置 字段位置 Arial,12,,
FrmSet_LblFieldSize 纸张大小 纸张大小 Arial,12,,
FrmSet_ChkRecursive 遍历同目录 遍历同目录 Arial,12,,
FrmSet_groupBox_lblkey 标签可用字段 标签可用字段 Arial,12,,
FrmSet_BtnSelectFile 选择文件 选择文件 Arial,12,,
FrmSet_faceLabel2 关键字匹配数据标题 关键字匹配数据标题 Arial,12,,
FrmSet_faceLabel1 识别关键词 识别关键词 Arial,12,,
FrmSet_LblFilestatus 文件状态: 文件状态: Arial,12,,
FrmSet_LblContent 标签数据源 标签数据源 Arial,12,,
FrmSet_pnlPrintTmpLst 标签模板 标签模板 Arial,12,,
FrmSet_pnlPrintTmpLstOp 标签模板操作 标签模板操作 Arial,12,,
FrmSet_BtnAddLabel 新建标签 新建标签 Arial,12,,
FrmSet_BtnDelLabel 删除标签 删除标签 Arial,12,,
FrmSet_BtnCopyLabel 复制标签 复制标签 Arial,12,,
FrmSet_BtnRenameLabel 重命名 重命名 Arial,12,,
FrmSet_pnLabelStyle 标签样式 标签样式 Arial,12,,
FrmSet_pnAllFieldsOfLabel 标签的所有字段 标签的所有字段 Arial,12,,
FrmSet_facePanel7 字段操作 字段操作 Arial,12,,
FrmSet_BtnAddField 添加字段 添加字段 Arial,12,,
FrmSet_BtnDelField 删除字段 删除字段 Arial,12,,
FrmSet_BtnFieldFont 字段字体 字段字体 Arial,12,,
FrmSet_ChkFieldShowKey 显示关键字 显示关键字 Arial,12,,
FrmSet_BtnSetField 设置字段内容 设置字段内容 Arial,12,,
FrmSet_BtnPrintTest 打印测试 打印测试 Arial,12,,
FrmSet_LblFieldType 条形码类型 条形码类型 Arial,12,,
FrmSet_pnLabelFieldPos 字段位置 字段位置 Arial,12,,
FrmSet_LblFieldSize 纸张大小 纸张大小 Arial,12,,
FrmSet_ChkRecursive 遍历同目录 遍历同目录 Arial,12,,
FrmSet_groupBox_lblkey 标签可用字段 标签可用字段 Arial,12,,
FrmSet_BtnSelectFile 选择文件 选择文件 Arial,12,,
FrmSet_faceLabel2 关键字匹配数据标题 关键字匹配数据标题 Arial,12,,
FrmSet_faceLabel1 识别关键词 识别关键词 Arial,12,,
FrmSet_LblFilestatus 文件状态: 文件状态: Arial,12,,
FrmSet_LblContent 标签数据源 标签数据源 Arial,12,,
Dialog_About_About 关于 关于
Dialog_About_mrs 物料注册系统 物料注册系统
......@@ -9,6 +9,7 @@ using SmartScan.SetControl.WPF.Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
......@@ -97,7 +98,7 @@ namespace SmartScan
}
public delegate void Check2(string text);
public event Check2 Check2s;
public void Scan()
public void Scan(bool fromlocalfile=false)
{
//此段代码加锁是因为,客户在连续点击识别设备按钮时,线程会同时生成rid=123并且rid赋值是重复的123123
//在测试时也遇到这个情况,但只成功复现了一次;故加锁。
......@@ -136,7 +137,7 @@ namespace SmartScan
originalCodeIsUsed = null;
LoadingScreen.Instance.Hide();
if (!GetCodeInfo())
if (!GetCodeInfo(fromlocalfile))
{
isTouch = false;
Common.frmMain.CloseWaittingDialog();
......@@ -420,11 +421,11 @@ namespace SmartScan
});
}
public bool isstart = false;
private bool GetCodeInfo()
private bool GetCodeInfo(bool fromlocalfile = false)
{
LogNet.log.Info("Work GetCodeInfo");
if (BLLCommon.config.EnabledCamera)// && isstart==true)
if (BLLCommon.config.EnabledCamera && !fromlocalfile)// && isstart==true)
{
LogNet.log.Info("1");
if (BLLCommon.config.TriggerOpenLight)
......@@ -444,7 +445,8 @@ namespace SmartScan
{
// 使用WPF控件显示图片
if (!BLL.Config.Backgrounder)
{
{//在图片画出识别的二维码
picShow.Image = image[0];
DisplayBitmapInWpfControl(image[0]);
}
......@@ -492,29 +494,7 @@ namespace SmartScan
workCodeInfo = Camera.GetBarCode(bmp);
//在图片画出识别的二维码
//kmon
//2025-6-25
int contenI = 1;
workCodeInfo.ForEach(info =>
{
//原本是画框,角度不对
//PointF[] points = GetRotatedRectanglePoints(info.Center, info.Size.Width, info.Size.Height, info.Angle+90);
//using (Pen pen = new Pen(Color.Red, 2))
//{
//System.Drawing.Graphics g = Graphics.FromImage(bmp);
//g.DrawLines(Pens.Red, points);
//}
//修改为写数字
using (System.Drawing.Graphics g = Graphics.FromImage(bmp))
{
string str = contenI.ToString();
Font font = new Font("Arial", 40);
SizeF textSize=g.MeasureString(str, font);
g.DrawString(str, font, Brushes.Red, info.Center);
}
contenI++;
});
//DrawCodeIndex(bmp, workCodeInfo);
......@@ -541,6 +521,51 @@ namespace SmartScan
LogNet.log.Info("条码个数:" + workCodeInfo.Count);
}
public static void DrawCodeIndex(Bitmap bmp, List<CameraVisionLib.Model.BarcodeInfo> workCodeInfo)
{
int contenI = 1;
workCodeInfo.ForEach(info =>
{
using (Graphics g = Graphics.FromImage(bmp))
{
string str = contenI.ToString();
Font font = new Font("Arial", 60, System.Drawing.FontStyle.Bold);
SizeF sz = g.MeasureString(str, font);
// 为了让文字中心落在 info.Center 上
RectangleF rc = new RectangleF(
info.Center.X - sz.Width / 4,
info.Center.Y - sz.Height / 4,
sz.Width, sz.Height);
// 1. 画白色描边
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddString(str,
font.FontFamily,
(int)font.Style,
font.SizeInPoints, // 用 Point 单位
rc.Location,
StringFormat.GenericDefault);
// 描边宽度可调
using (Pen pen = new Pen(Color.White, 10f))
{
pen.LineJoin = LineJoin.Round;
g.DrawPath(pen, gp);
}
// 2. 填充红色字
using (Brush brush = new SolidBrush(Color.Red))
{
g.FillPath(brush, gp);
}
}
}
contenI++;
});
}
//根据中心点取四个角的坐标
//kmon
//2025-6-25
......@@ -593,10 +618,8 @@ namespace SmartScan
}
// 创建新图片的副本以避免资源冲突
Bitmap bitmapCopy = new Bitmap(bitmap);
imageTest.imageBox.Image = bitmapCopy;
// 适应屏幕显示
imageTest.FitToScreen();
// 处理条码中心点
if (workCodeInfo != null && workCodeInfo.Count > 0)
{
......@@ -607,12 +630,19 @@ namespace SmartScan
.ToArray();
if (centers.Length > 0)
{
Console.WriteLine($"绘制 {centers.Length} 个条码中心点");
//Console.WriteLine($"绘制 {centers.Length} 个条码中心点");
// 使用新的直接绘制方法
imageTest.DrawCenterPointsOnImage(centers);
//imageTest.DrawCenterPointsOnImage(centers);
DrawCodeIndex(bitmapCopy, workCodeInfo);
}
}
imageTest.imageBox.Image = bitmapCopy;
// 适应屏幕显示
imageTest.FitToScreen();
}
......
......@@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -19,7 +20,6 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
......@@ -93,21 +93,24 @@ namespace SmartScan.SetControl.WPF
{ // 加载并显示图像
var bitMap= (Bitmap)ObjConversion.ReadImageFile(iamgepath);
int contenI = 1;
mateCopy[mateIndex].Code.ForEach(codeInfo =>
{
PointF ConterPoint;
using (System.Drawing.Graphics g = Graphics.FromImage(bitMap))
{
ConterPoint = new PointF(codeInfo.CenterX,codeInfo.CenterY);
string str = contenI.ToString();
Font font = new Font("Arial", 20);
SizeF textSize = g.MeasureString(str, font);
g.DrawString(str, font, System.Drawing.Brushes.Red, ConterPoint);
}
contenI++;
//int contenI = 1;
//mateCopy[mateIndex].Code.ForEach(codeInfo =>
//{
// PointF ConterPoint;
// using (System.Drawing.Graphics g = Graphics.FromImage(bitMap))
// {
// ConterPoint = new PointF(codeInfo.CenterX,codeInfo.CenterY);
// string str = contenI.ToString();
// Font font = new Font("Arial", 20);
// SizeF textSize = g.MeasureString(str, font);
// g.DrawString(str, font, System.Drawing.Brushes.Red, ConterPoint);
// }
// contenI++;
//});
var infocode = mateCopy[mateIndex].Code.Select(ci => new BarcodeInfo { Center = new PointF(ci.CenterX, ci.CenterY) }).ToList();
ScanWork.DrawCodeIndex(bitMap, infocode);
});
ImgShow.Image = bitMap;
// 清除并填充条码列表
......@@ -391,7 +394,10 @@ namespace SmartScan.SetControl.WPF
private void UsrMaterialTemplate_BtnScanCode_Click(object sender, RoutedEventArgs e)
{
if (mateIndex == -1) return;
if (bmp == null) return;
if (bmp == null)
iscamp=true;
else
iscamp = false;
string text = LanguageWwitchover.Dialog(LanguageDialogKey.REMIND_CLEARTEMPLATE, "Recognizing code will reset the template.Are you sure to perform the action?");
bool dialogResult= NeoAlertBox.Show(mateCopy[mateIndex].Name, text,AlertType.Warning,"NEO SCAN",true);
//DialogResult dialogResult = new FaceMessageBox(mateCopy[mateIndex].Name, text, MessageBoxButtons.YesNo).ShowDialog();
......@@ -408,13 +414,18 @@ namespace SmartScan.SetControl.WPF
bmp = result[0];
mateCopy[mateIndex].ImagePath = "";
mateCopy[mateIndex].Image = bmp;
ImgShow.Image = bmp;
}
else
{
info = Camera.GetBarCode(bmp);
}
var bmp2 = (Bitmap)bmp.Clone();
ScanWork.DrawCodeIndex(bmp2, info);
ImgShow.Image = bmp2;
//info = Camera.GetBarCode(bmp);
data3.ItemsSource = null;
......
......@@ -161,6 +161,7 @@ namespace SmartScan.SetControl.WPF
if (_centers == null || _centers.Length == 0 || imageBox == null || imageBox.Image == null)
return;
return;
// 获取图像和显示的关系
double zoomFactor = imageBox.ZoomFactor;
System.Drawing.Rectangle viewport = imageBox.GetImageViewPort();
......
......@@ -122,7 +122,7 @@ namespace SmartScan
//}
var aa = BLLCommon.macroKey;
// 2. 初始化目标字典
Dictionary<string, string> aaa = new Dictionary<string, string>();// { { "LOT",null} };
Dictionary<string, string> aaa = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);// { { "LOT",null} };
foreach (var key in aa)
{
aaa[key] = ""; // or aaa.Add(key, null);
......@@ -269,7 +269,7 @@ namespace SmartScan
LogNet.log.Info("模板匹配结果:" + rtn);
WebResultCode webResultCode = null;
Dictionary<string, string> keys = new Dictionary<string, string>();
Dictionary<string, string> keys = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var item in workCodeKeyword)
{
// workCodeKeyword[item.Key]= item.Value.Replace("<OCR>", "");
......@@ -443,7 +443,7 @@ namespace SmartScan
point = UsrKeywordlabeling.LabelingAngle(Value, aMatch, new Point(bitmapData.X, bitmapData.Y), bitmapData.IsIDCamera, bitmapData.PlateW, out angle, aMatch.CodeType);
//point =UsrCustomlabeling.LabelingAngle_New(mateName, aMatch, new Point(bitmapData.X, bitmapData.Y), bitmapData.IsIDCamera, bitmapData.PlateW, out angle);
}
Dictionary<string, string> keys = new Dictionary<string, string>();
Dictionary<string, string> keys = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var item in workCodeKeyword)
{
keys.Add(item.Key, item.Value.Replace("<OCR>", ""));
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!