-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBindingsManager.cls
120 lines (91 loc) · 4.32 KB
/
BindingsManager.cls
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "BindingsManager"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'@Folder "MVVM.Infrastructure.Binding"
Option Explicit
Private BindingColl As New Collection
'@Description "Binds a MSForms.Control property to a source property"
'Public Sub BindOneWayProperty(ByVal Control As MSForms.Control, ByVal ControlProperty As String, ByVal SourceProperty As String, ByVal Source As Object, Optional ByVal InvertBoolean As Boolean = False)
'
' Dim Binding As OneWayPropertyBinding
' Set Binding = New OneWayPropertyBinding
'
' Binding.Initialize Control, ControlProperty, Source, SourceProperty, InvertBoolean
'
' BindingColl.Add Binding
'
'End Sub
'@Description "Binds a MSForms.Control property to a source property"
Public Sub BindOneTimeProperty(ByVal Control As msForms.Control, ByVal ControlProperty As String, ByVal SourceProperty As String, ByVal Source As Object)
Dim Binding As OneTimePropertyBinding
Set Binding = New OneTimePropertyBinding
Binding.Initialize Control, ControlProperty, Source, SourceProperty
BindingColl.Add Binding
End Sub
''@Description "Binds a MSForms.Control property to a source property"
'Public Sub BindTwoWayProperty(ByVal Control As MSForms.Control, ByVal ControlProperty As String, ByVal SourceProperty As String, ByVal Source As Object, Optional ByVal InvertBoolean As Boolean = False)
'
' Dim Binding As TwoWayPropertyBinding
' Set Binding = New TwoWayPropertyBinding
'
' Binding.Initialize Control, ControlProperty, Source, SourceProperty, InvertBoolean
'
' 'Set BindTwoWayProperty = Binding
' BindingColl.Add Binding
'End Sub
'@Description "Binds the Text/Value of a MSForms.TextBox to a source property"
Public Sub BindTextBox(ByVal Control As msForms.Textbox, ByVal SourceProperty As String, ByVal Source As Object)
Dim Binding As TextBoxValueBinding
Set Binding = New TextBoxValueBinding
Binding.Initialize Control, Source, SourceProperty
'Set BindTextBox = Binding
BindingColl.Add Binding
End Sub
'@Description "Binds the Text of a MSForms.ComboBox to a String source property"
Public Sub BindComboBox(ByVal Control As msForms.ComboBox, ByVal SourceProperty As String, ByVal Source As Object)
Dim Binding As ComboBoxValueBinding
Set Binding = New ComboBoxValueBinding
Binding.Initialize Control, Source, SourceProperty
'Set BindComboBox = Binding
BindingColl.Add Binding
End Sub
'@Description "Binds the Value of a MSForms.CheckBox to a Boolean source property"
Public Sub BindCheckBox(ByVal Control As msForms.checkbox, ByVal SourceProperty As String, ByVal Source As Object)
Dim Binding As CheckBoxValueBinding
Set Binding = New CheckBoxValueBinding
Binding.Initialize Control, Source, SourceProperty
'Set BindCheckBox = Binding
BindingColl.Add Binding
End Sub
'@Description "Binds Command"
Public Sub BindCommand(ByVal ViewModel As Object, ByVal Control As msForms.CommandButton, ByVal Command As ICommand, _
Optional ByVal CanExecuteContext As Object, Optional ByVal ExecuteContext As Object)
Dim Binding As CommandBinding
Set Binding = New CommandBinding
Binding.Initialize ViewModel, Control, Command, CanExecuteContext, ExecuteContext
'Set BindCommand = Binding
BindingColl.Add Binding
End Sub
'@Description "Binds Label Command"
Public Sub BindImageCommand(ByVal ViewModel As Object, ByVal Control As msForms.Image, ByVal Command As ICommand, _
Optional ByVal CanExecuteContext As Object, Optional ByVal ExecuteContext As Object)
Dim Binding As ImageCommandBinding
Set Binding = New ImageCommandBinding
Binding.Initialize ViewModel, Control, Command, CanExecuteContext, ExecuteContext
'Set BindCommand = Binding
BindingColl.Add Binding
End Sub
'@Description "Binds the Value of a MSForms.Listbox to a Boolean source property"
Public Sub BindListBox(ByVal Control As msForms.listBox, ByVal SourceProperty As String, ByVal Source As Object)
Dim Binding As ListBoxListBinding
Set Binding = New ListBoxListBinding
Binding.Initialize Control, Source, SourceProperty
'Set BindCheckBox = Binding
BindingColl.Add Binding
End Sub