/// <summary>
        /// Starts the selected level
        /// </summary>
        /// <param name="sender">not used</param>
        /// <param name="e">not used</param>
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            int index = (int)cursor.Margin.Top / 20;

            if (campaign && index == 2)
            {
                EndlessMode endlessMode = new EndlessMode();
                endlessMode.Owner = this;
                Hide();
                try
                {
                    endlessMode.ShowDialog();
                }
                catch (Exception)
                {
                    endlessMode.Close();
                    MessageBox.Show("Game data has been modified during play.\nAn error has occurred due to this.\nThe level was aborted.");
                }
                Show();
                return;
            }

            Boolean goodMap = false;
            BasicLevel level = new BasicLevel();

            // Load the map
            if (campaign)
                goodMap = level.LoadCampaign(mapNames[index]);
            else
                goodMap = level.Load(mapNames[index]);

            // If successful, play the map
            if (goodMap)
            {
                Game game = new Game(level);
                game.Owner = this;
                Hide();
                try
                {
                    game.ShowDialog();
                }
                catch (Exception)
                {
                    game.Close();
                    MessageBox.Show("Game data has been modified during play.\nAn error has occurred due to this.\nThe level was aborted.");
                }
                Show();
                return;
            }

            // Remove the map due to not being valid
            grid1.Children.RemoveAt(index + 1);
            for (int i = index + 1; i < grid1.Children.Count; ++i)
            {
                Label l = grid1.Children[i] as Label;
                l.Margin = new Thickness(l.Margin.Left, l.Margin.Top - 20, 0, 0);
            }
            if (grid1.Children.Count == 1)
            {
                MessageBox.Show("There are no more maps available");
                Close();
            }
            else if (index == grid1.Children.Count - 1)
            {
                cursor.Margin = new Thickness(8, 20 * index - 16, 0, 0);
            }
        }
        /// <summary>
        /// Shows the details of a map
        /// </summary>
        /// <param name="sender">not used</param>
        /// <param name="e">not used</param>
        private void detailButton_Click(object sender, RoutedEventArgs e)
        {
            int index = (int)cursor.Margin.Top / 20;
            BasicLevel level = new BasicLevel();

            bool goodMap;

            // Load the map
            if (campaign)
                goodMap = level.LoadCampaign(mapNames[index]);
            else
                goodMap = level.Load(mapNames[index]);

            if (goodMap)
            {
                MapDetails detailMenu = new MapDetails(level);
                detailMenu.Owner = this;
                Hide();
                detailMenu.ShowDialog();
                Show();
            }
        }