예제 #1
0
        private async Task OnViewLoaded(PlaylistTabViewModel x)
        {
            if (x == null)
            {
                return;
            }
            if (x.GetItemCount() > 0)
            {
                return;
            }

            if (x.TabHeader == "Preparation Playlist")
            {
                return;
            }

            if (x.Playlist != null)
            {
                if (x.Playlist.Count > 0)
                {
                    var playlistSongs = await _horsifyPlaylistService.GetSongs(x.Playlist);

                    //Add item view models for all the returned songs
                    foreach (var song in playlistSongs)
                    {
                        x.AddPlaylistItem(new PlaylistItemViewModel(_loggerFacade)
                        {
                            Song        = song,
                            PlayedState = 0
                        });
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Closes the tab from the TabControl
        /// </summary>
        /// <param name="vm">The vm.</param>
        private void OnCloseTab(PlaylistTabViewModel vm)
        {
            try
            {
                if (SelectedTab != null)
                {
                    //User could push close button on tab and not actually be selected so set to incoming VM
                    if (SelectedTab != vm)
                    {
                        SelectedTab = vm;
                    }

                    if (SelectedTab.Playlist != null)
                    {
                        Log("Clearing tab items.");
                        //Clear the songs
                        SelectedTab.ClearItems();
                    }

                    //Remove the tab
                    OpenPlayListViewModels.Remove(SelectedTab);
                    Log($"Closed - {SelectedTab?.Playlist?.Name}");
                }
            }
            catch (System.Exception ex)
            {
                Log($"Close tab error: {ex.Message}");
            }
        }
예제 #3
0
        private void CreatePlayList(string playListName, bool addToTabsRegion = false)
        {
            PlaylistTabViewModel vm = null;

            if (!PlayListViewModels.Any(x => x.TabHeader == playListName))
            {
                vm           = ResolveNewTabModelFromContainer();
                vm.TabHeader = playListName;
                PlayListViewModels.Add(vm);
                Log($"Created playlist - {playListName}");
            }

            if (addToTabsRegion)
            {
                Log("Adding to tab region");
                OpenPlayListViewModels.Add(vm);
                _lastOpenedTab = vm;
            }
        }
예제 #4
0
        private async void OnOpenPlaylist(PlaylistTabViewModel playlistTabViewModel)
        {
            try
            {
                if (!OpenPlayListViewModels.Any(x => x == playlistTabViewModel))
                {
                    Log($"Opening existing: {playlistTabViewModel.Playlist?.Name}", Category.Debug);
                    OpenPlayListViewModels.Add(playlistTabViewModel);
                    await OnViewLoaded(playlistTabViewModel);
                }
                else if (playlistTabViewModel?.Playlist?.Id == 0)
                {
                    Log("Adding a not saved playlist");
                    OpenPlayListViewModels.Add(playlistTabViewModel);
                }

                SelectedTab = playlistTabViewModel;
            }
            catch (System.Exception ex)
            {
                Log(ex.Message, Category.Exception);
            }
        }
예제 #5
0
 private void OnOpenSavedPlaylist(PlaylistTabViewModel obj)
 {
     OnOpenPlaylist(obj);
 }