Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hemei
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
hemei
Commits
7cc119ae
Commit
7cc119ae
authored
May 28, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 称重加载 weighter.weightSystemClient.json 出错时, 没有画面
修复 称重每次开机 都重写 weighter.weightSystemClient.json
parent
fbbe03aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
+31
-5
WeightSystemServiceClient.cs
...FLY.Weight/FLY.Weight/Client/WeightSystemServiceClient.cs
+31
-5
No files found.
Project.FLY.Weight/FLY.Weight/Client/WeightSystemServiceClient.cs
View file @
7cc119ae
...
...
@@ -126,25 +126,51 @@ namespace FLY.Weight.Client
void
Load
()
{
if
(!
File
.
Exists
(
filePath
))
return
;
string
json
=
File
.
ReadAllText
(
filePath
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
WeightSystemClientJsonDb
>(
json
);
BinCnts
=
p
.
BinCnts
;
try
{
string
json
=
File
.
ReadAllText
(
filePath
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
WeightSystemClientJsonDb
>(
json
);
BinCnts
=
p
.
BinCnts
;
}
catch
{
//失败就算了。。。
}
}
private
void
WeightSystemClient_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
(
e
.
PropertyName
==
"BinCnts"
)
{
ResetItems
();
Save
();
if
(
IsBinCntsChanged
())
{
ResetItems
();
Save
();
}
}
}
bool
IsBinCntsChanged
()
{
var
binCnts
=
Items
.
Select
(
i
=>
i
.
BinCnt
).
ToArray
();
if
(
binCnts
.
Count
()
!=
BinCnts
.
Count
())
return
true
;
else
{
for
(
int
i
=
0
;
i
<
binCnts
.
Count
();
i
++)
if
(
binCnts
[
i
]
!=
BinCnts
[
i
])
{
return
true
;
}
}
return
false
;
}
/// <summary>
/// 重新创建 Items
/// </summary>
void
ResetItems
()
{
int
last_itemcnt
=
Items
.
Count
();
for
(
int
i
=
0
;
i
<
Items
.
Count
();
i
++)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment