-
Notifications
You must be signed in to change notification settings - Fork 0
/
ValueConverter.vb
97 lines (76 loc) · 3.85 KB
/
ValueConverter.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#Region "绑定转换器"
Imports System.Globalization
Class valueplusoneConverter
Implements IValueConverter
'items index默认从0开始,该转化器将其+1
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
Return (Val(value) + 1).ToString()
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
End Class
Class volto100Converter
Implements IValueConverter
'将mediaplay音量从0.1转化为10
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
Return Math.Round(value * 100)
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New System.Exception("绑定发生错误!")
End Function
End Class
Class volbtntooltipConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
Return "当前音量:" + value.ToString + vbCrLf + "滑动滑轮调节音量"
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New System.Exception("绑定发生错误!")
End Function
End Class
Class volpathVisibility0Converter
Implements IValueConverter
'将mediaplay音量转化为音量图标的显示(当音量为0时,显示x)
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
If Val(value) = 0 Then
Return Visibility.Visible
Else
Return Visibility.Hidden
End If
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New System.Exception("绑定发生错误!")
End Function
End Class
Class volpathopactiy33Converter
Implements IValueConverter
'将mediaplay音量转化为音量图标的显示(|)
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
If Val(value) > 0 Then
Return Visibility.Visible
Else
Return Visibility.Hidden
End If
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New System.Exception("绑定发生错误!")
End Function
End Class
Class listboxitemcontextmenu
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
If value Is Nothing Then Return Nothing
Dim tempmusic As Music = value
Dim musicname As String = tempmusic.MusicTitle
If musicname.Length >= 20 Then
musicname = Left(musicname, 17) + "..."
End If
Return "播放 " + musicname
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New Exception("listboxitemcontextmenu ConvertBack 粗错了!")
End Function
End Class
#End Region