Пример #1
0
        async Task <Dictionary <Playlist, IEnumerable <Mediafile> > > ShowAddPlaylistDialog()
        {
            var dialog = new InputDialog()
            {
                Title = "Name this playlist",
            };
            var Playlists = new Dictionary <Playlist, IEnumerable <Mediafile> >();

            if (await dialog.ShowAsync() == ContentDialogResult.Primary && dialog.Text != "")
            {
                if (!PlaylistCollection.Any(t => t.Name == dialog.Text))
                {
                    var pl = new Playlist()
                    {
                        Name = dialog.Text, Description = dialog.Description
                    };
                    Playlists.Add(pl, db.PlaylistSort(pl.Name));
                    var cmd = new ContextMenuCommand(AddToPlaylistCommand, pl.Name);
                    Options.Add(cmd);

                    ShellVM.PlaylistsItems.Add(new SplitViewMenu.SimpleNavMenuItem
                    {
                        Arguments       = Playlists,
                        Label           = dialog.Text,
                        DestinationPage = typeof(PlaylistView),
                        Symbol          = Symbol.List
                    });
                }


                return(Playlists);
            }
            return(Playlists);
        }
Пример #2
0
        private void Messages_OnScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            if (SelectedRoom == null)
            {
                return;
            }

            ListBoxItem lastItem   = null;
            var         stackPanel = Messages.FindVisualChild <VirtualizingStackPanel>();

            for (var i = 0; i < stackPanel.Children.Count; i++)
            {
                if (i >= stackPanel.VerticalOffset && i < stackPanel.VerticalOffset + stackPanel.ViewportHeight)
                {
                    lastItem = stackPanel.Children[i] as ListBoxItem;
                }
            }

            if (lastItem != null)
            {
                SelectedRoom.LastVisibleMessage = lastItem.DataContext as ChatMessage;

                if (SelectedRoom.LastVisibleMessage == SelectedRoom.Messages.LastOrDefault())
                {
                    SelectedRoom.HasNewItems = false;
                }

                UnreadMessages.SafeInvoke(_chatRooms.Any(r => r.HasNewItems));
            }
        }
Пример #3
0
        async Task <Dictionary <Playlist, IEnumerable <Mediafile> > > ShowAddPlaylistDialog()
        {
            var dialog = new InputDialog()
            {
                Title = "Name this playlist",
            };
            var Playlists = new Dictionary <Playlist, IEnumerable <Mediafile> >();

            if (await dialog.ShowAsync() == ContentDialogResult.Primary && dialog.Text != "")
            {
                if (!PlaylistCollection.Any(t => t.Name == dialog.Text))
                {
                    AddPlaylist(Playlists, dialog.Text, dialog.Description);
                }
                return(Playlists);
            }
            return(Playlists);
        }
 /// <summary>
 /// Adds all albums to <see cref="AlbumCollection"/>.
 /// </summary>
 /// <remarks>This is still experimental, a lot of performance improvements are needed.
 /// For instance, for each loop needs to be removed.
 /// Maybe we can use direct database queries and fill the AlbumCollection with it?
 /// </remarks>
 public void AddAlbums()
 {
     foreach (var song in LibVM.TracksCollection.Elements)
     {
         Album alb = null;
         if (!AlbumCollection.Any(t => t.AlbumName == song.Album && t.Artist == song.LeadArtist))
         {
             alb           = new Album();
             alb.AlbumName = song.Album;
             alb.Artist    = song.LeadArtist;
             alb.AlbumArt  = song.AttachedPicture;
             AlbumCollection.Add(alb);
         }
         else
         {
             AlbumCollection.First(t => t.AlbumName == song.Album && t.Artist == song.LeadArtist).AlbumSongs.Add(song);
         }
     }
 }
Пример #5
0
 public static bool IsPlayingCollection(this ThreadSafeObservableCollection <Mediafile> collection)
 {
     return(collection?.Any(t => t.State == Core.Common.PlayerState.Playing) == true);
 }