private void DownloadButtonClick(object sender, RoutedEventArgs e)
        {
            var dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            var songs     = MyTabControl.GetChildOfType <ListView>().SelectedItems.Cast <Song>();
            var songsList = songs as Song[] ?? songs.ToArray();

            if (!songsList.Any())
            {
                return;
            }
            _tokenSource           = new CancellationTokenSource();
            CancelButton.IsEnabled = true;
            if (songsList.Length == 1)
            {
                songsList.First().DownloadAudio(_tokenSource.Token, dialog.SelectedPath, this);
                return;
            }
            CancelButton.IsEnabled = true;
            Song.DownloadAudio(songsList, _tokenSource.Token, dialog.SelectedPath, this);
        }
        private void CopyButton_OnClick(object sender, RoutedEventArgs e)
        {
            SongTab sTab;
            ObservableCollection <Song> targetCollection;

            if (TabsComboBox.SelectedItem == null)
            {
                sTab = AddNewTab();
                if (sTab == null)
                {
                    return;
                }
                targetCollection = sTab.SongCollection;
            }
            else
            {
                sTab             = ((SongTab)TabsComboBox.SelectedItem);
                targetCollection = sTab.SongCollection;
            }
            var items = MyTabControl.GetChildOfType <ListView>().SelectedItems;

            foreach (var item in items)
            {
                targetCollection.Add((Song)((Song)item).Clone());
            }
            MyTabControl.SelectedItem = sTab;
        }
        private void DeleteButton_OnClick(object sender, RoutedEventArgs e)
        {
            var selectedSongs = MyTabControl.GetChildOfType <ListView>();

            if (selectedSongs.SelectedItems.Count < 0)
            {
                return;
            }
            var items = selectedSongs.SelectedItems;

            for (var i = 0; i < items.Count; i++)
            {
                ((Collection <Song>)selectedSongs.ItemsSource).Remove((Song)items[i]);
            }
        }
        private void ChangeButton_OnClick(object sender, RoutedEventArgs e)
        {
            int count = MyTabControl.GetChildOfType <ListView>().SelectedItems.Count;

            if (count > 1)
            {
                StateLabel.Text = "Choose only one song";
                return;
            }
            if (count == 0)
            {
                StateLabel.Text = "Choose song";
                return;
            }
            var eW = new EditWindow((Song)MyTabControl.GetChildOfType <ListView>().SelectedItem, User.AccessToken);

            eW.ShowDialog();
        }
 private void PlayButton_OnClick(object sender, RoutedEventArgs e)
 {
     if (!MyTabControl.GetChildOfType <ListView>().SelectedItems.Cast <Song>().ToList().Any())
     {
         _selectedSongs =
             new ObservableCollection <Song>(
                 MyTabControl.GetChildOfType <ListView>().ItemsSource.Cast <Song>().ToList());
     }
     else
     {
         _selectedSongs =
             new ObservableCollection <Song>(
                 MyTabControl.GetChildOfType <ListView>().SelectedItems.Cast <Song>().ToList());
     }
     _index = -1;
     _audioTimeUpdateTimer.Start();
     _isPlaying = true;
     CurrentSongsListBox.ItemsSource = _selectedSongs;
     PlayNextSong();
 }