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