Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Framework
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘龙飞
VIZ.Framework
Commits
12108025
Commit
12108025
authored
Mar 10, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加多值转化器
parent
22a4fb1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
VIZ.Framework.Core/Core/Converter/MultiBool2BoolConverter.cs
+76
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+1
-0
No files found.
VIZ.Framework.Core/Core/Converter/MultiBool2BoolConverter.cs
0 → 100644
View file @
12108025
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Data
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// 多Bool转化器
/// </summary>
public
class
MultiBool2BoolConverter
:
IMultiValueConverter
{
/// <summary>
/// 掩码True
/// </summary>
public
const
string
MASK_TRUE
=
"1"
;
/// <summary>
/// 掩码False
/// </summary>
public
const
string
MASK_FALSE
=
"0"
;
/// <summary>
/// 掩码
/// </summary>
/// <remarks>
/// 1 : true
/// 0 : false
/// 逗号或空格分割
/// 例如: 1,0,1
/// </remarks>
public
string
Mask
{
get
;
set
;
}
/// <summary>
/// 匹配返回
/// </summary>
public
bool
MatchResult
{
get
;
set
;
}
=
true
;
/// <summary>
/// 未匹配返回
/// </summary>
public
bool
NotMatchResult
{
get
;
set
;
}
=
false
;
public
object
Convert
(
object
[]
values
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(
values
==
null
)
return
this
.
NotMatchResult
;
string
[]
mask
=
this
.
Mask
.
Split
(
new
char
[]
{
','
,
' '
},
StringSplitOptions
.
RemoveEmptyEntries
);
if
(
values
.
Length
!=
mask
.
Length
)
return
this
.
NotMatchResult
;
for
(
int
i
=
0
;
i
<
mask
.
Length
;
i
++)
{
bool
?
b
=
values
[
i
]
as
bool
?;
bool
real
=
b
==
null
?
false
:
b
.
Value
;
string
m
=
mask
[
i
];
if
((
real
&&
m
==
MASK_TRUE
)
||
(!
real
&&
m
==
MASK_FALSE
))
continue
;
return
this
.
NotMatchResult
;
}
return
this
.
MatchResult
;
}
public
object
[]
ConvertBack
(
object
value
,
Type
[]
targetTypes
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
12108025
...
...
@@ -103,6 +103,7 @@
<Compile Include="Core\Converter\Bool2SolidColorBrushConverter.cs" />
<Compile Include="Core\Converter\Color2SolidColorBrushConverter.cs" />
<Compile Include="Core\Converter\Enum2EnumDescriptionConverter.cs" />
<Compile Include="Core\Converter\MultiBool2BoolConverter.cs" />
<Compile Include="Core\Converter\ObjectNotNull2BoolConverter.cs" />
<Compile Include="Core\Converter\String2ImageSourceConverter.cs" />
<Compile Include="Core\Converter\StringAppendConverter.cs" />
...
...
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