/// <summary>
        /// Called when a playlist name has been entered has been selected.
        /// </summary>
        /// <param name="selectedLibrary"></param>
        private async void NameEntered(string libraryName, NewLibraryNameDialogFragment libraryNameFragment)
        {
            string alertText = "";

            // An empty library name is not allowed
            if (libraryName.Length == 0)
            {
                alertText = EmptyNameError;
            }
            else
            {
                // Check for a duplicate
                if (Libraries.LibraryNames.Contains(libraryName) == true)
                {
                    alertText = DuplicateLibraryError;
                }
                else
                {
                    // Create a library with a default source and display the source editing fragment
                    Library newLibrary = new() { Name = libraryName };
                    await Libraries.AddLibraryAsync(newLibrary);

                    // Add a source
                    Source newSource = new() { Name = libraryName, AccessMethod = Source.AccessType.Local, FolderName = libraryName, LibraryId = newLibrary.Id };
                    await Sources.AddSourceAsync(newSource);

                    // Add an empty NowPlaying list
                    Playlist nowPlaying = new SongPlaylist()
                    {
                        Name = Playlists.NowPlayingPlaylistName, LibraryId = newLibrary.Id
                    };
                    await Playlists.AddPlaylistAsync(nowPlaying);

                    nowPlaying.SongIndex = -1;

                    SourceSelectionDialogFragment.ShowFragment(CommandRouter.Manager, newLibrary, SourceSelected, BindDialog);
                }
            }

            // Display an error message if the playlist name is not valid.
            if (alertText.Length > 0)
            {
                NotificationDialogFragment.ShowFragment(CommandRouter.Manager, alertText);
            }
            else
            {
                // Dismiss the library name dialogue
                libraryNameFragment.Dismiss();
            }
        }
 /// <summary>
 /// Called when the SourceSelectionDialogFragment dialog is displayed (OnResume)
 /// Save the reference for updating the sources if tey are edited
 /// </summary>
 /// <param name="dialogue"></param>
 private void BindDialog(SourceSelectionDialogFragment dialogue) => sourceSelectionDialog = dialogue;
Example #3
0
 /// <summary>
 /// Called when a library has been selected.
 /// </summary>
 /// <param name="selectedLibrary"></param>
 private void LibrarySelected(Library selectedLibrary) =>
 SourceSelectionDialogFragment.ShowFragment(CommandRouter.Manager, selectedLibrary, SourceSelected, BindDialog);