Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS100
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 68183dbb
由
王海洋
编写于
2025-06-25 16:44:13 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
将物料模板识别区域用数字标识
1 个父辈
e503d6e7
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
100 行增加
和
4 行删除
SmartScan/App.config
SmartScan/Form/FrmMain.cs
SmartScan/ScanWork.cs
SmartScan/SetControl/WPF/WPF_MaterialTemplate.xaml.cs
SmartScan/App.config
查看文件 @
68183db
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
</
startup
>
</
startup
>
<
appSettings
>
<
appSettings
>
<
add
key
=
"EnableWindowsFormsHighDpiAutoResizing"
value
=
"true"
/>
<
add
key
=
"EnableWindowsFormsHighDpiAutoResizing"
value
=
"true"
/>
<
add
key
=
"ClientSettingsProvider.ServiceUri"
value
=
""
/>
</
appSettings
>
</
appSettings
>
<
system
.
serviceModel
>
<
system
.
serviceModel
>
<
bindings
>
<
bindings
>
...
@@ -44,5 +45,16 @@
...
@@ -44,5 +45,16 @@
</
dependentAssembly
>
</
dependentAssembly
>
</
assemblyBinding
>
</
assemblyBinding
>
</
runtime
>
</
runtime
>
<
system
.
web
>
<
membership
defaultProvider
=
"ClientAuthenticationMembershipProvider"
>
<
providers
>
<
add
name
=
"ClientAuthenticationMembershipProvider"
type
=
"System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
serviceUri
=
""
/>
</
providers
>
</
membership
>
<
roleManager
defaultProvider
=
"ClientRoleProvider"
enabled
=
"true"
>
<
providers
>
<
add
name
=
"ClientRoleProvider"
type
=
"System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
serviceUri
=
""
cacheTimeout
=
"86400"
/>
</
providers
>
</
roleManager
>
</
system
.
web
>
</
configuration
>
</
configuration
>
\ No newline at end of file
\ No newline at end of file
SmartScan/Form/FrmMain.cs
查看文件 @
68183db
...
@@ -44,6 +44,7 @@ namespace SmartScan
...
@@ -44,6 +44,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
...
@@ -62,6 +63,8 @@ namespace SmartScan
...
@@ -62,6 +63,8 @@ namespace SmartScan
// wpf更新字体
// wpf更新字体
UpdateNS_VericalMenuControl
();
UpdateNS_VericalMenuControl
();
//初始化图片界面
//初始化图片界面
//先注释
//kmon
InitializeImageControls
();
InitializeImageControls
();
// 添加窗体大小调整事件
// 添加窗体大小调整事件
this
.
Resize
+=
YourWinFormClass_Resize
;
this
.
Resize
+=
YourWinFormClass_Resize
;
...
...
SmartScan/ScanWork.cs
查看文件 @
68183db
...
@@ -26,7 +26,7 @@ namespace SmartScan
...
@@ -26,7 +26,7 @@ namespace SmartScan
private
bool
isTouch
=
false
;
private
bool
isTouch
=
false
;
private
readonly
FacePictureBox
picShow
;
private
readonly
FacePictureBox
picShow
;
private
readonly
FaceButton
btnMatchedName
;
private
readonly
FaceButton
btnMatchedName
;
//private readonly System.Windows.Forms.Panel wpfImagePanel;
public
List
<
CameraVisionLib
.
Model
.
BarcodeInfo
>
workCodeInfo
;
public
List
<
CameraVisionLib
.
Model
.
BarcodeInfo
>
workCodeInfo
;
public
Dictionary
<
string
,
string
>
workCodeKeyword
;
public
Dictionary
<
string
,
string
>
workCodeKeyword
;
public
string
[]
originalCodeText
;
public
string
[]
originalCodeText
;
...
@@ -39,7 +39,7 @@ namespace SmartScan
...
@@ -39,7 +39,7 @@ namespace SmartScan
{
{
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;
}
}
...
@@ -481,6 +481,34 @@ namespace SmartScan
...
@@ -481,6 +481,34 @@ namespace SmartScan
Bitmap
bmp
=
null
;
Bitmap
bmp
=
null
;
bmp
=
ObjConversion
.
ReadImageFile
(
filename
);
bmp
=
ObjConversion
.
ReadImageFile
(
filename
);
workCodeInfo
=
Camera
.
GetBarCode
(
bmp
);
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
++;
});
Common
.
frmMain
.
Invoke
(
delegate
()
Common
.
frmMain
.
Invoke
(
delegate
()
{
{
if
(!
BLL
.
Config
.
Backgrounder
)
if
(!
BLL
.
Config
.
Backgrounder
)
...
@@ -504,6 +532,34 @@ namespace SmartScan
...
@@ -504,6 +532,34 @@ namespace SmartScan
LogNet
.
log
.
Info
(
"条码个数:"
+
workCodeInfo
.
Count
);
LogNet
.
log
.
Info
(
"条码个数:"
+
workCodeInfo
.
Count
);
}
}
//根据中心点取四个角的坐标
//kmon
//2025-6-25
//private PointF[] GetRotatedRectanglePoints(PointF center, float length, float width, float angle)
//{
// // 将角度转换为弧度
// float radians =(float) (angle * (Math.PI / 4));
// float halfLength = length / 2;
// float halfWidth = width / 2;
// PointF[] points = new PointF[4];
// points[0] = new PointF(center.X + halfLength, center.Y - halfWidth); // 左上角
// points[1] = new PointF(center.X + halfLength, center.Y + halfWidth); // 右下角
// points[2] = new PointF(center.X - halfLength, center.Y + halfWidth); // 左下角
// points[3] = new PointF(center.X - halfLength, center.Y - halfWidth); // 右上角
// // 应用旋转变换
// PointF[] rotatedPoints = new PointF[4];
// for (int i = 0; i < points.Length; i++)
// {
// float dx = points[i].X - center.X;
// float dy = points[i].Y - center.Y;
// float newX = center.X + (dx * (float)Math.Cos(radians) - dy * (float)Math.Sin(radians));
// float newY = center.Y + (dx * (float)Math.Sin(radians) + dy * (float)Math.Cos(radians));
// rotatedPoints[i] = new PointF(newX, newY);
// }
// return rotatedPoints;
//}
// 新增方法:将Bitmap显示在WPF控件中
// 新增方法:将Bitmap显示在WPF控件中
private
void
DisplayBitmapInWpfControl
(
Bitmap
bitmap
)
private
void
DisplayBitmapInWpfControl
(
Bitmap
bitmap
)
{
{
...
@@ -645,6 +701,8 @@ namespace SmartScan
...
@@ -645,6 +701,8 @@ namespace SmartScan
if
(!
BLL
.
Config
.
Backgrounder
)
if
(!
BLL
.
Config
.
Backgrounder
)
picShow
.
AddCodeCenter
(
center
);
picShow
.
AddCodeCenter
(
center
);
System
.
Windows
.
Forms
.
Application
.
DoEvents
();
System
.
Windows
.
Forms
.
Application
.
DoEvents
();
}
}
public
bool
MatchingTemplate
()
public
bool
MatchingTemplate
()
...
...
SmartScan/SetControl/WPF/WPF_MaterialTemplate.xaml.cs
查看文件 @
68183db
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Asa.FaceControl
;
using
Asa.FaceControl
;
using
BLL
;
using
BLL
;
using
CameraVisionLib.Model
;
using
CameraVisionLib.Model
;
using
DocumentFormat.OpenXml.EMMA
;
using
Model
;
using
Model
;
using
SmartScan.SetControl.WPF.Model
;
using
SmartScan.SetControl.WPF.Model
;
using
System
;
using
System
;
...
@@ -90,7 +91,24 @@ namespace SmartScan.SetControl.WPF
...
@@ -90,7 +91,24 @@ namespace SmartScan.SetControl.WPF
{
{
if
(
System
.
IO
.
File
.
Exists
(
iamgepath
))
if
(
System
.
IO
.
File
.
Exists
(
iamgepath
))
{
// 加载并显示图像
{
// 加载并显示图像
ImgShow
.
Image
=
ObjConversion
.
ReadImageFile
(
iamgepath
);
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
++;
});
ImgShow
.
Image
=
bitMap
;
// 清除并填充条码列表
// 清除并填充条码列表
codeItems
.
Clear
();
codeItems
.
Clear
();
...
@@ -101,6 +119,11 @@ namespace SmartScan.SetControl.WPF
...
@@ -101,6 +119,11 @@ namespace SmartScan.SetControl.WPF
if
(
data3
.
Items
.
Count
>
0
)
if
(
data3
.
Items
.
Count
>
0
)
data3
.
SelectedIndex
=
-
1
;
data3
.
SelectedIndex
=
-
1
;
bmp
=
(
Bitmap
)
ImgShow
.
Image
;
bmp
=
(
Bitmap
)
ImgShow
.
Image
;
//给条码加上识别数字
//kmon
//2025-6-25
}
}
else
else
{
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论