コード例 #1
0
        private void PlaylistSelectionChanged(int index)
        {
            IITPlaylist newPlaylist = null;

            if ((index > 0) && (index < _playlists.Count))
            {
                newPlaylist = _playlists[index];
                _workspaceViewModel.Workspace.Settings.ITunesSyncPlaylist = newPlaylist.Name;
                ITunesSync.RemoveOldTracks(newPlaylist);
            }

            foreach (var track in _workspaceViewModel.Tracks)
            {
                if (SelectedPlaylist != null)
                {
                    ITunesSync.RemoveTrack(SelectedPlaylist, track.Item);
                }

                if (newPlaylist != null)
                {
                    ITunesSync.AddTrack(newPlaylist, track.Item, track.GetFilePath());
                }
            }

            if (newPlaylist != null)
            {
                SelectedPlaylist = newPlaylist;
            }
        }
コード例 #2
0
        private void RefreshITunesPlaylists()
        {
            new Thread(() =>
            {
                Playlists.Clear();
                Playlists.Add("Disabled");
                _playlists.Clear();
                _playlists.Add(null);

                var i = 1;
                foreach (var playlist in ITunesSync.GetAllPlaylists())
                {
                    Playlists.Add(playlist.Name);
                    _playlists.Add(playlist);

                    if (playlist.Name == _workspaceViewModel.Workspace.Settings.ITunesSyncPlaylist)
                    {
                        SelectedPlaylistIndex = i;
                    }

                    i++;
                }

                if (SelectedPlaylistIndex == -1)
                {
                    SelectedPlaylistIndex = 0;
                }
            }).Start();
        }