Time for action – creating the menu bar
Double-click on the
MapEditor.cs
file in Solution Explorer to open the MapEditor form in the design window.Click on the empty MenuStrip you previously added to the form, and add menu entries for the following items:
&File
&Load Map
&Save Map
– (A single dash, creating a separator line)
E&xit
&Tools
&Clear Map
&Layer
&Background
&Interactive
&Foreground
Double-click on the Exit item under the File menu to have C# automatically generate an event handler for the Exit menu item.
Enter the following code into the
exitToolStripMenuItem_Click()
event handler:game.Exit(); Application.Exit();
What just happened?
We now have a standard Windows menu attached to our form with a few entries for our level editor. In order to add code to menu items other than the Exit command, we need to make modifications to our Game1 class, so we will come back to them after we have laid out all of the items on our display.
Tip
What are all those ampersands...