I am creating simple graphical game in WinForms and currently I want to display the menu when the game is displayed. My only problem is that I am not sure about the structure of my own, this is what I have done so far:
1) For a menu form and game form When the new game is selected, create a game form and dock it into the menu form - after the exit of the app, I can not settle the menu form or can I change the message form in different form? I suspect - 2) Enables me to build some main forms, so that I have to build and settle both the menu and the game form 3) Is there a completely different way?
In a way, I'm often using a container for ideas when developing applications
What you can do:
- Define two users (a view
UserControl
) , Which has a panel to add to the scene.Control, one for the menu, one for the logic of the game. The menu view can expose an event for each menu item that can be attached to the main form.
- When it is started, show the menu control when an event is applied to "play", then the main form should switch to the game view.
The following pseudo code will help you switch the view:
Private Zero SwitchView (panel container, user control newview) {if (container.style.exe & Gt; 0) {UserControl oldView = container.Controls [0] as UserControl; Container.Controls.Remove (0); OldView.Dispose (); } If (new view! = Null) {newView.Dock = Doc.fill; // Attach event if (new view is ...) {...} container. Control. Add (new view); Please note that this code may not be compiled properly, I am writing it with my head but it will give you a general idea that this can be done.
Comments
Post a Comment