Beispiel #1
0
        private async void MainPanel_ContextMenuOpening(object sender, RoutedEventArgs e)
        {
            MiscContext.Items.Clear();
            var playlists = library.Database.GetCollection <DatabasePlaylist>("playlists").Query().OrderBy("Name").ToEnumerable();

            foreach (var playlist in playlists)
            {
                List <DatabaseTrack> tracks;
                try
                {
                    tracks = await Task.Run(() => library.ReadTracksForPlaylist(playlist.Name));
                }
                catch
                {
                    continue;
                }
                var trackIsInPlaylist = tracks.Any(x => x.Path == FilePath);
                var item = new MenuItem
                {
                    Header      = playlist.Name,
                    IsCheckable = true
                };
                item.IsChecked = trackIsInPlaylist;
                item.Click    += (object sende, RoutedEventArgs ee) =>
                {
                    if (trackIsInPlaylist)
                    {
                        library.RemoveTrackFromPlaylist((string)item.Header, FilePath);
                    }
                    else
                    {
                        library.AddTrackToPlaylist((string)item.Header, FilePath);
                    }
                };
                MiscContext.Items.Add(item);
            }
            MiscContext.Items.Add(new Separator());
            var otheritem = new MenuItem();

            otheritem.Header = Properties.Resources.PLAYLISTMANAGEMENT;
            otheritem.Click += (object send, RoutedEventArgs eee) =>
            {
                var management = new PlaylistManagement(library, notificationHandler, ((Application.Current as App).MainWindow as MainWindow).CurrentTab, FilePath);
                management.ShowDialog();
            };
            MiscContext.Items.Add(otheritem);
        }
 private void RemoveButton_Click(object sender, RoutedEventArgs e)
 {
     library.RemoveTrackFromPlaylist(playlist, path);
     CheckIfPlaylistExists();
 }