Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS100
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 27ad3e76
由
王海洋
编写于
2025-06-10 18:18:17 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
why修改
1 个父辈
ade252a8
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
750 行增加
和
254 行删除
BLL/Extension/Item_General.cs
BLL/ExtraFileData.cs
BLL/MessageboxNeo.cs
BLL/ServerCommunication.cs
Model/FilePath.cs
SmartScan/Form/FrmMain.cs
SmartScan/ScanWork.cs
SmartScan/SetControl/WPF/NS_KetRight.xaml.cs
SmartScan/SetControl/WPF/NS_Keyword.xaml
SmartScan/SetControl/WPF/NS_Keyword.xaml.cs
SmartScan/SetControl/WPF/UserControl2.xaml
SmartScan/SetControl/WPF/UserControl2.xaml.cs
SmartScan/SetControl/WPF/UsrPrintTemplateleft.xaml.cs
SmartScan/SetControl/WPF/VerticalMenuControl.xaml
SmartScan/SetControl/WPF/WPF_CodeExtract.xaml
SmartScan/SetControl/WPF/WPF_CodeExtract.xaml.cs
SmartScan/SetControl/WPF/WPF_Date_From.xaml
SmartScan/SmartScan.csproj
BLL/Extension/Item_General.cs
查看文件 @
27ad3e7
...
...
@@ -148,6 +148,7 @@ namespace BLL
var
now
=
DateTime
.
Now
;
// 比较当前 key 和上次的 key
bool
isSame
=
false
;
bool
isFirstCapture
=
lastKeys
==
null
;
try
{
...
...
@@ -202,21 +203,24 @@ namespace BLL
}
#
endregion
// 添加或替换自增ID
string
reelIdKeyWord
=
config
.
ReelIDKeyWord
;
if
(!
string
.
IsNullOrEmpty
(
config
.
ReelIDKeyWord
)
&&
isdisplay
)
{
var
Reelidstr
=
GetReelid
();
if
(
key
.
ContainsKey
(
config
.
ReelIDKeyWord
))
{
key
[
config
.
ReelIDKeyWord
]
=
Reelidstr
;
}
else
if
(!
string
.
IsNullOrEmpty
(
config
.
ReelIDKeyWord
)
&&
isdisplay
)
{
key
.
Add
(
config
.
ReelIDKeyWord
,
Reelidstr
);
}
var
Reelidstr
=
GetReelid
();
if
(
key
.
ContainsKey
(
config
.
ReelIDKeyWord
))
{
key
[
config
.
ReelIDKeyWord
]
=
Reelidstr
;
}
else
{
key
.
Add
(
config
.
ReelIDKeyWord
,
Reelidstr
);
}
}
}
//客户定制key
string
exKey
=
ConfigHelper
.
Config
.
Get
(
"Ex_UserDataKey"
,
"Manufactured_Date"
);
if
(
macroKey
.
Contains
(
exKey
))
...
...
@@ -230,6 +234,30 @@ namespace BLL
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
)
{
//使用key填充时,请处理字段开头的<OCR>字段
...
...
@@ -246,37 +274,57 @@ namespace BLL
}
}
}
lastkey
=
key
;
islast
=
false
;
if
(
lastKeys
!=
null
)
{
// 创建不包含自增ID的临时字典进行比较
var
keyWithoutReelID
=
new
Dictionary
<
string
,
string
>(
key
);
var
lastKeysWithoutReelID
=
new
Dictionary
<
string
,
string
>(
lastKeys
);
// 从比较中排除自增ID
if
(!
string
.
IsNullOrEmpty
(
reelIdKeyWord
))
if
(
BLLCommon
.
config
.
CheckFunction
)
{
keyWithoutReelID
.
Remove
(
reelIdKeyWord
);
lastKeysWithoutReelID
.
Remove
(
reelIdKeyWord
);
if
(
BLLCommon
.
config
.
Language
.
Equals
(
"English"
))
{
BLLCommon
.
extension
.
labelText
=
"Waiting"
;
CheckText
(
"Waiting"
);
}
else
if
(
BLLCommon
.
config
.
Language
.
Equals
(
"日语"
))
{
BLLCommon
.
extension
.
labelText
=
"待機中"
;
CheckText
(
"待機中"
);
}
else
{
BLLCommon
.
extension
.
labelText
=
"等待中"
;
CheckText
(
"等待中"
);
}
islast
=
false
;
}
// 创建不包含自增ID的临时字典进行比较
//var keyWithoutReelID = new Dictionary<string, string>(key);
//var lastKeysWithoutReelID = new Dictionary<string, string>(lastKeys);
// 比较不包含自增ID的字典
isSame
=
keyWithoutReelID
.
Count
==
lastKeysWithoutReelID
.
Count
&&
!
keyWithoutReelID
.
Except
(
lastKeysWithoutReelID
).
Any
();
}
lastkey
=
key
;
islast
=
false
;
if
(
isSame
)
{
BLLCommon
.
extension
.
labelText
=
"OK"
;
CheckText
(
"OK"
);
lastKeys
=
null
;
islast
=
true
;
// 两次的 key 相同,可添加相应逻辑
}
else
if
(
lastKeys
!=
null
&&
!
isSame
)
{
// 两次的 key 不同,可添加相应逻辑
BLLCommon
.
extension
.
labelText
=
"NG"
;
CheckText
(
"NG"
);
//// 从比较中排除自增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
{
...
...
@@ -286,7 +334,8 @@ namespace BLL
{
BLLCommon
.
extension
.
labelText
=
"Waiting"
;
CheckText
(
"Waiting"
);
}
else
if
(
BLLCommon
.
config
.
Language
.
Equals
(
"日语"
))
}
else
if
(
BLLCommon
.
config
.
Language
.
Equals
(
"日语"
))
{
BLLCommon
.
extension
.
labelText
=
"待機中"
;
CheckText
(
"待機中"
);
...
...
@@ -297,22 +346,25 @@ namespace BLL
CheckText
(
"等待中"
);
}
islast
=
false
;
}
}
}
// 如果有字段更新,则再次调用OnKeySet更新WPF界面
OnKeySet
(
originalCode
,
key
,
hasMatch
);
}
// 如果有字段更新,则再次调用OnKeySet更新WPF界面
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
{
extensions
[
i
].
Control
.
Text
=
BLLCommon
.
extension
.
labelText
;
}
//if (extensions[i].LinkName == "ischeckresult" && lastKeys != null)
//{
// if (BLLCommon.extension.labelText == "NG")
// {
// extensions[i].Control.Text = BLLCommon.extension.labelText;
// extensions[i].Control.ForeColor = System.Drawing.Color.Red;
// }
// else if (BLLCommon.extension.labelText == "OK")
// {
// extensions[i].Control.Text = BLLCommon.extension.labelText;
// extensions[i].Control.ForeColor = System.Drawing.Color.Green;
// }
//}
}
}
if
(!
updatereelid
(
key
,
out
errmsg
))
return
false
;
//if (BLLCommon.config.CheckFunction)
//{
// if (isFirstCapture)
// {
// if (!updatereelid(key, out errmsg))
// return false;
// }
//}
//else
//{
if
(!
updatereelid
(
key
,
out
errmsg
))
return
false
;
// }
Application
.
DoEvents
();
...
...
@@ -387,36 +431,53 @@ namespace BLL
}
}
if
(
BLLCommon
.
config
.
CheckFunction
&&!
islast
)
{
return
false
;
}
//
if (BLLCommon.config.CheckFunction&&!islast)
//
{
//
return false;
//
}
return
true
;
}
bool
updatereelid
(
Dictionary
<
string
,
string
>
key
,
out
string
errmsg
)
{
errmsg
=
""
;
if
(!
string
.
IsNullOrEmpty
(
config
.
HttpReelID
))
errmsg
=
""
;
try
{
Dictionary
<
string
,
object
>
pairs
=
new
Dictionary
<
string
,
object
>();
if
(!
GetHttpReelID
(
key
,
out
errmsg
,
out
pairs
))
foreach
(
var
item
in
key
)
{
LogNet
.
log
.
Error
(
"GetHttpReelID:"
+
errmsg
);
return
false
;
LogNet
.
log
.
Info
(
"接口上传信息("
+
item
.
Key
+
":"
+
item
.
Value
+
")"
);
}
//key["ReelID"] = newid;
}
if
(
extensions
!=
null
&&
extensions
.
Count
>
0
&&
!
extensions
[
0
].
Control
.
InvokeRequired
)
{
for
(
int
i
=
0
;
i
<
extensions
.
Count
;
i
++)
if
(!
string
.
IsNullOrEmpty
(
config
.
HttpReelID
))
{
if
(
extensions
[
i
].
Key
.
ToLower
()
==
"reelid"
&&
key
.
ContainsKey
(
"reelid"
))
extensions
[
i
].
Control
.
Text
=
key
[
"reelid"
];
Dictionary
<
string
,
object
>
pairs
=
new
Dictionary
<
string
,
object
>();
if
(!
GetHttpReelID
(
key
,
out
errmsg
,
out
pairs
))
{
LogNet
.
log
.
Error
(
"GetHttpReelID:"
+
errmsg
);
return
false
;
}
//key["ReelID"] = newid;
}
if
(
extensions
!=
null
&&
extensions
.
Count
>
0
&&
!
extensions
[
0
].
Control
.
InvokeRequired
)
{
for
(
int
i
=
0
;
i
<
extensions
.
Count
;
i
++)
{
if
(
extensions
[
i
].
Key
.
ToLower
()
==
"reelid"
&&
key
.
ContainsKey
(
"reelid"
))
extensions
[
i
].
Control
.
Text
=
key
[
"reelid"
];
}
}
}
catch
(
Exception
ex
)
{
LogNet
.
log
.
Info
(
"ex"
+
ex
.
ToString
());
}
//SaveRetrospect?.Invoke(key);
return
true
;
}
public
void
Update
()
...
...
@@ -664,44 +725,7 @@ namespace BLL
}
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
)
{
...
...
@@ -822,7 +846,8 @@ namespace BLL
{
errmsg
=
"Api error"
;
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
;
}
...
...
@@ -836,7 +861,8 @@ namespace BLL
{
errmsg
=
"Api parse error:\r\n"
+
json
;
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
;
}
...
...
@@ -844,7 +870,8 @@ namespace BLL
if
(!
dic
.
TryGetValue
(
"CODE"
,
out
object
value
))
{
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
errmsg
=
"Api return data error:\r\n"
+
json
;
return
false
;
...
...
BLL/ExtraFileData.cs
查看文件 @
27ad3e7
...
...
@@ -173,7 +173,7 @@ namespace BLL
if
(!
File
.
Exists
(
filename
))
return
titles
;
LogNet
.
log
.
Info
(
"filename:"
+
filename
);
XLWorkbook
wb
=
new
XLWorkbook
(
filename
);
IXLWorksheet
ws
=
wb
.
Worksheet
(
1
);
for
(
int
i
=
1
;
i
<
50
;
i
++)
...
...
BLL/MessageboxNeo.cs
查看文件 @
27ad3e7
...
...
@@ -35,6 +35,8 @@ namespace BLL
public
MessageboxNeo
(
string
headerText
,
string
descriptionText
,
string
title
=
"NEO SCAN"
,
bool
showCancelButton
=
true
)
{
InitializeComponent
();
this
.
TopMost
=
true
;
// 添加这一行,使窗体总是在最前面
this
.
StartPosition
=
FormStartPosition
.
CenterScreen
;
// 改为CenterScreen以相对于整个屏幕居中
titleLabel
.
Text
=
title
;
headerLabel
.
Text
=
headerText
;
descriptionLabel
.
Text
=
descriptionText
;
...
...
BLL/ServerCommunication.cs
查看文件 @
27ad3e7
...
...
@@ -256,7 +256,7 @@ namespace BLL
public
class
Operation
{
public
string
cid
;
public
string
type
=
"N
EOSCAN
"
;
//COUNTING
public
string
type
=
"N
S100
"
;
//COUNTING
public
StoreStatus
status
;
public
int
seq
;
public
int
op
;
...
...
Model/FilePath.cs
查看文件 @
27ad3e7
...
...
@@ -26,6 +26,7 @@ namespace Model
public
static
readonly
string
CONFIG_EXTENSION
=
Environment
.
CurrentDirectory
+
"\\Config\\Extension.json"
;
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_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"
;
}
}
SmartScan/Form/FrmMain.cs
查看文件 @
27ad3e7
using
Asa.FaceControl
;
using
BLL
;
using
DocumentFormat.OpenXml.Bibliography
;
using
HandyControl.Properties.Langs
;
using
HandyControl.Tools.Extension
;
using
Model
;
using
Newtonsoft.Json
;
...
...
@@ -57,6 +58,7 @@ namespace SmartScan
InitializeImageControls
();
// 添加窗体大小调整事件
this
.
Resize
+=
YourWinFormClass_Resize
;
}
private
void
YourWinFormClass_Resize
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -186,6 +188,7 @@ namespace SmartScan
// 调用新的UpdateLanguage方法,而不仅仅是UpdateRight
wpfControl
.
UpdateLanguage
();
}
}
// 当窗口状态改变时,通知WPF控件
...
...
@@ -415,6 +418,8 @@ namespace SmartScan
// 确保它位于Z顺序的顶部
host
.
BringToFront
();
}
...
...
@@ -474,12 +479,109 @@ namespace SmartScan
PnlExtension
.
Left
=
Width
-
PnlExtension
.
Width
-
12
;
PnlExtension
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(
20
,
20
,
20
);
wpfControl
.
UpdateMultipleRecognitionData
(
BLLCommon
.
macroKeyValue
);
if
(
BLLCommon
.
config
.
CheckFunction
)
{
Extension_Checks
(
"2"
);
}
}
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
();
}
...
...
@@ -780,16 +882,32 @@ namespace SmartScan
// }
//}
string
aa
=
""
;
try
{
foreach
(
string
key
in
content
.
Keys
)
{
// 提取简写键(保留原键的层级结构)
string
shortKey
=
key
.
Split
(
'/'
).
First
();
// 输出 "RID" 或 "QTY"
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
);
SaveResult
(
content
);
//Bitmap labelBmp = Common.labelEdit.PrintImage(Common.config.DefaultPrintLabel, content, out _);
...
...
@@ -842,6 +960,7 @@ namespace SmartScan
scanWork
.
generals
=
new
General
(
BLLCommon
.
config
);
BLLCommon
.
extension
.
KeySets
+=
OnBllKeySet
;
BLLCommon
.
extension
.
Checks
+=
Extension_Checks
;
;
scanWork
.
Check2s
+=
Extension_Checks
;
LblVersion
.
Text
=
BLLCommon
.
config
.
SoftVersion
;
LblUserName
.
Text
=
BLLCommon
.
config
.
UserName
;
...
...
@@ -894,17 +1013,35 @@ namespace SmartScan
private
void
Extension_Checks
(
string
text
)
{
if
(
text
==
"OK"
)
if
(
this
.
InvokeRequired
)
{
wpfControl
.
SetResultOK
();
}
else
if
(
text
==
"等待中"
||
text
==
"Waiting"
||
text
==
"待機中"
)
this
.
Invoke
(
new
Action
(()
=>
Extension_Checks
(
text
)));
return
;
}
if
(
text
==
"1"
)
{
wpfControl
.
SetResultText
(
text
,
"#FFCC00"
);
// 显示NG
wpfControl
.
SetSkipButtonVisibility
(
true
);
return
;
}
else
if
(
text
==
"2"
)
{
wpfControl
.
SetResultNG
();
// 显示NG
wpfControl
.
SetSkipButtonVisibility
(
false
);
return
;
}
if
(
text
==
"OK"
)
{
wpfControl
.
SetResultOK
();
}
else
if
(
text
==
"等待中"
||
text
==
"Waiting"
||
text
==
"待機中"
)
{
wpfControl
.
SetResultText
(
text
,
"#FFCC00"
);
// 显示NG
}
else
{
wpfControl
.
SetResultNG
();
// 显示NG
}
}
private
void
OnBllKeySet
(
string
[]
originalCode
,
Dictionary
<
string
,
string
>
key
,
bool
hasMatch
)
...
...
SmartScan/ScanWork.cs
查看文件 @
27ad3e7
...
...
@@ -12,6 +12,7 @@ using System.Drawing;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Web.UI.WebControls
;
using
System.Windows
;
using
System.Windows.Forms
;
using
static
BLL
.
BLLCommon
;
...
...
@@ -33,19 +34,19 @@ namespace SmartScan
//bool falg = true;
public
General
generals
;
public
ScanWork
()
{
picShow
=
(
FacePictureBox
)
Common
.
frmMain
.
Controls
[
"PicShow"
];
btnMatchedName
=
(
FaceButton
)
Common
.
frmMain
.
Controls
[
"BtnMatchedName"
];
}
private
void
Extension_Checks
(
string
text
)
{
throw
new
NotImplementedException
();
}
public
void
Open
()
{
...
...
@@ -90,6 +91,12 @@ namespace SmartScan
static
System
.
Diagnostics
.
Stopwatch
reckontime
=
new
System
.
Diagnostics
.
Stopwatch
();
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
()
{
//此段代码加锁是因为,客户在连续点击识别设备按钮时,线程会同时生成rid=123并且rid赋值是重复的123123
...
...
@@ -99,6 +106,11 @@ namespace SmartScan
if
(!
isRun
)
return
;
if
(
isTouch
)
return
;
if
(
BLLCommon
.
config
.
CheckFunction
)
{
Check2s
?.
Invoke
(
"1"
);
}
isTouch
=
true
;
btnMatchedName
.
Invoke
(
delegate
()
{
...
...
@@ -153,20 +165,64 @@ namespace SmartScan
//Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialTemplateMatching"),5);//模版匹配...
reckontime
.
Restart
();
//Common.frmMain.Showlogs("OCR识别中请稍后");
bool
hasMatch
=
MatchingTemplate
();
LogNet
.
log
.
Info
(
$
"模板匹配耗时{reckontime.ElapsedMilliseconds}ms"
);
reckontime
.
Restart
();
//Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialProcessing"),5);//计算结果...
Common
.
frmMain
.
Invoke
(
delegate
()
{
SetKey
(
hasMatch
);
});
Common
.
frmMain
.
Showlogs
(
""
);
isTouch
=
false
;
LogNet
.
log
.
Info
(
"Work scan is done"
);
LogNet
.
log
.
Info
(
$
"渲染控件耗时{reckontime.ElapsedMilliseconds}ms"
);
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
();
LogNet
.
log
.
Info
(
$
"模板匹配耗时{reckontime.ElapsedMilliseconds}ms"
);
reckontime
.
Restart
();
//Common.frmMain.SetWaittingMsg(Language.Dialog("MaterialProcessing"),5);//计算结果...
Common
.
frmMain
.
Invoke
(
delegate
()
{
SetKey
(
hasMatch
);
});
Common
.
frmMain
.
Showlogs
(
""
);
isTouch
=
false
;
LogNet
.
log
.
Info
(
"Work scan is done"
);
LogNet
.
log
.
Info
(
$
"渲染控件耗时{reckontime.ElapsedMilliseconds}ms"
);
}
}
catch
(
Exception
ex
)
{
...
...
@@ -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
)
{
try
...
...
@@ -590,6 +685,7 @@ namespace SmartScan
return
rtn
;
}
public
bool
Ispring
=
true
;
public
bool
needPrint
=
false
;
public
void
SetKey
(
bool
hasMatch
)
{
LogNet
.
log
.
Info
(
"Work SetKey hasMatch:"
+
hasMatch
);
...
...
@@ -599,8 +695,16 @@ namespace SmartScan
bool
a
=
BLLCommon
.
extension
.
SetKey
(
originalCodeText
,
workCodeKeyword
,
hasMatch
,
out
_
);
LoadingScreen
.
Instance
.
Hide
();
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>"
)))
{
...
...
@@ -652,12 +756,7 @@ namespace SmartScan
}
else
{
if
(!
a
)
{
}
else
{
if
(
bendi
)
{
string
YU
=
BLLCommon
.
config
.
Language
;
...
...
@@ -685,7 +784,7 @@ namespace SmartScan
}
//打印
}
}
if
(
BLLCommon
.
config
.
PromptAfterPrinting
&&
!
BLL
.
Config
.
Backgrounder
)
...
...
@@ -695,82 +794,82 @@ namespace SmartScan
}
Ispring
=
true
;
}
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
,
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
//
{
//
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,
//
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;
//
}
}
//
}
}
}
...
...
SmartScan/SetControl/WPF/NS_KetRight.xaml.cs
查看文件 @
27ad3e7
...
...
@@ -138,6 +138,30 @@ namespace SmartScan.SetControl.WPF
// 更新识别结果
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
;
public
NS_KetRight
()
{
...
...
@@ -263,7 +287,7 @@ namespace SmartScan.SetControl.WPF
TextBlock
resultTextBlock
=
new
TextBlock
{
Name
=
"txtResults"
,
Text
=
"
NG
"
,
// 初始为空,稍后会根据结果设置为"OK"或"NG"
Text
=
""
,
// 初始为空,稍后会根据结果设置为"OK"或"NG"
Margin
=
new
Thickness
(
8
,
0
,
0
,
0
),
Foreground
=
new
SolidColorBrush
((
Color
)
ColorConverter
.
ConvertFromString
(
"#f0f0f0"
)),
FontSize
=
14
,
...
...
@@ -361,6 +385,18 @@ namespace SmartScan.SetControl.WPF
//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>
...
...
SmartScan/SetControl/WPF/NS_Keyword.xaml
查看文件 @
27ad3e7
...
...
@@ -617,7 +617,7 @@ Visibility="Collapsed"/>
<!-- 已选关键词(按显示顺序排列) -->
<TextBlock Text="已选关键词(按显示顺序排列)" Name="xianshi" Style="{StaticResource LabelStyle}" Margin="0,15,0,5"/>
<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>
...
...
SmartScan/SetControl/WPF/NS_Keyword.xaml.cs
查看文件 @
27ad3e7
...
...
@@ -60,7 +60,8 @@ namespace SmartScan.SetControl.WPF
// 新增属性用于流水号
public
bool
IsSerialNumber
{
get
;
set
;
}
// 是否为流水号
public
string
SerialExample
{
get
;
set
;
}
// 流水号示例
public
bool
IsEditing
{
get
;
set
;
}
// 新增编辑状态属性
}
private
readonly
List
<
string
>
keyCopy
;
private
readonly
List
<
string
>
keyCopyValue
;
...
...
@@ -305,16 +306,65 @@ namespace SmartScan.SetControl.WPF
}
};
Grid
.
SetColumn
(
numberBorder
,
0
);
StackPanel
contentPanel
=
new
StackPanel
{
Orientation
=
System
.
Windows
.
Controls
.
Orientation
.
Horizontal
};
// 关键词文本 - 这里已经支持显示流水号预览格式
System
.
Windows
.
Controls
.
TextBlock
keywordText
=
new
System
.
Windows
.
Controls
.
TextBlock
{
Text
=
keyword
.
DisplayText
??
keyword
.
Text
,
Visibility
=
keyword
.
IsEditing
?
Visibility
.
Collapsed
:
Visibility
.
Visible
,
Foreground
=
Brushes
.
White
,
VerticalAlignment
=
VerticalAlignment
.
Center
,
Margin
=
new
Thickness
(
10
,
0
,
0
,
0
),
FontSize
=
14
,
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
);
// 上移按钮
Button
upButton
=
new
Button
...
...
@@ -351,11 +401,14 @@ namespace SmartScan.SetControl.WPF
Grid
.
SetColumn
(
removeButton
,
4
);
// 添加所有元素到网格
itemGrid
.
Children
.
Add
(
numberBorder
);
itemGrid
.
Children
.
Add
(
keywordText
);
//
itemGrid.Children.Add(keywordText);
itemGrid
.
Children
.
Add
(
upButton
);
itemGrid
.
Children
.
Add
(
downButton
);
itemGrid
.
Children
.
Add
(
removeButton
);
// 将网格添加到面板
Grid
.
SetColumn
(
contentPanel
,
1
);
itemGrid
.
Children
.
Add
(
contentPanel
);
SelectedKeywordsPanel
.
Children
.
Add
(
itemGrid
);
}
// 更新预览
...
...
@@ -940,5 +993,8 @@ namespace SmartScan.SetControl.WPF
string
keywordsStr
=
string
.
Join
(
","
,
keywords
);
BLLCommon
.
config
.
CharacterTypeKeywords
=
keywordsStr
;
}
}
}
SmartScan/SetControl/WPF/UserControl2.xaml
0 → 100644
查看文件 @
27ad3e7
<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>
SmartScan/SetControl/WPF/UserControl2.xaml.cs
0 → 100644
查看文件 @
27ad3e7
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
);
}
}
}
SmartScan/SetControl/WPF/UsrPrintTemplateleft.xaml.cs
查看文件 @
27ad3e7
...
...
@@ -44,7 +44,14 @@ namespace SmartScan.SetControl.WPF
public
UsrPrintTemplateleft
()
{
InitializeComponent
();
if
(
LstLabel
.
SelectedIndex
>=
0
)
{
LabelSelectionChanged
?.
Invoke
(
this
,
new
LabelSelectionEventArgs
{
SelectedIndex
=
0
,
SelectedItem
=
LstLabel
.
SelectedItem
.
ToString
()
});
}
}
// 清空标签列表
public
void
ClearLabelList
()
...
...
@@ -53,6 +60,7 @@ namespace SmartScan.SetControl.WPF
}
private
void
LstLabel_SelectedIndexChanged
(
object
sender
,
SelectionChangedEventArgs
e
)
{
if
(
LstLabel
.
SelectedIndex
==
-
1
)
return
;
if
(
LstLabel
.
SelectedIndex
>=
0
)
{
LabelSelectionChanged
?.
Invoke
(
this
,
new
LabelSelectionEventArgs
...
...
@@ -61,6 +69,8 @@ namespace SmartScan.SetControl.WPF
SelectedItem
=
LstLabel
.
SelectedItem
.
ToString
()
});
}
// 重置选中状态
LstLabel
.
SelectedIndex
=
-
1
;
}
private
readonly
SizeF
LABEL_ADD_DEFAULT
=
new
(
50
,
60
);
...
...
SmartScan/SetControl/WPF/VerticalMenuControl.xaml
查看文件 @
27ad3e7
...
...
@@ -128,7 +128,7 @@
</Button.Tag>
</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>
<Image Source="/Resources/AI.png" Width="18" Height="18" />
</Button.Tag>
...
...
SmartScan/SetControl/WPF/WPF_CodeExtract.xaml
查看文件 @
27ad3e7
...
...
@@ -477,7 +477,7 @@
</Grid>
</Border>
<Grid Grid.Row="1">
<
Frame x:Name="aa"></Frame
>
<
ContentControl x:Name="aa"></ContentControl
>
</Grid>
</Grid>
...
...
SmartScan/SetControl/WPF/WPF_CodeExtract.xaml.cs
查看文件 @
27ad3e7
...
...
@@ -382,6 +382,7 @@ namespace SmartScan.SetControl.WPF
{
if
(
userControls
.
TryGetValue
(
clickedButton
,
out
UserControl1
userControl
))
{
//aa.NavigationService?.RemoveBackEntry();
// 清空Frame内容
aa
.
Content
=
null
;
...
...
SmartScan/SetControl/WPF/WPF_Date_From.xaml
查看文件 @
27ad3e7
...
...
@@ -463,7 +463,7 @@
<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_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"/>
...
...
SmartScan/SmartScan.csproj
查看文件 @
27ad3e7
...
...
@@ -252,6 +252,9 @@
<Compile Include="SetControl\WPF\UserControl1.xaml.cs">
<DependentUpon>UserControl1.xaml</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\UserControl2.xaml.cs">
<DependentUpon>UserControl2.xaml</DependentUpon>
</Compile>
<Compile Include="SetControl\WPF\UsrPrintTemplatebottom.xaml.cs">
<DependentUpon>UsrPrintTemplatebottom.xaml</DependentUpon>
</Compile>
...
...
@@ -598,6 +601,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SetControl\WPF\UserControl2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SetControl\WPF\UsrPrintTemplatebottom.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论