-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwitchUFValueCommand.cls
69 lines (60 loc) · 2.02 KB
/
SwitchUFValueCommand.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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "SwitchUFValueCommand"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'@Folder Userform.Command
'@ModuleDescription "A command that switch the userform values between 'default' and 'last saved input'."
Option Explicit
Implements ICommand
Private mViewModel As Object
'Private mButton As MSforms.CommandButton
'@Description "Creates a new instance of this command."
Public Function Create(ByVal ViewModel As Object) As ICommand
Dim result As SwitchUFValueCommand
Set result = New SwitchUFValueCommand
Set result.ViewModel = ViewModel
Set Create = result
result.ViewModel.RegisterCommand result
End Function
Public Property Get ViewModel() As Object
Set ViewModel = mViewModel
End Property
Public Property Set ViewModel(ByVal rhs As Object)
Set mViewModel = rhs
End Property
'Public Property Get Button() As Object
' Set Button = mButton
'End Property
'
'Public Property Set Button(ByVal RHS As Object)
' Set mButton = RHS
'End Property
Private Function ICommand_CanExecute(ByVal Context As Object) As Boolean
'If mViewModel.isLoadDefault Then
ICommand_CanExecute = True
'End If
End Function
Private Property Get ICommand_Description() As String
ICommand_Description = "SwitchUFValue."
End Property
Private Sub ICommand_Execute(ByVal Context As Object)
Dim CommandBtn As msForms.CommandButton
'Set CommandBtn = Me.Button
Const LoadDefaultText As String = "Load Default"
Const LoadLastSave As String = "Load Last Save"
If TypeOf Context Is msForms.CommandButton Then
Set CommandBtn = Context
If CommandBtn.caption = LoadDefaultText Then
Me.ViewModel.LoadDefaultVal
CommandBtn.caption = LoadLastSave
ElseIf CommandBtn.caption = LoadLastSave Then
Me.ViewModel.LoadLastSaveVal
CommandBtn.caption = LoadDefaultText
End If
End If
End Sub