Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
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
潘栩锋
Thick-Common
Commits
a440b345
Commit
a440b345
authored
Apr 10, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改进 RatioConverter 支持double输入
parent
01ee45d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
23 deletions
+30
-23
RatioConverter.cs
....Thick.Base/FLY.Thick.Base.UI/Converter/RatioConverter.cs
+30
-23
No files found.
Project.FLY.Thick.Base/FLY.Thick.Base.UI/Converter/RatioConverter.cs
View file @
a440b345
...
...
@@ -9,35 +9,42 @@ namespace FLY.Thick.Base.UI.Converter
public
class
RatioConverter
:
IMultiValueConverter
{
#
region
IMultiValueConverter
成员
public
object
Convert
(
object
[]
values
,
Type
targetType
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
double
getValue
(
object
value
)
{
if
(
values
.
Length
==
3
&&
(
values
[
0
]
is
int
)
&&
(
values
[
1
]
is
int
)
&&
(
values
[
2
]
is
double
))
//必须要检查,不然 界面生成器 会错误,提示转换异常
if
((
value
is
int
)
&&
(!
Misc
.
MyBase
.
ISVALIDATA
((
int
)
value
)))
return
0
;
try
{
double
ratio
;
int
value
=
(
int
)
values
[
0
];
if
(
value
==
99999998
)
value
=
0
;
int
max
=
(
int
)
values
[
1
];
double
ActualWidth
=
(
double
)
values
[
2
];
if
(
max
<=
0
)
ratio
=
0
;
else
ratio
=
(
double
)
value
/
max
;
if
(
ratio
<
0
)
ratio
=
0
;
else
if
(
ratio
>
1
)
ratio
=
1
;
return
ActualWidth
*
ratio
;
return
System
.
Convert
.
ToDouble
(
value
);
}
else
catch
{
return
0
;
}
}
public
object
Convert
(
object
[]
values
,
Type
targetType
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
{
if
(
values
.
Length
!=
3
)
//必须要检查,不然 界面生成器 会错误,提示转换异常
{
return
100
;
}
double
ratio
;
double
value
=
getValue
(
values
[
0
]);
double
max
=
getValue
(
values
[
1
]);
double
ActualWidth
=
getValue
(
values
[
2
]);
if
(
max
<=
0
)
ratio
=
0
;
else
ratio
=
(
double
)
value
/
max
;
if
(
ratio
<
0
)
ratio
=
0
;
else
if
(
ratio
>
1
)
ratio
=
1
;
return
ActualWidth
*
ratio
;
}
public
object
[]
ConvertBack
(
object
value
,
Type
[]
targetTypes
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
...
...
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