Original Post
Hey, i was wondering if what i'm doing is close to a MVC Pattern. I have the following classes: Model: Game.cs; in this main form the game itself is rendered + the extra GUI elements like Inventory.cs, CharacterStats.cs etc. Control: GUIHanlder.cs; This handles the GUI elements. Like if a button is pressed in CharacterStats.cs, then it gets handled in GUIHandler.cs Views: [i/These are the GUI files (User Controls) that can be Shown (Show()) or Hidden (Hide()) on the main form Game.cs Inventory.cs CharacterStats.cs Skills.cs My Question: ------------ Now what i want to know is, how to implement it properly. Should Game.cs pass an instance of itself to GUIHandler.cs? And should GUIHandler.cs create an instance to all the GUI elements? So i could do the following: (some pseudo code)
Game.cs:
GUIHandler GUI = new GUIHandler();
GUI.ShowCharacterStats();
---------------------------------------------
GUIHanlder.cs
Game game;
//.ctor
GUIHandler(Game game)
{
this.game = game;
CharacterStats cStats = new CharacterStats();
cStats = new Point(200,300);
game.Controls.Add(cStats);
//Same goes for all the other View classes!!
Iventory invent = new CharacterStats();
invent = new Point(200,300);
...etc
...etc
}
public void ShowInventory()
{
invent.Show();
}
pulbic void btCharStats_CraftStats()
{
//Code to update the View to display the users current Crafting status.
}
Or is better that Game.cs creates an instance to the Views it needs instead of doing that in GUIHandler? So that i just keep GUIHanlder for the button presses that occure on the forms of the Views?