CEngineSharp_Editor.MapEditor.removeMapButton_Click C# (CSharp) Method

removeMapButton_Click() private method

private removeMapButton_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void removeMapButton_Click(object sender, EventArgs e)
        {
            int index = this.mapList.SelectedIndex;

            File.Delete(AppDomain.CurrentDomain.BaseDirectory + "/Data/Maps/" + this.mapEditorProperties.CurrentMap.Name + ".map");
            this.maps.RemoveAt(index);

            if (this.maps.Count == 0)
            {
                this.maps.Add(new Map());
                this.mapEditorProperties.CurrentMap = this.maps[0];
                this.mapEditorProperties.CurrentMap.Name = "Untitled";
                this.mapEditorProperties.CurrentMap.ResizeMap(25, 25);

                this.RefreshMapList();

                this.mapList.SelectedIndex = 0;
            }
            else
            {
                this.mapEditorProperties.CurrentMap = this.maps[index - 1];

                this.RefreshMapList();

                this.mapList.SelectedIndex = index - 1;
            }
        }