- Model has a state called location and the view needs to know
when this changes so it can update
it's display
Create a interface for the View called IMyScreen or something similar
Add a method UpdateLocation to the interface or something similar
Create a variable or property functions that are visible to the state of type IMyScreen AND to the view. Call it something like MyScreen
Have the View implement IMyScreen and put the code needed to update the View when the Location state changes in the UpdateLocation method.
In your initialization routine of the View have the View register itself as the current MyScreen.
Modify the code working with Location to fire MyScreen.UpdateLocation anytime it changes.
Ideally the View would create a Command object run it's execute method. THe execute method would pull in any parameters it needed, modify the locaction, and then call MyScreen.UpdateLocation. But you should focus on changing one thing at a time and save that for later.
- View has a button that the model needs to know when it is clicked
This is a little vague. Generally buttons like this either do an action or indicate a status (check boxes, options, etc)
If it does an action then the ideal method is to create a ICommand Interface.
It has one method Execute.
Use the initialization routine to pass in any needed parameters.
Put the code that is needed to modify the model in the execute method.
When the button is click it would do something like
Sub MyButton_Click
ModifyCommand ThisCommand = New ModifyCommand(Parm1, Parm2, Parm3)
ModifyCommand.Execute
End Sub
If you need to query the status of the button then use the IMyScreen Interface and add a property called ButtonClicked.
When the button is clicked then set a flag that it has been clicked in the View
When the Model needs to know if the button has been clicked it called MyScreen.ButtonClicked.