/// <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}"); } }
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; } }
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); } }