From b661ad540b9434c4f184fcb33a327bf8529f00e4 Mon Sep 17 00:00:00 2001 From: VPKSoft Date: Sun, 21 Aug 2022 15:31:37 +0300 Subject: [PATCH] Add album ComboBox refresh. --- amp.EtoForms/FormMain.Events.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/amp.EtoForms/FormMain.Events.cs b/amp.EtoForms/FormMain.Events.cs index 68364ffc..4f565831 100644 --- a/amp.EtoForms/FormMain.Events.cs +++ b/amp.EtoForms/FormMain.Events.cs @@ -46,6 +46,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using EtoForms.Controls.Custom.UserIdle; using EtoForms.Controls.Custom.Utilities; using Microsoft.EntityFrameworkCore; +using Album = amp.EtoForms.DtoClasses.Album; using AlbumTrack = amp.EtoForms.DtoClasses.AlbumTrack; using AudioTrack = amp.EtoForms.DtoClasses.AudioTrack; @@ -534,14 +535,35 @@ await Globals.LoggerSafeInvokeAsync(async () => private async void ManageAlbumsCommand_Executed(object? sender, EventArgs e) { + using var form = new FormAlbums(context); + + bool changed; + if (UtilityOS.IsMacOS) { // ReSharper disable once MethodHasAsyncOverload, Shown-event won't fire on macOS. - new FormAlbums(context).ShowModal(this); + changed = form.ShowModal(this); } else { - await new FormAlbums(context).ShowModalAsync(this); + changed = await form.ShowModalAsync(this); + } + + if (changed) + { + suspendAlbumChange = true; + albums = context.Albums.Select(f => Globals.AutoMapper.Map(f)).ToList(); + cmbAlbumSelect.DataStore = albums; + var index = albums.FindIndex(f => f.Id == CurrentAlbumId); + if (index == -1) + { + CurrentAlbumId = 1; + } + else + { + cmbAlbumSelect.SelectedIndex = index; + } + suspendAlbumChange = false; } }