Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
SO827-AutoScanAndLabel
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit cde4adc1
由
刘韬
编写于
2022-07-21 13:50:19 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
3f9c25d0
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
400 行增加
和
4 行删除
AutoScanAndLabel/AboutBox1.cs
AutoScanAndLabel/Form1.cs
AutoScanAndLabel/UC/ListEditControl.cs
Common/CodeResourceControl.cs
Common/Common.csproj
Dingtalk_20210218104106.jpg
AutoScanAndLabel/AboutBox1.cs
查看文件 @
cde4adc
...
@@ -123,7 +123,7 @@ namespace AutoScanAndLabel
...
@@ -123,7 +123,7 @@ namespace AutoScanAndLabel
private
void
labelVersion_Click
(
object
sender
,
EventArgs
e
)
private
void
labelVersion_Click
(
object
sender
,
EventArgs
e
)
{
{
ConfigHelper
.
AdvanceConfigForm
.
ShowEditDialog
();
ConfigHelper
.
AdvanceConfigForm
.
ShowEditDialog
(
this
);
}
}
}
}
}
}
AutoScanAndLabel/Form1.cs
查看文件 @
cde4adc
...
@@ -343,7 +343,7 @@ namespace AutoScanAndLabel
...
@@ -343,7 +343,7 @@ namespace AutoScanAndLabel
{
{
Invoke
((
EventHandler
)
delegate
Invoke
((
EventHandler
)
delegate
{
{
btn_releaseleftshelf
.
Text
=
$
"左侧料串等待释放中({timeout / 2})"
;
btn_releaseleftshelf
.
Text
=
string
.
Format
(
"左侧料串等待释放中({0})"
,
timeout
/
2
)
;
});
});
}
}
if
((
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
==
MoveStep
.
L20_WaitLabel
||
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
==
MoveStep
.
L10_WaitReelPut
)
&&
(
RobotManage
.
mainMachine
.
RightMoveInfo
.
MoveStep
==
MoveStep
.
Wait
||
RobotManage
.
mainMachine
.
RightMoveInfo
.
MoveStep
==
MoveStep
.
REND
))
if
((
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
==
MoveStep
.
L20_WaitLabel
||
RobotManage
.
mainMachine
.
LeftMoveInfo
.
MoveStep
==
MoveStep
.
L10_WaitReelPut
)
&&
(
RobotManage
.
mainMachine
.
RightMoveInfo
.
MoveStep
==
MoveStep
.
Wait
||
RobotManage
.
mainMachine
.
RightMoveInfo
.
MoveStep
==
MoveStep
.
REND
))
...
@@ -389,7 +389,7 @@ namespace AutoScanAndLabel
...
@@ -389,7 +389,7 @@ namespace AutoScanAndLabel
{
{
Invoke
((
EventHandler
)
delegate
Invoke
((
EventHandler
)
delegate
{
{
btn_releaserightshelf
.
Text
=
$
"右侧料串等待释放中({timeout / 2})"
;
btn_releaserightshelf
.
Text
=
string
.
Format
(
"右侧料串等待释放中({0})"
,
timeout
/
2
)
;
});
});
}
}
}
}
...
...
AutoScanAndLabel/UC/ListEditControl.cs
查看文件 @
cde4adc
...
@@ -60,7 +60,7 @@ namespace AutoScanAndLabel.UC
...
@@ -60,7 +60,7 @@ namespace AutoScanAndLabel.UC
{
{
if
(
listBox1
.
SelectedIndex
<
0
)
if
(
listBox1
.
SelectedIndex
<
0
)
return
;
return
;
var
rl
=
MessageBox
.
Show
(
$
"确定要删除:\"{listBox1.SelectedItem}\"?"
,
"警告"
,
MessageBoxButtons
.
YesNo
);
var
rl
=
MessageBox
.
Show
(
string
.
Format
(
"确定要删除:\"{0}\"?"
,
listBox1
.
SelectedItem
)
,
"警告"
,
MessageBoxButtons
.
YesNo
);
if
(
rl
!=
DialogResult
.
Yes
)
if
(
rl
!=
DialogResult
.
Yes
)
return
;
return
;
if
(
listBox1
.
SelectedIndex
==
editindex
)
if
(
listBox1
.
SelectedIndex
==
editindex
)
...
...
Common/CodeResourceControl.cs
0 → 100644
查看文件 @
cde4adc
using
log4net
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
System.Windows.Forms.Layout
;
namespace
OnlineStore
{
public
class
crc
:
CodeResourceControl
{
}
public
class
CodeResourceControl
{
public
static
readonly
ILog
LOG
=
LogManager
.
GetLogger
(
"LngResource"
);
public
static
bool
OpenResourceLog
=
false
;
public
static
string
China
=
"zh-CN"
;
private
static
Dictionary
<
string
,
Dictionary
<
string
,
string
>>
LangMap
=
new
Dictionary
<
string
,
Dictionary
<
string
,
string
>>();
public
delegate
string
GetLanguageDelegate
();
public
static
event
GetLanguageDelegate
GetLanguageEvent
;
public
delegate
void
RefreshLanguageDelegate
();
public
static
event
RefreshLanguageDelegate
RefreshLanguageEvent
;
public
static
event
EventHandler
LanguageChangeEvent
;
static
CodeResourceControl
()
{
LoadData
();
var
lngjson
=
JsonHelper
.
SerializeObject
(
LangMap
);
Task
.
Run
(()
=>
{
//return;
try
{
Task
.
Delay
(
10
*
1000
).
Wait
();
if
(
SMF
.
UploadLangJsonData
(
lngjson
,
out
SmfResult
smfResult
))
{
LogUtil
.
info
(
"语言资源上传成功"
);
}
else
{
LogUtil
.
info
(
"语言资源上传失败"
);
}
var
lngdatas
=
SMF
.
DownloadLngData
();
foreach
(
var
lngdata
in
lngdatas
)
{
var
datalines
=
lngdata
.
resourceMap
.
ToList
().
Select
((
kv
)
=>
{
return
kv
.
Key
+
"\t\t"
+
kv
.
Value
;
}).
ToArray
();
string
lngfilename
=
"server\\"
+
lngdata
.
lanCode
+
".lngres"
;
Directory
.
CreateDirectory
(
Path
.
Combine
(
rPath
,
"server"
));
File
.
WriteAllLines
(
Path
.
Combine
(
rPath
,
lngfilename
),
datalines
);
}
LoadData
(
true
);
//SetCurrentCulture(CurrLanguage);
//LanguageChangeEvent?.Invoke(null, EventArgs.Empty);
}
catch
(
Exception
e
)
{
LogUtil
.
info
(
"语言资源处理出错:"
+
e
.
ToString
());
}
});
LoadData
(
true
);
}
private
static
char
spilt
=
'\t'
;
private
static
string
rPath
=
Application
.
StartupPath
+
@"\resources\"
;
private
static
void
LoadData
(
bool
loadserverdir
=
false
)
{
string
loadpath
=
rPath
;
if
(
loadserverdir
)
loadpath
=
Path
.
Combine
(
rPath
,
"server"
);
Directory
.
CreateDirectory
(
loadpath
);
string
[]
lngresfiles
=
Directory
.
GetFiles
(
loadpath
,
"*.lngres"
);
foreach
(
var
lngresfile
in
lngresfiles
)
{
Dictionary
<
string
,
string
>
lngMap
;
var
lngname
=
Path
.
GetFileNameWithoutExtension
(
lngresfile
);
if
(!
LangMap
.
ContainsKey
(
lngname
))
{
LangMap
.
Add
(
lngname
,
new
Dictionary
<
string
,
string
>());
}
lngMap
=
LangMap
[
lngname
];
string
[]
lines
=
File
.
ReadAllLines
(
lngresfile
);
foreach
(
string
line
in
lines
)
{
if
(
string
.
IsNullOrEmpty
(
line
))
continue
;
string
[]
array
=
line
.
Split
(
spilt
);
if
(
array
.
Length
>=
3
)
{
string
key
=
array
[
0
].
Trim
();
string
value
=
array
[
2
];
if
(
lngMap
.
ContainsKey
(
key
))
lngMap
[
key
]
=
value
;
else
lngMap
.
Add
(
key
,
value
);
}
}
}
}
static
Dictionary
<
string
,
string
>
LangName
=
new
Dictionary
<
string
,
string
>()
{
{
"zh-CN"
,
"简体中文"
},
{
"zh-TW"
,
"繁體中文"
},
{
"en-US"
,
"English"
},
{
"ja-JP"
,
"日本語"
},
{
"fr-FR"
,
"Français"
},
{
"de-DE"
,
"Deutsche"
},
};
public
static
Dictionary
<
string
,
string
>
GetLangList
()
{
Dictionary
<
string
,
string
>
LangList
=
new
Dictionary
<
string
,
string
>();
foreach
(
var
v
in
LangName
)
{
if
(
LangMap
.
ContainsKey
(
v
.
Key
))
{
if
(!
LangList
.
ContainsKey
(
v
.
Key
))
LangList
.
Add
(
v
.
Key
,
v
.
Value
);
}
}
return
LangList
;
}
public
static
void
LanguageChange
()
{
LanguageChangeEvent
?.
Invoke
(
null
,
EventArgs
.
Empty
);
}
public
static
string
GetLanguage
()
{
if
(
GetLanguageEvent
==
null
)
{
return
China
;
}
string
result
=
GetLanguageEvent
?.
Invoke
();
if
(
result
==
null
)
{
return
""
;
}
return
result
;
}
private
static
string
spiltStr
=
"_"
;
private
static
string
Text
=
"Text"
;
public
static
string
GetTextIdStr
(
string
class
Name
,
string
controlName
)
{
return
class
Name
+
spiltStr
+
controlName
+
spiltStr
+
Text
;
}
public
static
string
GetString
(
object
id
,
string
defaultStr
)
{
return
GetString
(
id
.
ToString
(),
defaultStr
);
}
public
static
string
GetString
(
string
id
,
string
defaultStr
)
{
string
strCurLanguage
=
defaultStr
;
var
haslang
=
getLangRes
(
CurrLanguage
);
if
(!
haslang
)
{
return
strCurLanguage
;
}
try
{
LangMap
[
CurrLanguage
].
TryGetValue
(
id
,
out
strCurLanguage
);
if
((
strCurLanguage
==
null
||
strCurLanguage
.
Equals
(
""
))
&&
(!
defaultStr
.
Equals
(
""
)))
{
strCurLanguage
=
defaultStr
;
NoIdLog
(
id
,
defaultStr
);
}
}
catch
(
Exception
ex
)
{
if
(
defaultStr
.
Equals
(
""
))
{
}
else
{
strCurLanguage
=
"No id:["
+
id
+
"], please add."
;
strCurLanguage
=
defaultStr
;
NoIdLog
(
id
,
defaultStr
);
}
}
if
(
strCurLanguage
==
null
)
{
strCurLanguage
=
""
;
}
return
strCurLanguage
;
}
public
static
string
GetString
(
string
id
,
string
defaultStr
,
params
object
[]
param
)
{
string
strCurLanguage
=
GetString
(
id
,
defaultStr
);
return
String
.
Format
(
strCurLanguage
,
param
);
}
static
HashSet
<
string
>
hss
=
new
HashSet
<
string
>();
private
static
void
NoIdLog
(
string
id
,
string
defaultStr
)
{
if
(
OpenResourceLog
)
{
getLangRes
(
"zh-CN"
);
if
(!
LangMap
[
"zh-CN"
].
ContainsKey
(
id
)
&&
checkInterid
(
id
)
&&
!
hss
.
Contains
(
id
))
{
hss
.
Add
(
id
);
LOG
.
Info
(
""
+
id
+
"\t"
+
defaultStr
);
}
}
}
private
static
bool
checkInterid
(
string
id
)
{
return
true
;
string
[]
interstring
=
new
string
[]
{
"_txt"
,
"_lbl"
};
var
x
=
from
a
in
interstring
where
id
.
IndexOf
(
a
)
>
-
1
select
a
;
return
x
.
Count
()
==
0
;
}
private
static
bool
getLangRes
(
string
lang
)
{
if
(!
LangMap
.
ContainsKey
(
lang
))
{
string
path
=
Application
.
StartupPath
+
@"\resources\"+lang+ "
.
lngres
";
if
(!
File
.
Exists
(
path
))
{
return
false
;
}
string
[]
lines
=
File
.
ReadAllLines
(
path
);
var
map
=
new
Dictionary
<
string
,
string
>();
foreach
(
string
line
in
lines
)
{
string
[]
array
=
line
.
Split
(
'\t'
);
if
(
array
.
Length
>=
3
)
{
string
key
=
array
[
0
];
string
chinese
=
array
[
1
];
string
english
=
array
[
2
];
if
(
map
.
ContainsKey
(
key
))
{
map
.
Remove
(
key
);
}
map
.
Add
(
key
,
english
);
}
}
LangMap
.
Add
(
lang
,
map
);
return
true
;
}
return
true
;
}
public
static
string
CurrLanguage
=
""
;
public
static
void
LanguageProcess
(
ContainerControl
cc
,
string
class
Name
=
""
)
{
if
(
string
.
IsNullOrEmpty
(
class
Name
))
class
Name
=
cc
.
GetType
().
Name
;
if
(
CurrLanguage
.
Equals
(
CodeResourceControl
.
GetLanguage
()))
{
//return;
}
//string className = cc.ClassName;
CurrLanguage
=
CodeResourceControl
.
GetLanguage
();
//string name = CodeResourceControl.GetString(CodeResourceControl.GetTextIdStr(className), cc.Text);
//if (!name.Equals("")) { cc.Text = name; }
PreControlLanaguage
(
cc
,
class
Name
);
RefreshLanguageEvent
?.
Invoke
();
}
private
static
void
PreControlLanaguage
(
Control
partentControl
,
string
class
Name
)
{
string
newStr
=
""
;
//Con_GetTxt(partentControl, out string title);
//string newStr = GetString(GetTextIdStr(className, partentControl.Name), title);
//if (!newStr.Equals(""))
//{
//Con_SetTxt(partentControl, newStr.Replace("\\n", "\n"));
//}
foreach
(
Control
con
in
partentControl
.
Controls
)
{
string
txt
=
""
;
bool
haslang
=
false
;
if
(
con
.
Tag
!=
null
&&
con
.
Tag
.
ToString
()
==
"not"
)
{
continue
;
}
if
(
Con_GetTxt
(
con
,
out
txt
))
{
newStr
=
GetString
(
GetTextIdStr
(
class
Name
,
con
.
Name
),
txt
);
if
(!
newStr
.
Equals
(
""
))
{
Con_SetTxt
(
con
,
newStr
.
Replace
(
"\\n"
,
"\n"
));
//haslang = true;
}
}
if
(
con
.
Tag
!=
null
&&
con
.
Tag
.
ToString
()
==
"nochiled"
)
{
continue
;
}
if
(
con
.
Controls
.
Count
>
0
&&
!
haslang
)
{
PreControlLanaguage
(
con
,
class
Name
+
"_"
+
con
.
Name
);
}
//Console.WriteLine(con is IList<Component>);
//Console.WriteLine(con is IList<Component>);
}
}
public
static
void
ProcessListItem
<
T
>(
T
con
,
string
ClassName
)
where
T
:
ToolStripItemCollection
{
for
(
int
i
=
0
;
i
<
con
.
Count
;
i
++)
{
if
(
con
[
i
].
Tag
!=
null
&&
con
[
i
].
Tag
.
ToString
()
==
"not"
)
{
continue
;
}
string
txt
=
con
[
i
].
Text
;
string
newStr
=
GetString
(
GetTextIdStr
(
ClassName
,
con
[
i
].
Name
),
txt
);
if
(!
newStr
.
Equals
(
""
))
{
con
[
i
].
Text
=
newStr
.
Replace
(
"\\n"
,
"\n"
);
//haslang = true;
}
if
(
con
[
i
]
is
ToolStripMenuItem
)
{
var
tt
=
((
ToolStripMenuItem
)
con
[
i
]);
ProcessListItem
(
tt
.
DropDownItems
,
tt
.
Name
);
}
}
}
static
bool
Con_GetTxt
(
Control
con
,
out
string
txt
)
{
txt
=
""
;
if
(
con
is
Label
||
con
is
Button
||
con
is
RadioButton
||
con
is
CheckBox
)
{
txt
=
con
.
Text
;
return
true
;
}
string
methodname
=
getMethodname
(
con
);
var
t
=
con
.
GetType
();
var
p
=
t
.
GetProperty
(
methodname
);
if
(
p
!=
null
)
{
txt
=
p
.
GetValue
(
con
,
null
).
ToString
();
return
true
;
}
return
false
;
}
static
void
Con_SetTxt
(
Control
con
,
string
txt
)
{
if
(
con
is
Label
||
con
is
Button
||
con
is
RadioButton
||
con
is
CheckBox
)
{
con
.
Text
=
txt
;
return
;
}
string
methodname
=
getMethodname
(
con
);
var
t
=
con
.
GetType
();
var
p
=
t
.
GetProperty
(
methodname
);
if
(
p
==
null
)
return
;
else
p
.
SetValue
(
con
,
txt
,
null
);
}
static
string
getMethodname
(
Control
con
)
{
string
methodname
=
"Text"
;
//if (con is UCBtnExt) methodname = "BtnText";
//if (con is UCTextBoxEx) methodname = "InputText";
//if (con is UCCheckBox) methodname = "TextValue";
//if (con is UCPanelTitle || con is FrmWithTitle) methodname = "Title";
//if (con is Form) methodname = "Title";
return
methodname
;
}
}
}
Common/Common.csproj
查看文件 @
cde4adc
...
@@ -52,6 +52,7 @@
...
@@ -52,6 +52,7 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="bean\Bean.cs" />
<Compile Include="bean\Bean.cs" />
<Compile Include="CodeResourceControl.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Setting_Init.cs" />
<Compile Include="Setting_Init.cs" />
<Compile Include="util\ConfigAppSettings.cs" />
<Compile Include="util\ConfigAppSettings.cs" />
...
...
Dingtalk_20210218104106.jpg
0 → 100644
查看文件 @
cde4adc
131.4 KB
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论