Просмотр исходного кода

Switch to new playlist automatically

Kenneth van Ewijk 10 лет назад
Родитель
Сommit
9d56e2e3b4
1 измененных файлов с 11 добавлено и 3 удалено
  1. 11 3
      MusicPlayer/MusicPlayer/PlaylistMaker.cs

+ 11 - 3
MusicPlayer/MusicPlayer/PlaylistMaker.cs

@@ -38,12 +38,15 @@ namespace MusicPlayer
             }
         }
 
-        public void Repopulate()
+        public void Repopulate(bool lastIndex)
         {
             int selection = PlaylistSelectBox.SelectedIndex;
             PlaylistSelectBox.Items.Clear();      
             pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
-            PlaylistSelectBox.SelectedIndex = selection;
+            if (lastIndex)
+                PlaylistSelectBox.SelectedIndex = PlaylistSelectBox.Items.Count - 1;
+            else
+                PlaylistSelectBox.SelectedIndex = selection;
             if (PlaylistSelectBox.SelectedItem != null)
             {
                 PlaylistSongContainer.Items.Clear();
@@ -52,6 +55,11 @@ namespace MusicPlayer
             }
         }
 
+        public void Repopulate()
+        {
+            Repopulate(false);
+        }
+
         public void Populate()
         {
             pl.GetPlaylists().ForEach(p => PlaylistSelectBox.Items.Add(p.name));
@@ -91,7 +99,7 @@ namespace MusicPlayer
         private void PlaylistNewButton_Click(object sender, EventArgs e)
         {
             pl.MakeNewPlaylistByName(PlaylistNewInputfield.Text);
-            Repopulate();
+            Repopulate(true);
         }
 
         private void PlaylistMaker_Load(object sender, EventArgs e)