/// <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>
        /// Let the user and other compnents know that the scan process has finished
        /// </summary>
        private void NotifyScanFinished()
        {
            // If there have been any changes to the library, and it is the library currently being displayed then force a refresh
            if ((LibraryScanModel.LibraryModified == true) && (libraryBeingScanned.Id == ConnectionDetailsModel.LibraryId))
            {
                new SelectedLibraryChangedMessage()
                {
                    SelectedLibrary = libraryBeingScanned.Id
                }.Send();
            }

            // Let the user know that the process has finished
            NotificationDialogFragment.ShowFragment(CommandRouter.Manager,
                                                    $"Scanning of library: {libraryBeingScanned.Name} {( ( cancelHasBeenRequested == true ) ? "cancelled" : "finished" )}");

            commandState = CommandStateType.Idle;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when an updated source has been submitted for saving
        /// Only update the existing source if it has been changed.
        /// </summary>
        /// <param name="originalSource"></param>
        /// <param name="newSource"></param>
        private void SourceChanged(Source originalSource, Source newSource, SourceEditDialogFragment sourceEditDialog)
        {
            // If nothing has changed then tell the user, otherwise carry out the save operation
            if ((newSource.Name != originalSource.Name) || (newSource.FolderName != originalSource.FolderName) ||
                (newSource.PortNo != originalSource.PortNo) || (newSource.IPAddress != originalSource.IPAddress) ||
                (newSource.AccessMethod != originalSource.AccessMethod))
            {
                // Something has changed so update the source
                originalSource.UpdateSource(newSource);

                // Need to tell the SourceSelectionDialogFragment that it needs to redisplay its data
                sourceSelectionDialog?.OnSourceChanged();

                // Dismiss the dialogue
                sourceEditDialog.Dismiss();
            }
            else
            {
                // Nothing has changed
                NotificationDialogFragment.ShowFragment(CommandRouter.Manager, "No changes made to source");
            }
        }
        /// <summary>
        /// Delegate called when the unmatched song deletion process has finished
        /// </summary>
        public void DeleteFinished()
        {
            // If the UI is available then get rid of the Scan In Progress dialoue
            if (scanProgressDialog != null)
            {
                scanProgressDialog.Dismiss();

                // If there have been any changes to the library, and it is the library currently being displayed then force a refresh
                if ((LibraryScanModel.LibraryModified == true) && (libraryBeingScanned.Id == ConnectionDetailsModel.LibraryId))
                {
                    new SelectedLibraryChangedMessage()
                    {
                        SelectedLibrary = libraryBeingScanned.Id
                    }.Send();
                }

                NotificationDialogFragment.ShowFragment(CommandRouter.Manager, $"Scanning of library: {LibraryScanModel.LibraryBeingScanned.Name} finished");
                commandState = CommandStateType.Idle;
            }
            else
            {
                commandState = CommandStateType.DeleteComplete;
            }
        }