XCase is based on Model-View-Controller (MVC) architecture.
- Model stores all the data managed by XCase and raises events when the data is changed (which can be done only through
Controllers or loading data from a file)
- View binds to Model's events and displays the current state in GUI. This binding is unilateral, View cannot directly access/change the model.
- Controllers provide methods for changing the model, which can be used by view and GUI (when processing user input), but doesn't change the View directly.
Example - Rename a Class
- User clicks on the Rename context menu item of a Class, types in a new name and presses Enter
- View checks whether the new name is different from the old one. If it is, it replaces the new name with the old one (because the new name will be set here in a different way and we want to see if everything works OK)
- View calls the Controller with the rename request
- Controller creates a Rename command, initializes it with the Model class and executes it
- The Rename command sets the Name property of the Model class and stores the old name for Undo
- The Model class detects the change to its Name property and invokes the PropertyChanged event
- The View representation of this class receives an update via
Binding and updates the text box containing the class name.