BF2Statistics.MainForm.ModSelectList_SelectedIndexChanged C# (CSharp) Method

ModSelectList_SelectedIndexChanged() private method

Event fired when the selected mod changes. When fired, this method fills in the "Next Map to be Played" area of the GUI.
private ModSelectList_SelectedIndexChanged ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void ModSelectList_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Reset form texts
            FirstMapBox.Text = MapModeBox.Text = MapSizeBox.Text = "";

            // Set our new selected mod variable
            SelectedMod = ModSelectList.SelectedItem as BF2Mod;

            // Grab the first map to be played from the maplist.con
            MapListEntry Entry = SelectedMod.MapList.Entries.FirstOrDefault();

            // Make sure we dont have an empty MapList file, or a bad Map Name
            if (Entry != default(MapListEntry) && !String.IsNullOrWhiteSpace(Entry.MapName))
            {
                // Fill the Map Name field
                try
                {
                    // Try and load the map descriptor file, so we can fetch the real name of the map
                    FirstMapBox.Text = SelectedMod.LoadMap(Entry.MapName).Title;
                }
                catch
                {
                    // If we cant load the map, lets parse the name the best we can
                    //
                    // First, convert mapname into an array, splitting by the underscore
                    string[] Parts = Entry.MapName.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);

                    // Rebuild the map name into a string, uppercasing the first letter of each word
                    StringBuilder MapParts = new StringBuilder();
                    foreach (string value in Parts)
                        MapParts.AppendFormat("{0} ", value.UppercaseFirst());

                    // Set map name
                    FirstMapBox.Text = MapParts.ToString().TrimEnd();
                }

                // Convert gametype
                MapModeBox.Text = BF2Server.GetGametypeString(Entry.GameMode);

                // Set mapsize
                MapSizeBox.Text = Entry.MapSize.ToString();
            }
        }
MainForm