/// <summary> /// Checks if we are in PartyMode & if a new song started playing /// Called from OnPlaybackControllerTrackStarted /// </summary> private void CheckForSwitch() { ThreadAssist.ProxyToMain(delegate { TrackInfo current_track = ServiceManager.PlaybackController.CurrentTrack; if (current_track != null && transitioned_track != current_track) { if (IsActiveSource) { FilterView.LabelTrack.SetValueWithAnim(current_track.TrackNumber + " - " + current_track.TrackTitle); } if (InPartyMode) { DatabaseAlbumInfo album = DatabaseAlbumInfo.FindOrCreate( DatabaseArtistInfo.FindOrCreate(current_track.AlbumArtist, current_track.AlbumArtistSort), current_track.AlbumTitle, current_track.AlbumTitleSort, current_track.IsCompilation); FilterView.ScrollTo(album); } transitioned_track = ServiceManager.PlayerEngine.CurrentTrack; } }); }
private void OnMerge(object o, EventArgs a) { var discs = library.BooksModel.SelectedItems.OrderBy(d => d.Title).ToList(); var author = DatabaseArtistInfo.Provider.FetchSingle((discs[0] as DatabaseAlbumInfo).ArtistId); var dialog = new HigMessageDialog( ServiceManager.Get <GtkElementsService> ().PrimaryWindow, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel, String.Format(Catalog.GetPluralString( "Merge the {0} selected discs into one book?", "Merge the {0} selected discs into one book?", discs.Count), discs.Count), Catalog.GetString( "This will ensure the disc numbers are all " + "set properly, and then set the author and book title for all tracks " + "on all these discs to the values below") ); var table = new SimpleTable <int> (); var author_entry = new Entry() { Text = discs[0].ArtistName }; table.AddRow(0, new Label(Catalog.GetString("Author:")) { Xalign = 0 }, author_entry ); var trimmings = new char [] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '-' }; var title_entry = new Entry() { Text = discs[0].Title.Trim(trimmings) }; table.AddRow(1, new Label(Catalog.GetString("Book Title:")) { Xalign = 0 }, title_entry ); dialog.LabelVBox.PackStart(table, false, false, 0); dialog.ShowAll(); var response = dialog.Run(); string title = title_entry.Text; string author_name = author_entry.Text; dialog.Destroy(); if (response == (int)Gtk.ResponseType.Ok && !String.IsNullOrEmpty(title)) { if (author_name != author.Name) { author = DatabaseArtistInfo.FindOrCreate(author_name, null); } var book = DatabaseAlbumInfo.FindOrCreate(author, title, null, false); int disc_num = 1; foreach (DatabaseAlbumInfo disc in discs) { // Update the disc num/count field for all tracks on this 'book' (actually just one disc of a book) ServiceManager.DbConnection.Execute( @"UPDATE CoreTracks SET AlbumID = ?, Disc = ?, DiscCount = ?, DateUpdatedStamp = ? WHERE PrimarySourceID = ? AND AlbumID = ?", book.DbId, disc_num++, discs.Count, DateTime.Now, library.DbId, disc.DbId ); } // Update the MetadataHash for all those tracks DatabaseTrackInfo.UpdateMetadataHash( book.Title, author.Name, String.Format("PrimarySourceId = {0} AND AlbumID = {1}", library.DbId, book.DbId) ); library.NotifyTracksChanged(); } }