Example #1
0
        private void ImportButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Filter = "Playlist Files|*.xspf;*.asx;*.wax;*.wvx;*.b4s;*.m3u;*.m3u8;*.pls;*.smil;*.smi;*.zpl;";
            if (dialog.ShowDialog() == true)
            {
                IPlaylistIO reader = PlaylistIOFactory.GetInstance().GetPlaylistIO(dialog.FileName);
                foreach (string s in reader.FilePaths)
                {
                    if (!File.Exists(s))
                    {
                        notificationHandler.Add(new Notification
                        {
                            ContentText    = string.Format(Properties.Resources.NOTIFICATION_COULD_NOT_IMPORT_PLAYLIST, s),
                            IsImportant    = true,
                            DisplayAsToast = true,
                            Type           = NotificationType.Failure
                        });
                        continue;
                    }
                    library.AddTrackToPlaylist(Path.GetFileNameWithoutExtension(dialog.FileName), s);
                }
            }
            InitFields();
        }
Example #2
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 AddButton_Click(object sender, RoutedEventArgs e)
 {
     library.AddTrackToPlaylist(playlist, path);
     CheckIfPlaylistExists();
 }